diff options
author | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2021-10-15 21:01:19 +0200 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2021-10-20 02:33:20 +0200 |
commit | 91ebe8bcbff9d2ff21303e73bf7434f39a98b255 (patch) | |
tree | bd54758edff84850b30b9d131fdb1a72bbf470f3 /kernel/events | |
parent | tracing: Reuse logic from perf's get_recursion_context() (diff) | |
download | linux-91ebe8bcbff9d2ff21303e73bf7434f39a98b255.tar.xz linux-91ebe8bcbff9d2ff21303e73bf7434f39a98b255.zip |
tracing/perf: Add interrupt_context_level() helper
Now that there are three different instances of doing the addition trick
to the preempt_count() and NMI_MASK, HARDIRQ_MASK and SOFTIRQ_OFFSET
macros, it deserves a helper function defined in the preempt.h header.
Add the interrupt_context_level() helper and replace the three instances
that do that logic with it.
Link: https://lore.kernel.org/all/20211015142541.4badd8a9@gandalf.local.home/
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Diffstat (limited to 'kernel/events')
-rw-r--r-- | kernel/events/internal.h | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/kernel/events/internal.h b/kernel/events/internal.h index 228801e20788..082832738c8f 100644 --- a/kernel/events/internal.h +++ b/kernel/events/internal.h @@ -205,12 +205,7 @@ DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user) static inline int get_recursion_context(int *recursion) { - unsigned int pc = preempt_count(); - unsigned char rctx = 0; - - rctx += !!(pc & (NMI_MASK)); - rctx += !!(pc & (NMI_MASK | HARDIRQ_MASK)); - rctx += !!(pc & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET)); + unsigned char rctx = interrupt_context_level(); if (recursion[rctx]) return -1; |