Messages in this thread | | | From | Joel Fernandes <> | Date | Tue, 23 Apr 2024 14:19:34 -0400 | Subject | Re: [PATCH V2 09/11] rcu: Implement PCPU_RCU_PREEMPT_COUNT framework |
| |
On Sun, Apr 7, 2024 at 5:04 AM Lai Jiangshan <jiangshanlai@gmail.com> wrote: > > From: Lai Jiangshan <jiangshan.ljs@antgroup.com> > > When the arch code provides HAVE_PCPU_RCU_PREEMPT_COUNT and the > corresponding functions, rcu core uses the functions to implement > rcu_preempt_depth(), special bits, switching and so on. > > 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 | 33 +++++++++++++++++++++++++++++++++ > kernel/rcu/Kconfig | 8 ++++++++ > kernel/rcu/rcu.h | 4 ++++ > kernel/rcu/tree_plugin.h | 8 ++++++++ > 4 files changed, 53 insertions(+) > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h > index 328667ae8086..e3e5ce44c7dc 100644 > --- a/include/linux/rcupdate.h > +++ b/include/linux/rcupdate.h > @@ -70,6 +70,8 @@ static inline bool same_state_synchronize_rcu(unsigned long oldstate1, unsigned > > void rcu_read_unlock_special(void); > > +#ifndef CONFIG_PCPU_RCU_PREEMPT_COUNT > + > void __rcu_read_lock(void); > void __rcu_read_unlock(void); > > @@ -81,6 +83,37 @@ void __rcu_read_unlock(void); > */ > #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)) > +#define pcpu_rcu_preempt_special_set() do { } while (0) > +#define pcpu_rcu_preempt_special_clear() do { } while (0) > + > +#else /* #ifndef CONFIG_PCPU_RCU_PREEMPT_COUNT */ > + > +#include <asm/rcu_preempt.h> > + > +static __always_inline void __rcu_read_lock(void) > +{ > + pcpu_rcu_preempt_count_add(1); > + barrier(); > +} > + > +static __always_inline void __rcu_read_unlock(void) > +{ > + barrier(); > + if (unlikely(pcpu_rcu_preempt_count_dec_and_test())) > + pcpu_rcu_read_unlock_special(); > +}
Previous code had comments about the barrier(); , can you add back those comments?
Also there was a compiler barrier in the body of the if() as well?
For reference:
void __rcu_read_unlock(void) { struct task_struct *t = current;
barrier(); // critical section before exit code. if (rcu_preempt_read_exit() == 0) { barrier(); // critical-section exit before .s check. if (unlikely(READ_ONCE(t->rcu_read_unlock_special.s))) rcu_read_unlock_special(t); }
| |