aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-08-09 12:50:46 -0400
committerSteven Rostedt <rostedt@goodmis.org>2012-07-19 13:18:49 -0400
commita1e2e31d175a1349274eba3465d17616c6725f8c (patch)
tree5f92ba7a822f8a9911aa50157f796213bfac4ebb
parentccf3672d530170c98c734dfc5db07d64bcbad2ad (diff)
ftrace: Return pt_regs to function trace callback
Return as the 4th paramater to the function tracer callback the pt_regs. Later patches that implement regs passing for the architectures will require having the ftrace_ops set the SAVE_REGS flag, which will tell the arch to take the time to pass a full set of pt_regs to the ftrace_ops callback function. If the arch does not support it then it should pass NULL. If an arch can pass full regs, then it should define: ARCH_SUPPORTS_FTRACE_SAVE_REGS to 1 Link: http://lkml.kernel.org/r/20120702201821.019966811@goodmis.org Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--include/linux/ftrace.h6
-rw-r--r--kernel/trace/ftrace.c37
-rw-r--r--kernel/trace/trace_event_perf.c2
-rw-r--r--kernel/trace/trace_events.c2
-rw-r--r--kernel/trace/trace_functions.c7
-rw-r--r--kernel/trace/trace_irqsoff.c2
-rw-r--r--kernel/trace/trace_sched_wakeup.c3
-rw-r--r--kernel/trace/trace_selftest.c15
-rw-r--r--kernel/trace/trace_stack.c3
9 files changed, 47 insertions, 30 deletions
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 3651fdc3bec9..e4202881fb00 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -10,6 +10,7 @@
10#include <linux/kallsyms.h> 10#include <linux/kallsyms.h>
11#include <linux/linkage.h> 11#include <linux/linkage.h>
12#include <linux/bitops.h> 12#include <linux/bitops.h>
13#include <linux/ptrace.h>
13#include <linux/ktime.h> 14#include <linux/ktime.h>
14#include <linux/sched.h> 15#include <linux/sched.h>
15#include <linux/types.h> 16#include <linux/types.h>
@@ -54,7 +55,7 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
54struct ftrace_ops; 55struct ftrace_ops;
55 56
56typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip, 57typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip,
57 struct ftrace_ops *op); 58 struct ftrace_ops *op, struct pt_regs *regs);
58 59
59/* 60/*
60 * FTRACE_OPS_FL_* bits denote the state of ftrace_ops struct and are 61 * FTRACE_OPS_FL_* bits denote the state of ftrace_ops struct and are
@@ -188,7 +189,8 @@ static inline int ftrace_function_local_disabled(struct ftrace_ops *ops)
188 return *this_cpu_ptr(ops->disabled); 189 return *this_cpu_ptr(ops->disabled);
189} 190}
190 191
191extern void ftrace_stub(unsigned long a0, unsigned long a1, struct ftrace_ops *op); 192extern void ftrace_stub(unsigned long a0, unsigned long a1,
193 struct ftrace_ops *op, struct pt_regs *regs);
192 194
193#else /* !CONFIG_FUNCTION_TRACER */ 195#else /* !CONFIG_FUNCTION_TRACER */
194/* 196/*
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 4cbca2e6eb70..6ff07ad0ede3 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -103,7 +103,7 @@ static struct ftrace_ops control_ops;
103 103
104#if ARCH_SUPPORTS_FTRACE_OPS 104#if ARCH_SUPPORTS_FTRACE_OPS
105static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip, 105static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
106 struct ftrace_ops *op); 106 struct ftrace_ops *op, struct pt_regs *regs);
107#else 107#else
108/* See comment below, where ftrace_ops_list_func is defined */ 108/* See comment below, where ftrace_ops_list_func is defined */
109static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip); 109static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip);
@@ -121,7 +121,7 @@ static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip);
121 */ 121 */
122static void 122static void
123ftrace_global_list_func(unsigned long ip, unsigned long parent_ip, 123ftrace_global_list_func(unsigned long ip, unsigned long parent_ip,
124 struct ftrace_ops *op) 124 struct ftrace_ops *op, struct pt_regs *regs)
125{ 125{
126 if (unlikely(trace_recursion_test(TRACE_GLOBAL_BIT))) 126 if (unlikely(trace_recursion_test(TRACE_GLOBAL_BIT)))
127 return; 127 return;
@@ -129,19 +129,19 @@ ftrace_global_list_func(unsigned long ip, unsigned long parent_ip,
129 trace_recursion_set(TRACE_GLOBAL_BIT); 129 trace_recursion_set(TRACE_GLOBAL_BIT);
130 op = rcu_dereference_raw(ftrace_global_list); /*see above*/ 130 op = rcu_dereference_raw(ftrace_global_list); /*see above*/
131 while (op != &ftrace_list_end) { 131 while (op != &ftrace_list_end) {
132 op->func(ip, parent_ip, op); 132 op->func(ip, parent_ip, op, regs);
133 op = rcu_dereference_raw(op->next); /*see above*/ 133 op = rcu_dereference_raw(op->next); /*see above*/
134 }; 134 };
135 trace_recursion_clear(TRACE_GLOBAL_BIT); 135 trace_recursion_clear(TRACE_GLOBAL_BIT);
136} 136}
137 137
138static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip, 138static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip,
139 struct ftrace_ops *op) 139 struct ftrace_ops *op, struct pt_regs *regs)
140{ 140{
141 if (!test_tsk_trace_trace(current)) 141 if (!test_tsk_trace_trace(current))
142 return; 142 return;
143 143
144 ftrace_pid_function(ip, parent_ip, op); 144 ftrace_pid_function(ip, parent_ip, op, regs);
145} 145}
146 146
147static void set_ftrace_pid_function(ftrace_func_t func) 147static void set_ftrace_pid_function(ftrace_func_t func)
@@ -763,7 +763,7 @@ ftrace_profile_alloc(struct ftrace_profile_stat *stat, unsigned long ip)
763 763
764static void 764static void
765function_profile_call(unsigned long ip, unsigned long parent_ip, 765function_profile_call(unsigned long ip, unsigned long parent_ip,
766 struct ftrace_ops *ops) 766 struct ftrace_ops *ops, struct pt_regs *regs)
767{ 767{
768 struct ftrace_profile_stat *stat; 768 struct ftrace_profile_stat *stat;
769 struct ftrace_profile *rec; 769 struct ftrace_profile *rec;
@@ -793,7 +793,7 @@ function_profile_call(unsigned long ip, unsigned long parent_ip,
793#ifdef CONFIG_FUNCTION_GRAPH_TRACER 793#ifdef CONFIG_FUNCTION_GRAPH_TRACER
794static int profile_graph_entry(struct ftrace_graph_ent *trace) 794static int profile_graph_entry(struct ftrace_graph_ent *trace)
795{ 795{
796 function_profile_call(trace->func, 0, NULL); 796 function_profile_call(trace->func, 0, NULL, NULL);
797 return 1; 797 return 1;
798} 798}
799 799
@@ -2771,7 +2771,7 @@ static int __init ftrace_mod_cmd_init(void)
2771device_initcall(ftrace_mod_cmd_init); 2771device_initcall(ftrace_mod_cmd_init);
2772 2772
2773static void function_trace_probe_call(unsigned long ip, unsigned long parent_ip, 2773static void function_trace_probe_call(unsigned long ip, unsigned long parent_ip,
2774 struct ftrace_ops *op) 2774 struct ftrace_ops *op, struct pt_regs *pt_regs)
2775{ 2775{
2776 struct ftrace_func_probe *entry; 2776 struct ftrace_func_probe *entry;
2777 struct hlist_head *hhd; 2777 struct hlist_head *hhd;
@@ -3923,7 +3923,7 @@ ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip)
3923 3923
3924static void 3924static void
3925ftrace_ops_control_func(unsigned long ip, unsigned long parent_ip, 3925ftrace_ops_control_func(unsigned long ip, unsigned long parent_ip,
3926 struct ftrace_ops *op) 3926 struct ftrace_ops *op, struct pt_regs *regs)
3927{ 3927{
3928 if (unlikely(trace_recursion_test(TRACE_CONTROL_BIT))) 3928 if (unlikely(trace_recursion_test(TRACE_CONTROL_BIT)))
3929 return; 3929 return;
@@ -3938,7 +3938,7 @@ ftrace_ops_control_func(unsigned long ip, unsigned long parent_ip,
3938 while (op != &ftrace_list_end) { 3938 while (op != &ftrace_list_end) {
3939 if (!ftrace_function_local_disabled(op) && 3939 if (!ftrace_function_local_disabled(op) &&
3940 ftrace_ops_test(op, ip)) 3940 ftrace_ops_test(op, ip))
3941 op->func(ip, parent_ip, op); 3941 op->func(ip, parent_ip, op, regs);
3942 3942
3943 op = rcu_dereference_raw(op->next); 3943 op = rcu_dereference_raw(op->next);
3944 }; 3944 };
@@ -3952,7 +3952,7 @@ static struct ftrace_ops control_ops = {
3952 3952
3953static inline void 3953static inline void
3954__ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip, 3954__ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
3955 struct ftrace_ops *ignored) 3955 struct ftrace_ops *ignored, struct pt_regs *regs)
3956{ 3956{
3957 struct ftrace_ops *op; 3957 struct ftrace_ops *op;
3958 3958
@@ -3971,7 +3971,7 @@ __ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
3971 op = rcu_dereference_raw(ftrace_ops_list); 3971 op = rcu_dereference_raw(ftrace_ops_list);
3972 while (op != &ftrace_list_end) { 3972 while (op != &ftrace_list_end) {
3973 if (ftrace_ops_test(op, ip)) 3973 if (ftrace_ops_test(op, ip))
3974 op->func(ip, parent_ip, op); 3974 op->func(ip, parent_ip, op, regs);
3975 op = rcu_dereference_raw(op->next); 3975 op = rcu_dereference_raw(op->next);
3976 }; 3976 };
3977 preempt_enable_notrace(); 3977 preempt_enable_notrace();
@@ -3983,17 +3983,24 @@ __ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
3983 * the list function ignores the op parameter, we do not want any 3983 * the list function ignores the op parameter, we do not want any
3984 * C side effects, where a function is called without the caller 3984 * C side effects, where a function is called without the caller
3985 * sending a third parameter. 3985 * sending a third parameter.
3986 * Archs are to support both the regs and ftrace_ops at the same time.
3987 * If they support ftrace_ops, it is assumed they support regs.
3988 * If call backs want to use regs, they must either check for regs
3989 * being NULL, or ARCH_SUPPORTS_FTRACE_SAVE_REGS.
3990 * Note, ARCH_SUPPORT_SAVE_REGS expects a full regs to be saved.
3991 * An architecture can pass partial regs with ftrace_ops and still
3992 * set the ARCH_SUPPORT_FTARCE_OPS.
3986 */ 3993 */
3987#if ARCH_SUPPORTS_FTRACE_OPS 3994#if ARCH_SUPPORTS_FTRACE_OPS
3988static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip, 3995static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
3989 struct ftrace_ops *op) 3996 struct ftrace_ops *op, struct pt_regs *regs)
3990{ 3997{
3991 __ftrace_ops_list_func(ip, parent_ip, NULL); 3998 __ftrace_ops_list_func(ip, parent_ip, NULL, regs);
3992} 3999}
3993#else 4000#else
3994static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip) 4001static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip)
3995{ 4002{
3996 __ftrace_ops_list_func(ip, parent_ip, NULL); 4003 __ftrace_ops_list_func(ip, parent_ip, NULL, NULL);
3997} 4004}
3998#endif 4005#endif
3999 4006
diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index a872a9a298a0..9824419c8404 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(perf_trace_buf_prepare);
259#ifdef CONFIG_FUNCTION_TRACER 259#ifdef CONFIG_FUNCTION_TRACER
260static void 260static void
261perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip, 261perf_ftrace_function_call(unsigned long ip, unsigned long parent_ip,
262 struct ftrace_ops *ops) 262 struct ftrace_ops *ops, struct pt_regs *pt_regs)
263{ 263{
264 struct ftrace_entry *entry; 264 struct ftrace_entry *entry;
265 struct hlist_head *head; 265 struct hlist_head *head;
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 88daa5177bf4..8c6696833686 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1682,7 +1682,7 @@ static DEFINE_PER_CPU(atomic_t, ftrace_test_event_disable);
1682 1682
1683static void 1683static void
1684function_test_events_call(unsigned long ip, unsigned long parent_ip, 1684function_test_events_call(unsigned long ip, unsigned long parent_ip,
1685 struct ftrace_ops *op) 1685 struct ftrace_ops *op, struct pt_regs *pt_regs)
1686{ 1686{
1687 struct ring_buffer_event *event; 1687 struct ring_buffer_event *event;
1688 struct ring_buffer *buffer; 1688 struct ring_buffer *buffer;
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c
index fceb7a9aa06d..5675ebd541f0 100644
--- a/kernel/trace/trace_functions.c
+++ b/kernel/trace/trace_functions.c
@@ -49,7 +49,7 @@ static void function_trace_start(struct trace_array *tr)
49 49
50static void 50static void
51function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip, 51function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip,
52 struct ftrace_ops *op) 52 struct ftrace_ops *op, struct pt_regs *pt_regs)
53{ 53{
54 struct trace_array *tr = func_trace; 54 struct trace_array *tr = func_trace;
55 struct trace_array_cpu *data; 55 struct trace_array_cpu *data;
@@ -77,7 +77,8 @@ function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip,
77 77
78static void 78static void
79function_trace_call(unsigned long ip, unsigned long parent_ip, 79function_trace_call(unsigned long ip, unsigned long parent_ip,
80 struct ftrace_ops *op) 80 struct ftrace_ops *op, struct pt_regs *pt_regs)
81
81{ 82{
82 struct trace_array *tr = func_trace; 83 struct trace_array *tr = func_trace;
83 struct trace_array_cpu *data; 84 struct trace_array_cpu *data;
@@ -109,7 +110,7 @@ function_trace_call(unsigned long ip, unsigned long parent_ip,
109 110
110static void 111static void
111function_stack_trace_call(unsigned long ip, unsigned long parent_ip, 112function_stack_trace_call(unsigned long ip, unsigned long parent_ip,
112 struct ftrace_ops *op) 113 struct ftrace_ops *op, struct pt_regs *pt_regs)
113{ 114{
114 struct trace_array *tr = func_trace; 115 struct trace_array *tr = func_trace;
115 struct trace_array_cpu *data; 116 struct trace_array_cpu *data;
diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index 2862c77f95d9..c7a9ba936de6 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -137,7 +137,7 @@ static int func_prolog_dec(struct trace_array *tr,
137 */ 137 */
138static void 138static void
139irqsoff_tracer_call(unsigned long ip, unsigned long parent_ip, 139irqsoff_tracer_call(unsigned long ip, unsigned long parent_ip,
140 struct ftrace_ops *op) 140 struct ftrace_ops *op, struct pt_regs *pt_regs)
141{ 141{
142 struct trace_array *tr = irqsoff_trace; 142 struct trace_array *tr = irqsoff_trace;
143 struct trace_array_cpu *data; 143 struct trace_array_cpu *data;
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c
index 0caf4f5da569..7547e36d483e 100644
--- a/kernel/trace/trace_sched_wakeup.c
+++ b/kernel/trace/trace_sched_wakeup.c
@@ -108,7 +108,8 @@ out_enable:
108 * wakeup uses its own tracer function to keep the overhead down: 108 * wakeup uses its own tracer function to keep the overhead down:
109 */ 109 */
110static void 110static void
111wakeup_tracer_call(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op) 111wakeup_tracer_call(unsigned long ip, unsigned long parent_ip,
112 struct ftrace_ops *op, struct pt_regs *pt_regs)
112{ 113{
113 struct trace_array *tr = wakeup_trace; 114 struct trace_array *tr = wakeup_trace;
114 struct trace_array_cpu *data; 115 struct trace_array_cpu *data;
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
index 9ae40c823af8..add37e019fd0 100644
--- a/kernel/trace/trace_selftest.c
+++ b/kernel/trace/trace_selftest.c
@@ -104,7 +104,8 @@ static inline void warn_failed_init_tracer(struct tracer *trace, int init_ret)
104static int trace_selftest_test_probe1_cnt; 104static int trace_selftest_test_probe1_cnt;
105static void trace_selftest_test_probe1_func(unsigned long ip, 105static void trace_selftest_test_probe1_func(unsigned long ip,
106 unsigned long pip, 106 unsigned long pip,
107 struct ftrace_ops *op) 107 struct ftrace_ops *op,
108 struct pt_regs *pt_regs)
108{ 109{
109 trace_selftest_test_probe1_cnt++; 110 trace_selftest_test_probe1_cnt++;
110} 111}
@@ -112,7 +113,8 @@ static void trace_selftest_test_probe1_func(unsigned long ip,
112static int trace_selftest_test_probe2_cnt; 113static int trace_selftest_test_probe2_cnt;
113static void trace_selftest_test_probe2_func(unsigned long ip, 114static void trace_selftest_test_probe2_func(unsigned long ip,
114 unsigned long pip, 115 unsigned long pip,
115 struct ftrace_ops *op) 116 struct ftrace_ops *op,
117 struct pt_regs *pt_regs)
116{ 118{
117 trace_selftest_test_probe2_cnt++; 119 trace_selftest_test_probe2_cnt++;
118} 120}
@@ -120,7 +122,8 @@ static void trace_selftest_test_probe2_func(unsigned long ip,
120static int trace_selftest_test_probe3_cnt; 122static int trace_selftest_test_probe3_cnt;
121static void trace_selftest_test_probe3_func(unsigned long ip, 123static void trace_selftest_test_probe3_func(unsigned long ip,
122 unsigned long pip, 124 unsigned long pip,
123 struct ftrace_ops *op) 125 struct ftrace_ops *op,
126 struct pt_regs *pt_regs)
124{ 127{
125 trace_selftest_test_probe3_cnt++; 128 trace_selftest_test_probe3_cnt++;
126} 129}
@@ -128,7 +131,8 @@ static void trace_selftest_test_probe3_func(unsigned long ip,
128static int trace_selftest_test_global_cnt; 131static int trace_selftest_test_global_cnt;
129static void trace_selftest_test_global_func(unsigned long ip, 132static void trace_selftest_test_global_func(unsigned long ip,
130 unsigned long pip, 133 unsigned long pip,
131 struct ftrace_ops *op) 134 struct ftrace_ops *op,
135 struct pt_regs *pt_regs)
132{ 136{
133 trace_selftest_test_global_cnt++; 137 trace_selftest_test_global_cnt++;
134} 138}
@@ -136,7 +140,8 @@ static void trace_selftest_test_global_func(unsigned long ip,
136static int trace_selftest_test_dyn_cnt; 140static int trace_selftest_test_dyn_cnt;
137static void trace_selftest_test_dyn_func(unsigned long ip, 141static void trace_selftest_test_dyn_func(unsigned long ip,
138 unsigned long pip, 142 unsigned long pip,
139 struct ftrace_ops *op) 143 struct ftrace_ops *op,
144 struct pt_regs *pt_regs)
140{ 145{
141 trace_selftest_test_dyn_cnt++; 146 trace_selftest_test_dyn_cnt++;
142} 147}
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index e20006d5fb6a..2fa5328e8893 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -111,7 +111,8 @@ static inline void check_stack(void)
111} 111}
112 112
113static void 113static void
114stack_trace_call(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op) 114stack_trace_call(unsigned long ip, unsigned long parent_ip,
115 struct ftrace_ops *op, struct pt_regs *pt_regs)
115{ 116{
116 int cpu; 117 int cpu;
117 118