[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250722220446.GA376252@joelbox2>
Date: Tue, 22 Jul 2025 18:04:46 -0400
From: Joel Fernandes <joelagnelf@...dia.com>
To: "Paul E. McKenney" <paulmck@...nel.org>
Cc: rcu@...r.kernel.org, linux-kernel@...r.kernel.org, kernel-team@...a.com,
rostedt@...dmis.org,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Subject: Re: [PATCH v3 1/4] srcu: Move rcu_is_watching() checks to
srcu_read_{,un}lock_fast()
On Mon, Jul 21, 2025 at 09:24:30AM -0700, Paul E. McKenney wrote:
> The rcu_is_watching() warnings are currently in the SRCU-tree
> implementations of __srcu_read_lock_fast() and __srcu_read_unlock_fast().
> However, this makes it difficult to create _notrace variants of
> srcu_read_lock_fast() and srcu_read_unlock_fast(). This commit therefore
> moves these checks to srcu_read_lock_fast(), srcu_read_unlock_fast(),
> srcu_down_read_fast(), and srcu_up_read_fast().
>
> Signed-off-by: Paul E. McKenney <paulmck@...nel.org>
Reviewed-by: Joel Fernandes <joelagnelf@...dia.com>
thanks,
- Joel
> Cc: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
> Cc: Steven Rostedt <rostedt@...dmis.org>
> Cc: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
> ---
> include/linux/srcu.h | 4 ++++
> include/linux/srcutree.h | 2 --
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/srcu.h b/include/linux/srcu.h
> index f179700fecafb..478c73d067f7d 100644
> --- a/include/linux/srcu.h
> +++ b/include/linux/srcu.h
> @@ -275,6 +275,7 @@ static inline struct srcu_ctr __percpu *srcu_read_lock_fast(struct srcu_struct *
> {
> struct srcu_ctr __percpu *retval;
>
> + RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_lock_fast().");
> srcu_check_read_flavor_force(ssp, SRCU_READ_FLAVOR_FAST);
> retval = __srcu_read_lock_fast(ssp);
> rcu_try_lock_acquire(&ssp->dep_map);
> @@ -295,6 +296,7 @@ static inline struct srcu_ctr __percpu *srcu_read_lock_fast(struct srcu_struct *
> static inline struct srcu_ctr __percpu *srcu_down_read_fast(struct srcu_struct *ssp) __acquires(ssp)
> {
> WARN_ON_ONCE(IS_ENABLED(CONFIG_PROVE_RCU) && in_nmi());
> + RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_down_read_fast().");
> srcu_check_read_flavor_force(ssp, SRCU_READ_FLAVOR_FAST);
> return __srcu_read_lock_fast(ssp);
> }
> @@ -389,6 +391,7 @@ static inline void srcu_read_unlock_fast(struct srcu_struct *ssp, struct srcu_ct
> srcu_check_read_flavor(ssp, SRCU_READ_FLAVOR_FAST);
> srcu_lock_release(&ssp->dep_map);
> __srcu_read_unlock_fast(ssp, scp);
> + RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_unlock_fast().");
> }
>
> /**
> @@ -405,6 +408,7 @@ static inline void srcu_up_read_fast(struct srcu_struct *ssp, struct srcu_ctr __
> WARN_ON_ONCE(IS_ENABLED(CONFIG_PROVE_RCU) && in_nmi());
> srcu_check_read_flavor(ssp, SRCU_READ_FLAVOR_FAST);
> __srcu_read_unlock_fast(ssp, scp);
> + RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_up_read_fast().");
> }
>
> /**
> diff --git a/include/linux/srcutree.h b/include/linux/srcutree.h
> index bf44d8d1e69ea..043b5a67ef71e 100644
> --- a/include/linux/srcutree.h
> +++ b/include/linux/srcutree.h
> @@ -244,7 +244,6 @@ static inline struct srcu_ctr __percpu *__srcu_read_lock_fast(struct srcu_struct
> {
> struct srcu_ctr __percpu *scp = READ_ONCE(ssp->srcu_ctrp);
>
> - RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_lock_fast().");
> if (!IS_ENABLED(CONFIG_NEED_SRCU_NMI_SAFE))
> this_cpu_inc(scp->srcu_locks.counter); /* Y */
> else
> @@ -275,7 +274,6 @@ static inline void __srcu_read_unlock_fast(struct srcu_struct *ssp, struct srcu_
> this_cpu_inc(scp->srcu_unlocks.counter); /* Z */
> else
> atomic_long_inc(raw_cpu_ptr(&scp->srcu_unlocks)); /* Z */
> - RCU_LOCKDEP_WARN(!rcu_is_watching(), "RCU must be watching srcu_read_unlock_fast().");
> }
>
> void __srcu_check_read_flavor(struct srcu_struct *ssp, int read_flavor);
> --
> 2.40.1
>
Powered by blists - more mailing lists