/* SPDX-License-Identifier: GPL-2.0 */ /* * bch2_time_stats - collect statistics on events that have a duration, with nicely * formatted textual output on demand * * - percpu buffering of event collection: cheap enough to shotgun * everywhere without worrying about overhead * * tracks: * - number of events * - maximum event duration ever seen * - sum of all event durations * - average event duration, standard and weighted * - standard deviation of event durations, standard and weighted * and analagous statistics for the frequency of events * * We provide both mean and weighted mean (exponentially weighted), and standard * deviation and weighted standard deviation, to give an efficient-to-compute * view of current behaviour versus. average behaviour - "did this event source * just become wonky, or is this typical?". * * Particularly useful for tracking down latency issues.
*/ #ifndef _BCACHEFS_TIME_STATS_H #define _BCACHEFS_TIME_STATS_H
/** * time_stats_update - collect a new event being tracked * * @stats - bch2_time_stats to update * @start - start time of event, recorded with local_clock() * * The end duration of the event will be the current time
*/ staticinlinevoid bch2_time_stats_update(struct bch2_time_stats *stats, u64 start)
{
__bch2_time_stats_update(stats, start, local_clock());
}
/** * track_event_change - track state change events * * @stats - bch2_time_stats to update * @v - new state, true or false * * Use this when tracking time stats for state changes, i.e. resource X becoming * blocked/unblocked.
*/ staticinlinebool track_event_change(struct bch2_time_stats *stats, bool v)
{ if (v != !!stats->last_event_start) { if (!v) {
bch2_time_stats_update(stats, stats->last_event_start);
stats->last_event_start = 0;
} else {
stats->last_event_start = local_clock() ?: 1; returntrue;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.