Thread (20 messages) 20 messages, 5 authors, 2023-07-22

Re: [PATCH] tracing: Have all levels of checks prevent recursion

From: Peter Zijlstra <peterz@infradead.org>
Date: 2021-10-15 18:29:52
Also in: linux-riscv, live-patching, lkml

On Fri, Oct 15, 2021 at 02:20:33PM -0400, Steven Rostedt wrote:
On Fri, 15 Oct 2021 20:04:29 +0200
Peter Zijlstra [off-list ref] wrote:
quoted
On Fri, Oct 15, 2021 at 01:58:06PM -0400, Steven Rostedt wrote:
quoted
Something like this:  
I think having one copy of that in a header is better than having 3
copies. But yes, something along them lines.
I was just about to ask you about this patch ;-)
Much better :-)
quoted hunk ↗ jump to hunk
diff --git a/kernel/events/internal.h b/kernel/events/internal.h
index 228801e20788..c91711f20cf8 100644
--- a/kernel/events/internal.h
+++ b/kernel/events/internal.h
@@ -206,11 +206,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();
Although I think we can do without that ^ line as well :-)
-	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;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help