diff options
author | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2020-11-06 03:32:37 +0100 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2020-11-06 14:33:23 +0100 |
commit | 6e4eb9cb22fc8a893cb708ed42644de5ee7c3827 (patch) | |
tree | 5aa13b98aa6b7659a8c711eac36cc1180656f424 /kernel | |
parent | ftrace: Move the recursion testing into global headers (diff) | |
download | linux-6e4eb9cb22fc8a893cb708ed42644de5ee7c3827.tar.xz linux-6e4eb9cb22fc8a893cb708ed42644de5ee7c3827.zip |
ftrace: Add ftrace_test_recursion_trylock() helper function
To make it easier for ftrace callbacks to have recursion protection, provide
a ftrace_test_recursion_trylock() and ftrace_test_recursion_unlock() helper
that tests for recursion.
Link: https://lkml.kernel.org/r/20201028115612.634927593@goodmis.org
Link: https://lkml.kernel.org/r/20201106023546.378584067@goodmis.org
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace_functions.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c index 2c2126e1871d..943756c01190 100644 --- a/kernel/trace/trace_functions.c +++ b/kernel/trace/trace_functions.c @@ -141,22 +141,20 @@ function_trace_call(unsigned long ip, unsigned long parent_ip, if (unlikely(!tr->function_enabled)) return; + bit = ftrace_test_recursion_trylock(); + if (bit < 0) + return; + pc = preempt_count(); preempt_disable_notrace(); - bit = trace_test_and_set_recursion(TRACE_FTRACE_START, TRACE_FTRACE_MAX); - if (bit < 0) - goto out; - cpu = smp_processor_id(); data = per_cpu_ptr(tr->array_buffer.data, cpu); if (!atomic_read(&data->disabled)) { local_save_flags(flags); trace_function(tr, ip, parent_ip, flags, pc); } - trace_clear_recursion(bit); - - out: + ftrace_test_recursion_unlock(bit); preempt_enable_notrace(); } |