Re: [PATCH 1/2] ftrace: disable preemption on the testing of recursion

2021-10-12 Thread 王贇
On 2021/10/13 上午10:30, Steven Rostedt wrote: > On Wed, 13 Oct 2021 10:04:52 +0800 > 王贇 wrote: > >> I see, while the user can still check smp_processor_id() after trylock >> return bit 0... > > But preemption would have already been disabled. That's because a bit 0 > means that a recursion

Re: [PATCH 1/2] ftrace: disable preemption on the testing of recursion

2021-10-12 Thread 王贇
On 2021/10/13 上午10:27, Steven Rostedt wrote: > On Wed, 13 Oct 2021 09:50:17 +0800 > 王贇 wrote: > - preempt_enable_notrace(); ftrace_test_recursion_unlock(bit); } >>> >>> I don't like this change much. We have preempt_disable there not because >>> of

Re: [PATCH 1/2] ftrace: disable preemption on the testing of recursion

2021-10-12 Thread Steven Rostedt
On Wed, 13 Oct 2021 10:04:52 +0800 王贇 wrote: > I see, while the user can still check smp_processor_id() after trylock > return bit 0... But preemption would have already been disabled. That's because a bit 0 means that a recursion check has already been made by a previous caller and this one is

Re: [PATCH 1/2] ftrace: disable preemption on the testing of recursion

2021-10-12 Thread Steven Rostedt
On Wed, 13 Oct 2021 09:50:17 +0800 王贇 wrote: > >> - preempt_enable_notrace(); > >>ftrace_test_recursion_unlock(bit); > >> } > > > > I don't like this change much. We have preempt_disable there not because > > of ftrace_test_recursion, but because of RCU. ftrace_test_recursion was > >

Re: [PATCH 1/2] ftrace: disable preemption on the testing of recursion

2021-10-12 Thread 王贇
On 2021/10/12 下午8:43, Steven Rostedt wrote: > On Tue, 12 Oct 2021 13:40:08 +0800 > 王贇 wrote: > >> --- a/include/linux/trace_recursion.h >> +++ b/include/linux/trace_recursion.h >> @@ -214,7 +214,14 @@ static __always_inline void trace_clear_recursion(int >> bit) >> static __always_inline

Re: [PATCH 1/2] ftrace: disable preemption on the testing of recursion

2021-10-12 Thread 王贇
On 2021/10/12 下午8:29, Steven Rostedt wrote: > On Tue, 12 Oct 2021 14:24:43 +0200 (CEST) > Miroslav Benes wrote: > >>> +++ b/kernel/livepatch/patch.c >>> @@ -52,11 +52,6 @@ static void notrace klp_ftrace_handler(unsigned long ip, >>> bit = ftrace_test_recursion_trylock(ip, parent_ip); >>>

Re: [PATCH 1/2] ftrace: disable preemption on the testing of recursion

2021-10-12 Thread 王贇
On 2021/10/12 下午8:24, Miroslav Benes wrote: [snip] >> >> func = list_first_or_null_rcu(>func_stack, struct klp_func, >>stack_node); >> @@ -120,7 +115,6 @@ static void notrace klp_ftrace_handler(unsigned long ip, >> klp_arch_set_pc(fregs, (unsigned

Re: [PATCH 1/2] ftrace: disable preemption on the testing of recursion

2021-10-12 Thread 王贇
On 2021/10/12 下午8:17, Steven Rostedt wrote: > On Tue, 12 Oct 2021 13:40:08 +0800 > 王贇 wrote: > >> @@ -52,11 +52,6 @@ static void notrace klp_ftrace_handler(unsigned long ip, >> bit = ftrace_test_recursion_trylock(ip, parent_ip); >> if (WARN_ON_ONCE(bit < 0)) >> return;

Re: [PATCH 1/2] ftrace: disable preemption on the testing of recursion

2021-10-12 Thread Steven Rostedt
On Tue, 12 Oct 2021 13:40:08 +0800 王贇 wrote: > --- a/include/linux/trace_recursion.h > +++ b/include/linux/trace_recursion.h > @@ -214,7 +214,14 @@ static __always_inline void trace_clear_recursion(int > bit) > static __always_inline int ftrace_test_recursion_trylock(unsigned long ip, >

Re: [PATCH 1/2] ftrace: disable preemption on the testing of recursion

2021-10-12 Thread Miroslav Benes
> diff --git a/include/linux/trace_recursion.h b/include/linux/trace_recursion.h > index a9f9c57..805f9c4 100644 > --- a/include/linux/trace_recursion.h > +++ b/include/linux/trace_recursion.h > @@ -214,7 +214,14 @@ static __always_inline void trace_clear_recursion(int > bit) > static

Re: [PATCH 1/2] ftrace: disable preemption on the testing of recursion

2021-10-12 Thread Steven Rostedt
On Tue, 12 Oct 2021 14:24:43 +0200 (CEST) Miroslav Benes wrote: > > +++ b/kernel/livepatch/patch.c > > @@ -52,11 +52,6 @@ static void notrace klp_ftrace_handler(unsigned long ip, > > bit = ftrace_test_recursion_trylock(ip, parent_ip); > > if (WARN_ON_ONCE(bit < 0)) > >

Re: [PATCH 1/2] ftrace: disable preemption on the testing of recursion

2021-10-12 Thread Steven Rostedt
On Tue, 12 Oct 2021 13:40:08 +0800 王贇 wrote: > @@ -52,11 +52,6 @@ static void notrace klp_ftrace_handler(unsigned long ip, > bit = ftrace_test_recursion_trylock(ip, parent_ip); > if (WARN_ON_ONCE(bit < 0)) > return; > - /* > - * A variant of synchronize_rcu()

[PATCH 1/2] ftrace: disable preemption on the testing of recursion

2021-10-12 Thread 王贇
As the documentation explained, ftrace_test_recursion_trylock() and ftrace_test_recursion_unlock() were supposed to disable and enable preemption properly, however currently this work is done outside of the function, which could be missing by mistake. This path will make sure the preemption will