Linux 2.6.28-rc5
[cris-mirror.git] / kernel / trace / trace_functions.c
blob0f85a64003d3980d1002d1877712808703f25cb9
1 /*
2 * ring buffer based function tracer
4 * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com>
5 * Copyright (C) 2008 Ingo Molnar <mingo@redhat.com>
7 * Based on code from the latency_tracer, that is:
9 * Copyright (C) 2004-2006 Ingo Molnar
10 * Copyright (C) 2004 William Lee Irwin III
12 #include <linux/debugfs.h>
13 #include <linux/uaccess.h>
14 #include <linux/ftrace.h>
15 #include <linux/fs.h>
17 #include "trace.h"
19 static void function_reset(struct trace_array *tr)
21 int cpu;
23 tr->time_start = ftrace_now(tr->cpu);
25 for_each_online_cpu(cpu)
26 tracing_reset(tr, cpu);
29 static void start_function_trace(struct trace_array *tr)
31 tr->cpu = get_cpu();
32 function_reset(tr);
33 put_cpu();
35 tracing_start_cmdline_record();
36 tracing_start_function_trace();
39 static void stop_function_trace(struct trace_array *tr)
41 tracing_stop_function_trace();
42 tracing_stop_cmdline_record();
45 static void function_trace_init(struct trace_array *tr)
47 if (tr->ctrl)
48 start_function_trace(tr);
51 static void function_trace_reset(struct trace_array *tr)
53 if (tr->ctrl)
54 stop_function_trace(tr);
57 static void function_trace_ctrl_update(struct trace_array *tr)
59 if (tr->ctrl)
60 start_function_trace(tr);
61 else
62 stop_function_trace(tr);
65 static struct tracer function_trace __read_mostly =
67 .name = "function",
68 .init = function_trace_init,
69 .reset = function_trace_reset,
70 .ctrl_update = function_trace_ctrl_update,
71 #ifdef CONFIG_FTRACE_SELFTEST
72 .selftest = trace_selftest_startup_function,
73 #endif
76 static __init int init_function_trace(void)
78 return register_tracer(&function_trace);
81 device_initcall(init_function_trace);