Skip to content

Commit 7b508b3

Browse files
author
Kent Overstreet
committed
bcachefs: time_stats: Check for last_event == 0 when updating freq stats
This fixes spurious outliers in the frequency stats. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent dd839f3 commit 7b508b3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/bcachefs/util.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,14 +418,15 @@ static inline void bch2_time_stats_update_one(struct bch2_time_stats *stats,
418418
bch2_quantiles_update(&stats->quantiles, duration);
419419
}
420420

421-
if (time_after64(end, stats->last_event)) {
421+
if (stats->last_event && time_after64(end, stats->last_event)) {
422422
freq = end - stats->last_event;
423423
mean_and_variance_update(&stats->freq_stats, freq);
424424
mean_and_variance_weighted_update(&stats->freq_stats_weighted, freq);
425425
stats->max_freq = max(stats->max_freq, freq);
426426
stats->min_freq = min(stats->min_freq, freq);
427-
stats->last_event = end;
428427
}
428+
429+
stats->last_event = end;
429430
}
430431

431432
static void __bch2_time_stats_clear_buffer(struct bch2_time_stats *stats,

0 commit comments

Comments
 (0)