[PATCHv2 05/17] nvme: add Clang context annotations for nvme_ns_head::current_path

Paul E. McKenney paulmck at kernel.org
Tue Jun 30 07:24:34 PDT 2026


On Tue, Jun 30, 2026 at 03:26:40PM +0530, Nilay Shroff wrote:
> > > > > 
> > > > > commit 32c1e63fee171f7ed8cc986ec64f576ee80bccab
> > > > > Author: Paul E. McKenney <paulmck at kernel.org>
> > > > > Date:   Sun Jun 28 09:00:01 2026 -0700
> > > > > 
> > > > >       rcu: Mark __rcu_access_pointer() as context_unsafe()
> > > > > 
> > > > >       A simple comparison of a pointer returned by rcu_access_pointer() results
> > > > >       in a context-analysis warning for lockless inspection of the RCU-protected
> > > > >       (also known as __rcu-protected) pointer.  This can be suppressed by
> > > > >       placing context_unsafe() calls around calls rcu_access_pointer(),
> > > > >       but this is messy and distracting.  This commit therefore wraps the
> > > > >       underlying __rcu_access_pointer() macro with a call to context_unsafe(),
> > > > >       thereby informing the context-analysis code that rcu_access_pointer()
> > > > >       may safely be invoked outside of an RCU read-side critical section.
> > > > > 
> > > > >       Reported-by: Christoph Hellwig <hch at lst.de>
> > > > >       Suggested-by: Marco Elver <elver at google.com>
> > > > >       Signed-off-by: Paul E. McKenney <paulmck at kernel.org>
> > > > > 
> > > > > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
> > > > > index 5e95acc33989b6..e40dc2e20c5b1f 100644
> > > > > --- a/include/linux/rcupdate.h
> > > > > +++ b/include/linux/rcupdate.h
> > > > > @@ -490,12 +490,12 @@ context_unsafe(                                                         \
> > > > >     */
> > > > >    #define unrcu_pointer(p) __unrcu_pointer(p, __UNIQUE_ID(rcu))
> > > > > 
> > > > > -#define __rcu_access_pointer(p, local, space) \
> > > > > +#define __rcu_access_pointer(p, local, space) context_unsafe( \
> > > > >    ({ \
> > > > >        typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \
> > > > >        rcu_check_sparse(p, space); \
> > > > >        ((typeof(*p) __force __kernel *)(local)); \
> > > > > -})
> > > > > +}) )
> > > > >    #define __rcu_dereference_check(p, local, c, space) \
> > > > >    ({ \
> > > > >        /* Dependency order vs. p above. */ \
> > > > 
> > > > I have tested the above patch with an __rcu_guarded pointer accessed
> > > > outside an RCU read-side critical section while Clang context analysis
> > > > is enabled. I can confirm that this change suppresses the context
> > > > analysis warning when the pointer is accessed via rcu_access_pointer().
> > > > 
> > > > With that, if you send out this change, please add:
> > > > 
> > > > Tested-by: Nilay Shroff <nilay at linux.ibm.com>
> > > 
> > > Thanks for double-checking.
> > > 
> > > Reviewed-by: Marco Elver <elver at google.com>
> > 
> > Thank you all!
> > 
> > By default, I will push this into the upcoming v7.3 merge window.  If you
> > need it earlier, we would have to make a case for this being a regression.
> > Which I could probably do, but first, is v7.3 too late for you?
> 
> I think anyways the current series would not land in the upcoming
> kernel v7.2. So if you could push this during v7.3 merge window then
> that should be good for us.

Very good, v7.3 it is!

							Thanx, Paul



More information about the Linux-nvme mailing list