aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.h
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2008-12-28 23:44:51 -0500
committerIngo Molnar <mingo@elte.hu>2008-12-29 06:55:45 -0500
commitdbd0b4b33074aa6b7832a9d9a5bd985eca5c1aa2 (patch)
treeb2f498a25c176cdba29cb1f9d1e854d38204192e /kernel/trace/trace.h
parentf633cef0200bbaec539e2dbb0bc4bed7f022f98b (diff)
tracing/ftrace: provide the base infrastructure for histogram tracing
Impact: extend the tracing API The goal of this patch is to normalize and make more easy the implementation of statistical (histogram) tracing. It implements a trace_stat file into the /debugfs/tracing directory where one can print a one-shot output of statistics/histogram entries. A tracer has to provide two basic iterator callbacks: stat_start() => the first entry stat_next(prev, idx) => the next one. Note that it is adapted for arrays or hash tables or lists.... since it provides a pointer to the previous entry and the current index of the iterator. These two callbacks are called to get a snapshot of the statistics at each opening of the trace_stat file because. The values are so updated between two "cat trace_stat". And the tracer is free to lock its datas during the iteration to keep consistent values. Since it is almost always interesting to sort statisticals values to address the problems by priority, this infrastructure provides a "sorting" of the stat entries too if desired. A tracer has just to provide a stat_cmp callback to compare two entries and the stat tracing infrastructure will build a sorted list of the given entries. A last callback, called stat_headers, can be implemented by a tracer to output headers on its trace. If one of these callbacks is changed on runtime, it just have to signal it to the stat tracing API by calling the init_tracer_stat() helper. Changes in V2: - Fix a memory leak if the user opens multiple times the trace_stat file without closing it. Now we always free our list before rebuilding it. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace.h')
-rw-r--r--kernel/trace/trace.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 6bd71fa1e1c7..05fa804d1c16 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -336,6 +336,21 @@ struct tracer {
336 struct tracer *next; 336 struct tracer *next;
337 int print_max; 337 int print_max;
338 struct tracer_flags *flags; 338 struct tracer_flags *flags;
339
340 /*
341 * If you change one of the following on tracing runtime, recall
342 * init_tracer_stat()
343 */
344
345 /* Iteration over statistic entries */
346 void *(*stat_start)(void);
347 void *(*stat_next)(void *prev, int idx);
348 /* Compare two entries for sorting (optional) for stats */
349 int (*stat_cmp)(void *p1, void *p2);
350 /* Print a stat entry */
351 int (*stat_show)(struct seq_file *s, void *p);
352 /* Print the headers of your stat entries */
353 int (*stat_headers)(struct seq_file *s);
339}; 354};
340 355
341struct trace_seq { 356struct trace_seq {
@@ -421,6 +436,8 @@ void tracing_start_sched_switch_record(void);
421int register_tracer(struct tracer *type); 436int register_tracer(struct tracer *type);
422void unregister_tracer(struct tracer *type); 437void unregister_tracer(struct tracer *type);
423 438
439void init_tracer_stat(struct tracer *trace);
440
424extern unsigned long nsecs_to_usecs(unsigned long nsecs); 441extern unsigned long nsecs_to_usecs(unsigned long nsecs);
425 442
426extern unsigned long tracing_max_latency; 443extern unsigned long tracing_max_latency;