From: NeilBrown <neilb@suse.de>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Patrick Marlier <patrick.marlier@gmail.com>,
linux-kernel@vger.kernel.org, mingo@kernel.org,
laijs@cn.fujitsu.com, dipankar@in.ibm.com,
akpm@linux-foundation.org, mathieu.desnoyers@efficios.com,
josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org,
dhowells@redhat.com, edumazet@google.com, dvhart@linux.intel.com,
fweisbec@gmail.com, oleg@redhat.com, bobby.prani@gmail.com,
wangyun@linux.vnet.ibm.com
Subject: Re: [PATCH tip/core/rcu 3/4] md/bitmap: Fix list_entry_rcu usage
Date: Thu, 21 May 2015 10:07:35 +1000 [thread overview]
Message-ID: <20150521100735.4ad0b5ae@notabene.brown> (raw)
In-Reply-To: <20150520132835.GJ6776@linux.vnet.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 3771 bytes --]
On Wed, 20 May 2015 06:28:35 -0700 "Paul E. McKenney"
<paulmck@linux.vnet.ibm.com> wrote:
> On Wed, May 20, 2015 at 03:09:19PM +1000, NeilBrown wrote:
> > On Tue, 19 May 2015 15:07:25 -0700 "Paul E. McKenney"
> > <paulmck@linux.vnet.ibm.com> wrote:
> >
> >
> > > The code in md probably needs to change in any case, as otherwise we are
> > > invoking rcu_dereference_whatever() on a full struct list_head rather
> > > than on a single pointer. Or am I missing something here?
> >
> > I think it would be
> > rcu_dereference_whatever(&mddev->disks)
> >
> > I don't know what you mean by "on a full struct list_head", but there is
> > nothing actually being dereferenced here - right? Just pointer arithmetic on
> > 'mddev'.
>
> It really does dereference. Strange but true.
Well... your the expert. But without an lvalue, I can't see it.
>
> > I should probably just
> >
> > diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
> > index 2bc56e2a3526..b1d237bf8b3b 100644
> > --- a/drivers/md/bitmap.c
> > +++ b/drivers/md/bitmap.c
> > @@ -181,7 +181,7 @@ static struct md_rdev *next_active_rdev(struct md_rdev *rdev, struct mddev *mdde
> > rcu_read_lock();
> > if (rdev == NULL)
> > /* start at the beginning */
> > - rdev = list_entry_rcu(&mddev->disks, struct md_rdev, same_set);
> > + rdev = list_entry(&mddev->disks, struct md_rdev, same_set);
> > else {
> > /* release the previous rdev and start from there. */
> > rdev_dec_pending(rdev, mddev);
> >
> > as there really are no RCU issues with getting that address. Maybe I should
> > move it outside the rcu_read_lock() just to be blatant.... but that would
> > make the code a lot more clumsy as the rdev_dec_pending must be inside the
> > rcu_read_lock..
> >
> > So this.
>
> Fair enough -- if you aren't using RCU, there is really no point in using
> the RCU API. I will drop this patch from my tree. You are pushing yours,
> I am guessing?
Excellent guess :-)
Hopefully for the next -rc.
Thanks,
NeilBrown
>
> Thanx, Paul
>
> > Thanks,
> > NeilBrown
> >
> > From: NeilBrown <neilb@suse.de>
> > Date: Wed, 20 May 2015 15:05:09 +1000
> > Subject: [PATCH] md/bitmap: remove rcu annotation from pointer arithmetic.
> >
> > Evaluating "&mddev->disks" is simple pointer arithmetic, so
> > it does not need 'rcu' annotations - no dereferencing is happening.
> >
> > Also enhance the comment to explain that 'rdev' in that case
> > is not actually a pointer to an rdev.
> >
> > Reported-by: Patrick Marlier <patrick.marlier@gmail.com>
> > Signed-off-by: NeilBrown <neilb@suse.de>
> >
> > diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
> > index 2bc56e2a3526..135a0907e9de 100644
> > --- a/drivers/md/bitmap.c
> > +++ b/drivers/md/bitmap.c
> > @@ -177,11 +177,16 @@ static struct md_rdev *next_active_rdev(struct md_rdev *rdev, struct mddev *mdde
> > * nr_pending is 0 and In_sync is clear, the entries we return will
> > * still be in the same position on the list when we re-enter
> > * list_for_each_entry_continue_rcu.
> > + *
> > + * Note that if entered with 'rdev == NULL' to start at the
> > + * beginning, we temporarily assign 'rdev' to an address which
> > + * isn't really an rdev, but which can be used by
> > + * list_for_each_entry_continue_rcu() to find the first entry.
> > */
> > rcu_read_lock();
> > if (rdev == NULL)
> > /* start at the beginning */
> > - rdev = list_entry_rcu(&mddev->disks, struct md_rdev, same_set);
> > + rdev = list_entry(&mddev->disks, struct md_rdev, same_set);
> > else {
> > /* release the previous rdev and start from there. */
> > rdev_dec_pending(rdev, mddev);
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]
next prev parent reply other threads:[~2015-05-21 0:08 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-12 22:46 [PATCH tip/core/rcu 0/4] RCU-protected list updates for 4.2 Paul E. McKenney
2015-05-12 22:46 ` [PATCH tip/core/rcu 1/4] rculist: Fix another sparse warning Paul E. McKenney
2015-05-12 22:46 ` [PATCH tip/core/rcu 2/4] rculist: Fix list_entry_rcu to read ptr with rcu_dereference_raw Paul E. McKenney
2015-05-12 22:46 ` [PATCH tip/core/rcu 3/4] md/bitmap: Fix list_entry_rcu usage Paul E. McKenney
2015-05-13 2:38 ` Steven Rostedt
2015-05-13 2:58 ` NeilBrown
2015-05-13 13:17 ` Paul E. McKenney
2015-05-16 17:42 ` Patrick Marlier
2015-05-18 2:06 ` NeilBrown
2015-05-18 13:43 ` Steven Rostedt
2015-05-19 22:07 ` Paul E. McKenney
2015-05-20 5:09 ` NeilBrown
2015-05-20 13:28 ` Paul E. McKenney
2015-05-21 0:07 ` NeilBrown [this message]
2015-09-11 23:05 ` Paul E. McKenney
2015-09-13 10:06 ` Patrick Marlier
2015-09-13 16:10 ` Paul E. McKenney
2015-09-22 20:50 ` Paul E. McKenney
2015-09-23 17:57 ` Patrick Marlier
2015-09-24 4:45 ` Paul E. McKenney
2015-05-18 13:53 ` Patrick Marlier
2015-05-18 19:36 ` Patrick Marlier
2015-05-12 22:46 ` [PATCH tip/core/rcu 4/4] netfilter: " Paul E. McKenney
2015-05-13 2:42 ` Steven Rostedt
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=20150521100735.4ad0b5ae@notabene.brown \
--to=neilb@suse.de \
--cc=akpm@linux-foundation.org \
--cc=bobby.prani@gmail.com \
--cc=dhowells@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=dvhart@linux.intel.com \
--cc=edumazet@google.com \
--cc=fweisbec@gmail.com \
--cc=josh@joshtriplett.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=patrick.marlier@gmail.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=wangyun@linux.vnet.ibm.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).