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

2023-07-21 Thread Jakub Kicinski
On Fri, 21 Jul 2023 12:26:32 -0400 Steven Rostedt wrote: > > if (!(in_hardirq() || irqs_disabled())) > > > > Yeah, probably. > > > , nothing more elegant / already existing / ...? > > It's not a common check. What would you call that? Looks like Olek started the weekend already so let me a

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

2023-07-21 Thread Alexander Lobakin
From: Steven Rostedt Date: Fri, 21 Jul 2023 12:00:40 -0400 > On Fri, 21 Jul 2023 17:34:41 +0200 > Alexander Lobakin wrote: [...] >>> + level += !!(pc & (NMI_MASK)); >>> + level += !!(pc & (NMI_MASK | HARDIRQ_MASK)); >>> + level += !!(pc & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET)); >>

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

2023-07-21 Thread Alexander Lobakin
From: Steven Rostedt Date: Fri, 15 Oct 2021 14:25:41 -0400 Sorry for such a necroposting :z Just wanted to know if this is a bug, so that I could send a fix, or intended behaviour. > On Fri, 15 Oct 2021 14:20:33 -0400 > Steven Rostedt wrote: > >>> I think having one copy of that in a header is

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

2023-07-21 Thread Steven Rostedt
On Fri, 21 Jul 2023 18:06:07 +0200 Alexander Lobakin wrote: > > Just because you disable interrupts does not mean you are in interrupt > > context. > > Ah okay, thanks! IOW, if we want to check in some code that we're > certainly have interrupts enabled and are not in the interrupt context, >

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

2023-07-21 Thread Steven Rostedt
On Fri, 21 Jul 2023 17:34:41 +0200 Alexander Lobakin wrote: > From: Steven Rostedt > Date: Fri, 15 Oct 2021 14:25:41 -0400 > > Sorry for such a necroposting :z > Just wanted to know if this is a bug, so that I could send a fix, or > intended behaviour. > > > On Fri, 15 Oct 2021 14:20:33 -0400

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

2021-10-19 Thread Steven Rostedt
On Tue, 19 Oct 2021 08:41:23 +0200 Petr Mladek wrote: > Feel free to postpone this change. I do not want to complicate > upstreaming the fix for stable. I am sorry if I already > complicated it. > No problem. It's not that complicated of a merge fix. I'm sure Linus can handle it ;-) -- Steve

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

2021-10-19 Thread Petr Mladek
On Mon 2021-10-18 22:02:03, Steven Rostedt wrote: > On Mon, 18 Oct 2021 12:19:20 +0200 > Petr Mladek wrote: > > > > - > > > bit = trace_get_context_bit() + start; > > > if (unlikely(val & (1 << bit))) { > > > /* > > >* It could be that preempt_count has not been updated

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

2021-10-18 Thread Steven Rostedt
On Mon, 18 Oct 2021 12:19:20 +0200 Petr Mladek wrote: > > - > > bit = trace_get_context_bit() + start; > > if (unlikely(val & (1 << bit))) { > > /* > > * It could be that preempt_count has not been updated during > > * a switch between contexts. Allow

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

2021-10-18 Thread Petr Mladek
On Mon 2021-10-18 09:50:27, Steven Rostedt wrote: > On Mon, 18 Oct 2021 12:19:20 +0200 > Petr Mladek wrote: > > > On Fri 2021-10-15 11:00:35, Steven Rostedt wrote: > > > From: "Steven Rostedt (VMware)" > > > > > > While writing an email explaining the "bit = 0" logic for a discussion on > > > m

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

2021-10-18 Thread Petr Mladek
On Fri 2021-10-15 11:00:35, Steven Rostedt wrote: > From: "Steven Rostedt (VMware)" > > While writing an email explaining the "bit = 0" logic for a discussion on > making ftrace_test_recursion_trylock() disable preemption, I discovered a > path that makes the "not do the logic if bit is zero" uns

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

2021-10-18 Thread Steven Rostedt
On Mon, 18 Oct 2021 12:19:20 +0200 Petr Mladek wrote: > On Fri 2021-10-15 11:00:35, Steven Rostedt wrote: > > From: "Steven Rostedt (VMware)" > > > > While writing an email explaining the "bit = 0" logic for a discussion on > > making ftrace_test_recursion_trylock() disable preemption, I discov

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

2021-10-15 Thread Steven Rostedt
On Fri, 15 Oct 2021 20:24:59 +0200 Peter Zijlstra wrote: > > @@ -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 w

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

2021-10-15 Thread Peter Zijlstra
On Fri, Oct 15, 2021 at 02:20:33PM -0400, Steven Rostedt wrote: > On Fri, 15 Oct 2021 20:04:29 +0200 > Peter Zijlstra 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 havin

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

2021-10-15 Thread Steven Rostedt
On Fri, 15 Oct 2021 14:20:33 -0400 Steven Rostedt wrote: > > 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 ;-) Except it doesn't build :-p (need to move the inlined function

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

2021-10-15 Thread Steven Rostedt
On Fri, 15 Oct 2021 20:04:29 +0200 Peter Zijlstra 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 yo

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

2021-10-15 Thread Peter Zijlstra
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.

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

2021-10-15 Thread Steven Rostedt
On Fri, 15 Oct 2021 13:35:04 -0400 Steven Rostedt wrote: > On Fri, 15 Oct 2021 18:17:02 +0200 > Peter Zijlstra wrote: > > > On Fri, Oct 15, 2021 at 11:00:35AM -0400, Steven Rostedt wrote: > > > From: "Steven Rostedt (VMware)" > > > > > > While writing an email explaining the "bit = 0" logic

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

2021-10-15 Thread Steven Rostedt
On Fri, 15 Oct 2021 18:17:02 +0200 Peter Zijlstra wrote: > On Fri, Oct 15, 2021 at 11:00:35AM -0400, Steven Rostedt wrote: > > From: "Steven Rostedt (VMware)" > > > > While writing an email explaining the "bit = 0" logic for a discussion on > > > bit = trace_get_context_bit() + start;

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

2021-10-15 Thread Peter Zijlstra
On Fri, Oct 15, 2021 at 11:00:35AM -0400, Steven Rostedt wrote: > From: "Steven Rostedt (VMware)" > > While writing an email explaining the "bit = 0" logic for a discussion on > bit = trace_get_context_bit() + start; While there, you were also going to update that function to match/use ge

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

2021-10-15 Thread Steven Rostedt
From: "Steven Rostedt (VMware)" While writing an email explaining the "bit = 0" logic for a discussion on making ftrace_test_recursion_trylock() disable preemption, I discovered a path that makes the "not do the logic if bit is zero" unsafe. The recursion logic is done in hot paths like the func