tracing/ftrace: change the type of the init() callback
[cascardo/linux.git] / kernel / trace / trace_functions_return.c
1 /*
2  *
3  * Function return tracer.
4  * Copyright (c) 2008 Frederic Weisbecker <fweisbec@gmail.com>
5  * Mostly borrowed from function tracer which
6  * is Copyright (c) Steven Rostedt <srostedt@redhat.com>
7  *
8  */
9 #include <linux/debugfs.h>
10 #include <linux/uaccess.h>
11 #include <linux/ftrace.h>
12 #include <linux/fs.h>
13
14 #include "trace.h"
15
16
17 static void start_return_trace(struct trace_array *tr)
18 {
19         register_ftrace_return(&trace_function_return);
20 }
21
22 static void stop_return_trace(struct trace_array *tr)
23 {
24         unregister_ftrace_return();
25 }
26
27 static int return_trace_init(struct trace_array *tr)
28 {
29         int cpu;
30         for_each_online_cpu(cpu)
31                 tracing_reset(tr, cpu);
32
33         start_return_trace(tr);
34         return 0;
35 }
36
37 static void return_trace_reset(struct trace_array *tr)
38 {
39                 stop_return_trace(tr);
40 }
41
42
43 enum print_line_t
44 print_return_function(struct trace_iterator *iter)
45 {
46         struct trace_seq *s = &iter->seq;
47         struct trace_entry *entry = iter->ent;
48         struct ftrace_ret_entry *field;
49         int ret;
50
51         if (entry->type == TRACE_FN_RET) {
52                 trace_assign_type(field, entry);
53                 ret = trace_seq_printf(s, "%pF -> ", (void *)field->parent_ip);
54                 if (!ret)
55                         return TRACE_TYPE_PARTIAL_LINE;
56                 ret = seq_print_ip_sym(s, field->ip,
57                                         trace_flags & TRACE_ITER_SYM_MASK);
58                 if (!ret)
59                         return TRACE_TYPE_PARTIAL_LINE;
60                 ret = trace_seq_printf(s, " (%llu ns)\n",
61                                         field->rettime - field->calltime);
62                 if (!ret)
63                         return TRACE_TYPE_PARTIAL_LINE;
64                 else
65                         return TRACE_TYPE_HANDLED;
66         }
67         return TRACE_TYPE_UNHANDLED;
68 }
69
70 static struct tracer return_trace __read_mostly =
71 {
72         .name        = "return",
73         .init        = return_trace_init,
74         .reset       = return_trace_reset,
75         .print_line = print_return_function
76 };
77
78 static __init int init_return_trace(void)
79 {
80         return register_tracer(&return_trace);
81 }
82
83 device_initcall(init_return_trace);