]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bcachefs: time_stats: Check for last_event == 0 when updating freq stats
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 2 Feb 2024 02:01:02 +0000 (21:01 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Feb 2024 18:14:31 +0000 (19:14 +0100)
commit 7b508b323b2ec45be59769bd4e4aeba729c52cf6 upstream.

This fixes spurious outliers in the frequency stats.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/bcachefs/util.c

index 84b142fcc3dfce6cfbdb30647d4aa67609511519..3b7c349f2665adc7e91163147dd4afa9727c48d2 100644 (file)
@@ -362,14 +362,15 @@ static inline void bch2_time_stats_update_one(struct bch2_time_stats *stats,
                bch2_quantiles_update(&stats->quantiles, duration);
        }
 
-       if (time_after64(end, stats->last_event)) {
+       if (stats->last_event && time_after64(end, stats->last_event)) {
                freq = end - stats->last_event;
                mean_and_variance_update(&stats->freq_stats, freq);
                mean_and_variance_weighted_update(&stats->freq_stats_weighted, freq);
                stats->max_freq = max(stats->max_freq, freq);
                stats->min_freq = min(stats->min_freq, freq);
-               stats->last_event = end;
        }
+
+       stats->last_event = end;
 }
 
 static noinline void bch2_time_stats_clear_buffer(struct bch2_time_stats *stats,