summaryrefslogtreecommitdiff
path: root/include/linux/time_stats.h
blob: 7ae929e6f836d86da8723fa0b24dbd1fbe7a1e26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* SPDX-License-Identifier: GPL-2.0 */

#ifndef _LINUX_TIMESTATS_H
#define _LINUX_TIMESTATS_H

#include <linux/spinlock_types.h>
#include <linux/types.h>

#define NR_QUANTILES	15

struct quantiles {
	struct quantile_entry {
		u64	m;
		u64	step;
	}		entries[NR_QUANTILES];
};

struct time_stat_buffer {
	unsigned int	nr;
	struct time_stat_buffer_entry {
		u64	start;
		u64	end;
	}		entries[32];
};

struct time_stats {
	spinlock_t	lock;
	u64		count;
	/* all fields are in nanoseconds */
	u64		average_duration;
	u64		average_frequency;
	u64		max_duration;
	u64		last_event;
	struct quantiles quantiles;

	struct time_stat_buffer __percpu *buffer;
};

struct seq_buf;
void time_stats_update(struct time_stats *stats, u64 start);
void time_stats_to_text(struct seq_buf *out, struct time_stats *stats);
void time_stats_exit(struct time_stats *stats);

#endif /* _LINUX_TIMESTATS_H */