diff options
author | Steven Rostedt <srostedt@redhat.com> | 2008-11-10 23:07:30 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-11-11 03:40:29 -0500 |
commit | 5aa1ba6a6c710e747838a22d798ac97a8b248745 (patch) | |
tree | 29a0e0bfdad1a5674667dda1236099952dbf41cb /kernel/trace/trace.c | |
parent | e0cb4ebcd9e5b4ddd8216c20f54445c91b1fa4b9 (diff) |
ftrace: prevent ftrace_special from recursion
Impact: stop ftrace_special from recursion
The ftrace_special is used to help debug areas of the kernel.
Because of this, if it is put in certain locations, the fact that
it allows recursion can become a problem if the kernel developer
using does not realize that.
This patch changes ftrace_special to not allow recursion into itself
to make it more robust.
It also changes from preempt disable interrupts disable to prevent
any loss of trace entries.
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 0c22fe2d43a7..216bbe7547a4 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -960,6 +960,7 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) | |||
960 | { | 960 | { |
961 | struct trace_array *tr = &global_trace; | 961 | struct trace_array *tr = &global_trace; |
962 | struct trace_array_cpu *data; | 962 | struct trace_array_cpu *data; |
963 | unsigned long flags; | ||
963 | int cpu; | 964 | int cpu; |
964 | int pc; | 965 | int pc; |
965 | 966 | ||
@@ -967,14 +968,15 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) | |||
967 | return; | 968 | return; |
968 | 969 | ||
969 | pc = preempt_count(); | 970 | pc = preempt_count(); |
970 | preempt_disable_notrace(); | 971 | local_irq_save(flags); |
971 | cpu = raw_smp_processor_id(); | 972 | cpu = raw_smp_processor_id(); |
972 | data = tr->data[cpu]; | 973 | data = tr->data[cpu]; |
973 | 974 | ||
974 | if (likely(!atomic_read(&data->disabled))) | 975 | if (likely(atomic_inc_return(&data->disabled) == 1)) |
975 | ftrace_trace_special(tr, data, arg1, arg2, arg3, pc); | 976 | ftrace_trace_special(tr, data, arg1, arg2, arg3, pc); |
976 | 977 | ||
977 | preempt_enable_notrace(); | 978 | atomic_dec(&data->disabled); |
979 | local_irq_restore(flags); | ||
978 | } | 980 | } |
979 | 981 | ||
980 | #ifdef CONFIG_FUNCTION_TRACER | 982 | #ifdef CONFIG_FUNCTION_TRACER |