Message ID | 20240328075318.83039-3-jiangshanlai@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | rcu/x86: Use per-cpu rcu preempt count | expand |
> On Mar 28, 2024, at 1:20 PM, Lai Jiangshan <jiangshanlai@gmail.com> wrote: > > From: Lai Jiangshan <jiangshan.ljs@antgroup.com> > > Prepare for arch-specific-defined rcu_preempt_depth_set(). > > No functionality change intended, but it has to be defined as a macro > as rcupdate.h is a very low level header included from areas that don't > even know about the task struct "current". Sorry I did not follow changelog. If some rcupdate.h includers do not know about task_struct, how does adding a macro that uses current help? Thanks, - Joel > > Cc: "Paul E. McKenney" <paulmck@kernel.org> > Cc: Peter Zijlstra <peterz@infradead.org> > Cc: Frederic Weisbecker <frederic@kernel.org> > Signed-off-by: Lai Jiangshan <jiangshan.ljs@antgroup.com> > --- > include/linux/rcupdate.h | 1 + > kernel/rcu/tree_plugin.h | 5 ----- > 2 files changed, 1 insertion(+), 5 deletions(-) > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h > index 16f519914415..210f65baf47c 100644 > --- a/include/linux/rcupdate.h > +++ b/include/linux/rcupdate.h > @@ -78,6 +78,7 @@ void __rcu_read_unlock(void); > * types of kernel builds, the rcu_read_lock() nesting depth is unknowable. > */ > #define rcu_preempt_depth() READ_ONCE(current->rcu_read_lock_nesting) > +#define rcu_preempt_depth_set(val) WRITE_ONCE(current->rcu_read_lock_nesting, (val)) > > #else /* #ifdef CONFIG_PREEMPT_RCU */ > > diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h > index 36a8b5dbf5b5..b1264096d03a 100644 > --- a/kernel/rcu/tree_plugin.h > +++ b/kernel/rcu/tree_plugin.h > @@ -387,11 +387,6 @@ static int rcu_preempt_read_exit(void) > return ret; > } > > -static void rcu_preempt_depth_set(int val) > -{ > - WRITE_ONCE(current->rcu_read_lock_nesting, val); > -} > - > /* > * Preemptible RCU implementation for rcu_read_lock(). > * Just increment ->rcu_read_lock_nesting, shared state will be updated > -- > 2.19.1.6.gb485710b >
On Sun, Mar 31, 2024 at 7:10 PM Joel Fernandes <joel@joelfernandes.org> wrote: > > > > > On Mar 28, 2024, at 1:20 PM, Lai Jiangshan <jiangshanlai@gmail.com> wrote: > > > > From: Lai Jiangshan <jiangshan.ljs@antgroup.com> > > > > Prepare for arch-specific-defined rcu_preempt_depth_set(). > > > > No functionality change intended, but it has to be defined as a macro > > as rcupdate.h is a very low level header included from areas that don't > > even know about the task struct "current". > > Sorry I did not follow changelog. If some rcupdate.h includers do not know > about task_struct, how does adding a macro that uses current help? > Hello This is how macro works and it expands blindly based on tokens on the usage-sites. And rcu_preempt_depth() & rcu_preempt_depth_set() are not universally used wrappers, the user can simply also include linux/sched.h to make they work. Thanks Lai
> On Mar 31, 2024, at 9:46 PM, Lai Jiangshan <jiangshanlai@gmail.com> wrote: > > On Sun, Mar 31, 2024 at 7:10 PM Joel Fernandes <joel@joelfernandes.org> wrote: >> >> >> >>>> On Mar 28, 2024, at 1:20 PM, Lai Jiangshan <jiangshanlai@gmail.com> wrote: >>> >>> From: Lai Jiangshan <jiangshan.ljs@antgroup.com> >>> >>> Prepare for arch-specific-defined rcu_preempt_depth_set(). >>> >>> No functionality change intended, but it has to be defined as a macro >>> as rcupdate.h is a very low level header included from areas that don't >>> even know about the task struct "current". >> >> Sorry I did not follow changelog. If some rcupdate.h includers do not know >> about task_struct, how does adding a macro that uses current help? >> > > Hello > > This is how macro works and it expands blindly based on tokens on the > usage-sites. > > And rcu_preempt_depth() & rcu_preempt_depth_set() are not universally > used wrappers, the user can simply also include linux/sched.h to make > they work. Oh I see, so by hiding it in a macro, the code remains unexpanded. That makes sense.. Thanks. > > Thanks > Lai
2024年4月1日 00:16,Lai Jiangshan <jiangshanlai@gmail.com> wrote: > > On Sun, Mar 31, 2024 at 7:10 PM Joel Fernandes <joel@joelfernandes.org> wrote: >> >> >> >>> On Mar 28, 2024, at 1:20 PM, Lai Jiangshan <jiangshanlai@gmail.com> wrote: >>> >>> From: Lai Jiangshan <jiangshan.ljs@antgroup.com> >>> >>> Prepare for arch-specific-defined rcu_preempt_depth_set(). >>> >>> No functionality change intended, but it has to be defined as a macro >>> as rcupdate.h is a very low level header included from areas that don't >>> even know about the task struct "current". >> >> Sorry I did not follow changelog. If some rcupdate.h includers do not know >> about task_struct, how does adding a macro that uses current help? >> > > Hello > > This is how macro works and it expands blindly based on tokens on the > usage-sites. But ‘current’ still needs to be expanded at last, it seems to me that it only affects the including order of the header files? Or what am I missing? > > And rcu_preempt_depth() & rcu_preempt_depth_set() are not universally > used wrappers, the user can simply also include linux/sched.h to make > they work. > > Thanks > Lai >
2024年4月1日 19:40,Alan Huang <mmpgouride@gmail.com> wrote: > > 2024年4月1日 00:16,Lai Jiangshan <jiangshanlai@gmail.com> wrote: >> >> On Sun, Mar 31, 2024 at 7:10 PM Joel Fernandes <joel@joelfernandes.org> wrote: >>> >>> >>> >>>> On Mar 28, 2024, at 1:20 PM, Lai Jiangshan <jiangshanlai@gmail.com> wrote: >>>> >>>> From: Lai Jiangshan <jiangshan.ljs@antgroup.com> >>>> >>>> Prepare for arch-specific-defined rcu_preempt_depth_set(). >>>> >>>> No functionality change intended, but it has to be defined as a macro >>>> as rcupdate.h is a very low level header included from areas that don't >>>> even know about the task struct "current". >>> >>> Sorry I did not follow changelog. If some rcupdate.h includers do not know >>> about task_struct, how does adding a macro that uses current help? >>> >> >> Hello >> >> This is how macro works and it expands blindly based on tokens on the >> usage-sites. > > But ‘current’ still needs to be expanded at last, it seems to me that it only affects > the including order of the header files? > > Or what am I missing? Get the missing part: if the user don’t need to use rcu_preempt_depth() and rcu_preempt_depth_set() but other parts of rcupdate.h, then the two has to be defined as a macro to avoid including linux/sched.h. Sorry for the bother. > >> >> And rcu_preempt_depth() & rcu_preempt_depth_set() are not universally >> used wrappers, the user can simply also include linux/sched.h to make >> they work. >> >> Thanks >> Lai
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 16f519914415..210f65baf47c 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -78,6 +78,7 @@ void __rcu_read_unlock(void); * types of kernel builds, the rcu_read_lock() nesting depth is unknowable. */ #define rcu_preempt_depth() READ_ONCE(current->rcu_read_lock_nesting) +#define rcu_preempt_depth_set(val) WRITE_ONCE(current->rcu_read_lock_nesting, (val)) #else /* #ifdef CONFIG_PREEMPT_RCU */ diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 36a8b5dbf5b5..b1264096d03a 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -387,11 +387,6 @@ static int rcu_preempt_read_exit(void) return ret; } -static void rcu_preempt_depth_set(int val) -{ - WRITE_ONCE(current->rcu_read_lock_nesting, val); -} - /* * Preemptible RCU implementation for rcu_read_lock(). * Just increment ->rcu_read_lock_nesting, shared state will be updated