diff options
Diffstat (limited to 'kernel/trace/ftrace.c')
| -rw-r--r-- | kernel/trace/ftrace.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 83783579378f..2404b59b3097 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
| @@ -24,9 +24,11 @@ | |||
| 24 | #include <linux/uaccess.h> | 24 | #include <linux/uaccess.h> |
| 25 | #include <linux/ftrace.h> | 25 | #include <linux/ftrace.h> |
| 26 | #include <linux/sysctl.h> | 26 | #include <linux/sysctl.h> |
| 27 | #include <linux/slab.h> | ||
| 27 | #include <linux/ctype.h> | 28 | #include <linux/ctype.h> |
| 28 | #include <linux/list.h> | 29 | #include <linux/list.h> |
| 29 | #include <linux/hash.h> | 30 | #include <linux/hash.h> |
| 31 | #include <linux/rcupdate.h> | ||
| 30 | 32 | ||
| 31 | #include <trace/events/sched.h> | 33 | #include <trace/events/sched.h> |
| 32 | 34 | ||
| @@ -84,22 +86,22 @@ ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub; | |||
| 84 | ftrace_func_t __ftrace_trace_function __read_mostly = ftrace_stub; | 86 | ftrace_func_t __ftrace_trace_function __read_mostly = ftrace_stub; |
| 85 | ftrace_func_t ftrace_pid_function __read_mostly = ftrace_stub; | 87 | ftrace_func_t ftrace_pid_function __read_mostly = ftrace_stub; |
| 86 | 88 | ||
| 87 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 89 | /* |
| 88 | static int ftrace_set_func(unsigned long *array, int *idx, char *buffer); | 90 | * Traverse the ftrace_list, invoking all entries. The reason that we |
| 89 | #endif | 91 | * can use rcu_dereference_raw() is that elements removed from this list |
| 90 | 92 | * are simply leaked, so there is no need to interact with a grace-period | |
| 93 | * mechanism. The rcu_dereference_raw() calls are needed to handle | ||
| 94 | * concurrent insertions into the ftrace_list. | ||
| 95 | * | ||
| 96 | * Silly Alpha and silly pointer-speculation compiler optimizations! | ||
| 97 | */ | ||
| 91 | static void ftrace_list_func(unsigned long ip, unsigned long parent_ip) | 98 | static void ftrace_list_func(unsigned long ip, unsigned long parent_ip) |
| 92 | { | 99 | { |
| 93 | struct ftrace_ops *op = ftrace_list; | 100 | struct ftrace_ops *op = rcu_dereference_raw(ftrace_list); /*see above*/ |
| 94 | |||
| 95 | /* in case someone actually ports this to alpha! */ | ||
| 96 | read_barrier_depends(); | ||
| 97 | 101 | ||
| 98 | while (op != &ftrace_list_end) { | 102 | while (op != &ftrace_list_end) { |
| 99 | /* silly alpha */ | ||
| 100 | read_barrier_depends(); | ||
| 101 | op->func(ip, parent_ip); | 103 | op->func(ip, parent_ip); |
| 102 | op = op->next; | 104 | op = rcu_dereference_raw(op->next); /*see above*/ |
| 103 | }; | 105 | }; |
| 104 | } | 106 | } |
| 105 | 107 | ||
| @@ -154,8 +156,7 @@ static int __register_ftrace_function(struct ftrace_ops *ops) | |||
| 154 | * the ops->next pointer is valid before another CPU sees | 156 | * the ops->next pointer is valid before another CPU sees |
| 155 | * the ops pointer included into the ftrace_list. | 157 | * the ops pointer included into the ftrace_list. |
| 156 | */ | 158 | */ |
| 157 | smp_wmb(); | 159 | rcu_assign_pointer(ftrace_list, ops); |
| 158 | ftrace_list = ops; | ||
| 159 | 160 | ||
| 160 | if (ftrace_enabled) { | 161 | if (ftrace_enabled) { |
| 161 | ftrace_func_t func; | 162 | ftrace_func_t func; |
| @@ -2276,6 +2277,8 @@ __setup("ftrace_filter=", set_ftrace_filter); | |||
| 2276 | 2277 | ||
| 2277 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 2278 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
| 2278 | static char ftrace_graph_buf[FTRACE_FILTER_SIZE] __initdata; | 2279 | static char ftrace_graph_buf[FTRACE_FILTER_SIZE] __initdata; |
| 2280 | static int ftrace_set_func(unsigned long *array, int *idx, char *buffer); | ||
| 2281 | |||
| 2279 | static int __init set_graph_function(char *str) | 2282 | static int __init set_graph_function(char *str) |
| 2280 | { | 2283 | { |
| 2281 | strlcpy(ftrace_graph_buf, str, FTRACE_FILTER_SIZE); | 2284 | strlcpy(ftrace_graph_buf, str, FTRACE_FILTER_SIZE); |
| @@ -3351,6 +3354,7 @@ void ftrace_graph_init_task(struct task_struct *t) | |||
| 3351 | { | 3354 | { |
| 3352 | /* Make sure we do not use the parent ret_stack */ | 3355 | /* Make sure we do not use the parent ret_stack */ |
| 3353 | t->ret_stack = NULL; | 3356 | t->ret_stack = NULL; |
| 3357 | t->curr_ret_stack = -1; | ||
| 3354 | 3358 | ||
| 3355 | if (ftrace_graph_active) { | 3359 | if (ftrace_graph_active) { |
| 3356 | struct ftrace_ret_stack *ret_stack; | 3360 | struct ftrace_ret_stack *ret_stack; |
| @@ -3360,7 +3364,6 @@ void ftrace_graph_init_task(struct task_struct *t) | |||
| 3360 | GFP_KERNEL); | 3364 | GFP_KERNEL); |
| 3361 | if (!ret_stack) | 3365 | if (!ret_stack) |
| 3362 | return; | 3366 | return; |
| 3363 | t->curr_ret_stack = -1; | ||
| 3364 | atomic_set(&t->tracing_graph_pause, 0); | 3367 | atomic_set(&t->tracing_graph_pause, 0); |
| 3365 | atomic_set(&t->trace_overrun, 0); | 3368 | atomic_set(&t->trace_overrun, 0); |
| 3366 | t->ftrace_timestamp = 0; | 3369 | t->ftrace_timestamp = 0; |
