]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - kernel/trace/trace_functions.c
ftrace: set_ftrace_notrace feature
[mirror_ubuntu-bionic-kernel.git] / kernel / trace / trace_functions.c
CommitLineData
1b29b018
SR
1/*
2 * ring buffer based function tracer
3 *
4 * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com>
5 * Copyright (C) 2008 Ingo Molnar <mingo@redhat.com>
6 *
7 * Based on code from the latency_tracer, that is:
8 *
9 * Copyright (C) 2004-2006 Ingo Molnar
10 * Copyright (C) 2004 William Lee Irwin III
11 */
1b29b018
SR
12#include <linux/debugfs.h>
13#include <linux/uaccess.h>
14#include <linux/ftrace.h>
2e0f5761 15#include <linux/fs.h>
1b29b018
SR
16
17#include "trace.h"
18
e309b41d 19static void function_reset(struct trace_array *tr)
1b29b018
SR
20{
21 int cpu;
22
750ed1a4 23 tr->time_start = ftrace_now(tr->cpu);
1b29b018
SR
24
25 for_each_online_cpu(cpu)
26 tracing_reset(tr->data[cpu]);
27}
28
e309b41d 29static void start_function_trace(struct trace_array *tr)
1b29b018
SR
30{
31 function_reset(tr);
25b0b44a 32 atomic_inc(&trace_record_cmdline_enabled);
1b29b018
SR
33 tracing_start_function_trace();
34}
35
e309b41d 36static void stop_function_trace(struct trace_array *tr)
1b29b018
SR
37{
38 tracing_stop_function_trace();
25b0b44a 39 atomic_dec(&trace_record_cmdline_enabled);
1b29b018
SR
40}
41
e309b41d 42static void function_trace_init(struct trace_array *tr)
1b29b018
SR
43{
44 if (tr->ctrl)
45 start_function_trace(tr);
46}
47
e309b41d 48static void function_trace_reset(struct trace_array *tr)
1b29b018
SR
49{
50 if (tr->ctrl)
51 stop_function_trace(tr);
52}
53
e309b41d 54static void function_trace_ctrl_update(struct trace_array *tr)
1b29b018
SR
55{
56 if (tr->ctrl)
57 start_function_trace(tr);
58 else
59 stop_function_trace(tr);
60}
61
62static struct tracer function_trace __read_mostly =
63{
64 .name = "ftrace",
65 .init = function_trace_init,
66 .reset = function_trace_reset,
67 .ctrl_update = function_trace_ctrl_update,
60a11774
SR
68#ifdef CONFIG_FTRACE_SELFTEST
69 .selftest = trace_selftest_startup_function,
70#endif
1b29b018
SR
71};
72
73static __init int init_function_trace(void)
74{
75 return register_tracer(&function_trace);
76}
77
78device_initcall(init_function_trace);