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

From: Paul E. McKenney

Date: Fri Jun 26 2026 - 14:36:36 EST


On Fri, Jun 26, 2026 at 08:40:50AM +0200, Christoph Hellwig wrote:
> On Sun, Jun 14, 2026 at 06:45:20PM +0530, Nilay Shroff wrote:
> > +++ b/drivers/nvme/host/multipath.c
> > @@ -231,8 +231,16 @@ bool nvme_mpath_clear_current_path(struct nvme_ns *ns)
> > bool changed = false;
> > int node;
> >
> > + /*
> > + * This helper is used by namespace failover/teardown and I/O policy
> > + * update paths. We only compare the head->current_path[] pointer value
> > + * and do not dereference the referenced namespace, so suppress the
> > + * context analysis warning for this lockless inspection of the
> > + * __rcu_guarded pointer.
> > + */
> > for_each_node(node) {
> > - if (ns == rcu_access_pointer(head->current_path[node])) {
> > + if (context_unsafe(ns ==
> > + rcu_access_pointer(head->current_path[node]))) {
>
> I think we need a helper for this, as for a simple pointer value
> comparison without a dereference we don't really need either
> rcu_access_pointer nor locking.
>
> Maybe somthing like a
>
> rcu_compare_pointer(rcu_pointer, nonrcu_pointer)
>
> ?

We could provide something like this:

#define rcu_compare_pointer(rcu_pointer, nonrcu_pointer) \
context_unsafe(rcu_access_pointer(rcu_pointer) == (nonrcu_pointer))

Or maybe rcu_pointer_equals()?

Marco, thoughts?

Thanx, Paul