^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __TRACE_STAT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __TRACE_STAT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * If you want to provide a stat file (one-shot statistics), fill
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * an iterator with stat_start/stat_next and a stat_show callbacks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * The others callbacks are optional.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct tracer_stat {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /* The name of your stat file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) /* Iteration over statistic entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) void *(*stat_start)(struct tracer_stat *trace);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) void *(*stat_next)(void *prev, int idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /* Compare two entries for stats sorting */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) cmp_func_t stat_cmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /* Print a stat entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) int (*stat_show)(struct seq_file *s, void *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) /* Release an entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) void (*stat_release)(void *stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) /* Print the headers of your stat entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) int (*stat_headers)(struct seq_file *s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * Destroy or create a stat file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) extern int register_stat_tracer(struct tracer_stat *trace);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) extern void unregister_stat_tracer(struct tracer_stat *trace);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #endif /* __TRACE_STAT_H */