All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	Johannes Thumshirn <jthumshirn@suse.de>,
	Keith Busch <keith.busch@intel.com>,
	Sagi Grimberg <sagi@grimberg.me>,
	Linux Kernel Mailinglist <linux-kernel@vger.kernel.org>,
	Linux NVMe Mailinglist <linux-nvme@lists.infradead.org>,
	Hannes Reinecke <hare@suse.de>, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH] nvme: fix lockdep warning in nvme_mpath_clear_current_path
Date: Mon, 14 May 2018 06:34:03 -0700	[thread overview]
Message-ID: <20180514133403.GA14243@infradead.org> (raw)
In-Reply-To: <20180514133105.GU26088@linux.vnet.ibm.com>

On Mon, May 14, 2018 at 06:31:05AM -0700, Paul E. McKenney wrote:
> > > +	if (head &&
> > > +	    ns == rcu_dereference_protected(head->current_path,
> > > +				lockdep_is_held(&ns->ctrl->subsys->lock)))
> > >  		rcu_assign_pointer(head->current_path, NULL);
> > >  }
> > >  struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);
> > 
> > We don't really dereference it at all in fact, but just check the
> > pointers for equality.  I wonder if there is a better way to do this,
> > as my ANA patches add a caller without the lock (and withou SRU
> > protection either now that I think of it) - for a pure pointer compare
> > we really should not need any sort of protection.
> 
> If you are just looking at the value of an RCU-protected pointer, then
> using rcu_access_pointer() will cause RCU to just read out the value
> and otherwise keeps its mouth shut.

That is exactly the function I was looking for.  And given that srcu
and rcu use the same annotations I should have through of being able
to use it of course.  As you see above we only use the return value
to do a comparison, so we should be perfectly fine.

Johannes, can you respin the patch to use rcu_access_pointer?

WARNING: multiple messages have this Message-ID (diff)
From: hch@infradead.org (Christoph Hellwig)
Subject: [PATCH] nvme: fix lockdep warning in nvme_mpath_clear_current_path
Date: Mon, 14 May 2018 06:34:03 -0700	[thread overview]
Message-ID: <20180514133403.GA14243@infradead.org> (raw)
In-Reply-To: <20180514133105.GU26088@linux.vnet.ibm.com>

On Mon, May 14, 2018@06:31:05AM -0700, Paul E. McKenney wrote:
> > > +	if (head &&
> > > +	    ns == rcu_dereference_protected(head->current_path,
> > > +				lockdep_is_held(&ns->ctrl->subsys->lock)))
> > >  		rcu_assign_pointer(head->current_path, NULL);
> > >  }
> > >  struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);
> > 
> > We don't really dereference it at all in fact, but just check the
> > pointers for equality.  I wonder if there is a better way to do this,
> > as my ANA patches add a caller without the lock (and withou SRU
> > protection either now that I think of it) - for a pure pointer compare
> > we really should not need any sort of protection.
> 
> If you are just looking at the value of an RCU-protected pointer, then
> using rcu_access_pointer() will cause RCU to just read out the value
> and otherwise keeps its mouth shut.

That is exactly the function I was looking for.  And given that srcu
and rcu use the same annotations I should have through of being able
to use it of course.  As you see above we only use the return value
to do a comparison, so we should be perfectly fine.

Johannes, can you respin the patch to use rcu_access_pointer?

  reply	other threads:[~2018-05-14 13:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-14 12:13 [PATCH] nvme: fix lockdep warning in nvme_mpath_clear_current_path Johannes Thumshirn
2018-05-14 12:13 ` Johannes Thumshirn
2018-05-14 12:42 ` Christoph Hellwig
2018-05-14 12:42   ` Christoph Hellwig
2018-05-14 12:57   ` Johannes Thumshirn
2018-05-14 12:57     ` Johannes Thumshirn
2018-05-14 13:38     ` Paul E. McKenney
2018-05-14 13:38       ` Paul E. McKenney
2018-05-14 13:56       ` Johannes Thumshirn
2018-05-14 13:56         ` Johannes Thumshirn
2018-05-14 16:08         ` Paul E. McKenney
2018-05-14 16:08           ` Paul E. McKenney
2018-05-14 13:31   ` Paul E. McKenney
2018-05-14 13:31     ` Paul E. McKenney
2018-05-14 13:34     ` Christoph Hellwig [this message]
2018-05-14 13:34       ` Christoph Hellwig
2018-05-14 13:34     ` Johannes Thumshirn
2018-05-14 13:34       ` Johannes Thumshirn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180514133403.GA14243@infradead.org \
    --to=hch@infradead.org \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jthumshirn@suse.de \
    --cc=keith.busch@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.