Lines Matching +full:switching +full:- +full:freq

1 // SPDX-License-Identifier: GPL-2.0
13 /* disable automatic switching to percpu mode */
46 while (i < ARRAY_SIZE(q->entries)) { in quantiles_update()
47 struct quantile_entry *e = q->entries + i; in quantiles_update()
49 if (unlikely(!e->step)) { in quantiles_update()
50 e->m = v; in quantiles_update()
51 e->step = max_t(unsigned, v / 2, 1024); in quantiles_update()
52 } else if (e->m > v) { in quantiles_update()
53 e->m = e->m >= e->step in quantiles_update()
54 ? e->m - e->step in quantiles_update()
56 } else if (e->m < v) { in quantiles_update()
57 e->m = e->m + e->step > e->m in quantiles_update()
58 ? e->m + e->step in quantiles_update()
62 if ((e->m > v ? e->m - v : v - e->m) < e->step) in quantiles_update()
63 e->step = max_t(unsigned, e->step / 2, 1); in quantiles_update()
65 if (v >= e->m) in quantiles_update()
68 i = eytzinger0_child(i, v > e->m); in quantiles_update()
75 u64 duration, freq; in time_stats_update_one() local
76 bool initted = stats->last_event != 0; in time_stats_update_one()
81 duration = end - start; in time_stats_update_one()
82 mean_and_variance_update(&stats->duration_stats, duration); in time_stats_update_one()
83 mean_and_variance_weighted_update(&stats->duration_stats_weighted, in time_stats_update_one()
85 stats->max_duration = max(stats->max_duration, duration); in time_stats_update_one()
86 stats->min_duration = min(stats->min_duration, duration); in time_stats_update_one()
87 stats->total_duration += duration; in time_stats_update_one()
93 if (stats->last_event && time_after64(end, stats->last_event)) { in time_stats_update_one()
94 freq = end - stats->last_event; in time_stats_update_one()
95 mean_and_variance_update(&stats->freq_stats, freq); in time_stats_update_one()
96 mean_and_variance_weighted_update(&stats->freq_stats_weighted, in time_stats_update_one()
97 freq, initted, TIME_STATS_MV_WEIGHT); in time_stats_update_one()
98 stats->max_freq = max(stats->max_freq, freq); in time_stats_update_one()
99 stats->min_freq = min(stats->min_freq, freq); in time_stats_update_one()
102 stats->last_event = end; in time_stats_update_one()
108 for (struct time_stat_buffer_entry *i = b->entries; in __bch2_time_stats_clear_buffer()
109 i < b->entries + ARRAY_SIZE(b->entries); in __bch2_time_stats_clear_buffer()
111 time_stats_update_one(stats, i->start, i->end); in __bch2_time_stats_clear_buffer()
112 b->nr = 0; in __bch2_time_stats_clear_buffer()
120 spin_lock_irqsave(&stats->lock, flags); in time_stats_clear_buffer()
122 spin_unlock_irqrestore(&stats->lock, flags); in time_stats_clear_buffer()
129 if ((unsigned long) stats->buffer <= TIME_STATS_NONPCPU) { in __bch2_time_stats_update()
130 spin_lock_irqsave(&stats->lock, flags); in __bch2_time_stats_update()
133 if (!stats->buffer && in __bch2_time_stats_update()
134 mean_and_variance_weighted_get_mean(stats->freq_stats_weighted, TIME_STATS_MV_WEIGHT) < 32 && in __bch2_time_stats_update()
135 stats->duration_stats.n > 1024) in __bch2_time_stats_update()
136 stats->buffer = in __bch2_time_stats_update()
139 spin_unlock_irqrestore(&stats->lock, flags); in __bch2_time_stats_update()
144 b = this_cpu_ptr(stats->buffer); in __bch2_time_stats_update()
146 BUG_ON(b->nr >= ARRAY_SIZE(b->entries)); in __bch2_time_stats_update()
147 b->entries[b->nr++] = (struct time_stat_buffer_entry) { in __bch2_time_stats_update()
152 if (unlikely(b->nr == ARRAY_SIZE(b->entries))) in __bch2_time_stats_update()
160 spin_lock_irq(&stats->lock); in bch2_time_stats_reset()
162 memset((void *) stats + offset, 0, sizeof(*stats) - offset); in bch2_time_stats_reset()
164 if ((unsigned long) stats->buffer > TIME_STATS_NONPCPU) { in bch2_time_stats_reset()
167 per_cpu_ptr(stats->buffer, cpu)->nr = 0; in bch2_time_stats_reset()
169 spin_unlock_irq(&stats->lock); in bch2_time_stats_reset()
174 if ((unsigned long) stats->buffer > TIME_STATS_NONPCPU) in bch2_time_stats_exit()
175 free_percpu(stats->buffer); in bch2_time_stats_exit()
176 stats->buffer = NULL; in bch2_time_stats_exit()
182 stats->min_duration = U64_MAX; in bch2_time_stats_init()
183 stats->min_freq = U64_MAX; in bch2_time_stats_init()
184 spin_lock_init(&stats->lock); in bch2_time_stats_init()
190 stats->buffer = (struct time_stat_buffer __percpu *) TIME_STATS_NONPCPU; in bch2_time_stats_init_no_pcpu()