[PATCH] tracing: Have all levels of checks prevent recursion
Peter Zijlstra
peterz at infradead.org
Fri Oct 15 11:24:59 PDT 2021
On Fri, Oct 15, 2021 at 02:20:33PM -0400, Steven Rostedt wrote:
> On Fri, 15 Oct 2021 20:04:29 +0200
> Peter Zijlstra <peterz at infradead.org> wrote:
>
> > On Fri, Oct 15, 2021 at 01:58:06PM -0400, Steven Rostedt wrote:
> > > 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 :-)
> 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;
More information about the linux-riscv
mailing list