From: Frederic Weisbecker <frederic@kernel.org>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Neeraj Upadhyay <neeraju@codeaurora.org>,
Boqun Feng <boqun.feng@gmail.com>,
Uladzislau Rezki <urezki@gmail.com>,
Joel Fernandes <joel@joelfernandes.org>
Subject: Re: [PATCH] rcu/doc: Add a quick quiz to explain further why we need smp_mb__after_unlock_lock()
Date: Sat, 12 Jun 2021 00:45:17 +0200 [thread overview]
Message-ID: <20210611224517.GA150081@lothringen> (raw)
In-Reply-To: <20210611172514.GG4397@paulmck-ThinkPad-P17-Gen-1>
On Fri, Jun 11, 2021 at 10:25:14AM -0700, Paul E. McKenney wrote:
> On Fri, Jun 11, 2021 at 12:34:32PM +0200, Frederic Weisbecker wrote:
> Glad to help, and I will reach out to you should someone make the mistake
> of insisting that I write something in French. ;-)
If that can help, we still have frenglish for neutral territories such as airports.
Not easy to master though...
>
> > > ++-----------------------------------------------------------------------+
> > > +
> > > This approach must be extended to include idle CPUs, which need
> > > RCU's grace-period memory ordering guarantee to extend to any
> > > RCU read-side critical sections preceding and following the current
>
> How about like this?
>
> +-----------------------------------------------------------------------+
> | **Quick Quiz**: |
> +-----------------------------------------------------------------------+
> | But the chain of rcu_node-structure lock acquisitions guarantees |
> | that new readers will see all of the updater's pre-grace-period |
> | accesses and also guarantees that the updater's post-grace-period |
> | accesses will see all of the old reader's accesses. So why do we |
> | need all of those calls to smp_mb__after_unlock_lock()? |
> +-----------------------------------------------------------------------+
> | **Answer**: |
> +-----------------------------------------------------------------------+
> | Because we must provide ordering for RCU's polling grace-period |
> | primitives, for example, get_state_synchronize_rcu() and |
> | poll_state_synchronize_rcu(). Consider this code:: |
> | |
> | CPU 0 CPU 1 |
> | ---- ---- |
> | WRITE_ONCE(X, 1) WRITE_ONCE(Y, 1) |
> | g = get_state_synchronize_rcu() smp_mb() |
> | while (!poll_state_synchronize_rcu(g)) r1 = READ_ONCE(X) |
> | continue; |
> | r0 = READ_ONCE(Y) |
> | |
> | RCU guarantees that the outcome r0 == 0 && r1 == 0 will not |
> | happen, even if CPU 1 is in an RCU extended quiescent state |
> | (idle or offline) and thus won't interact directly with the RCU |
> | core processing at all. |
> +-----------------------------------------------------------------------+
Very good, thanks a lot :o)
next prev parent reply other threads:[~2021-06-11 22:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-10 15:50 [PATCH] rcu/doc: Add a quick quiz to explain further why we need smp_mb__after_unlock_lock() Frederic Weisbecker
2021-06-10 16:57 ` Paul E. McKenney
2021-06-11 0:28 ` Akira Yokosawa
2021-06-11 0:48 ` Paul E. McKenney
2021-06-11 0:58 ` Akira Yokosawa
2021-06-11 10:34 ` Frederic Weisbecker
2021-06-11 17:25 ` Paul E. McKenney
2021-06-11 22:45 ` Frederic Weisbecker [this message]
2021-06-11 23:48 ` Paul E. McKenney
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=20210611224517.GA150081@lothringen \
--to=frederic@kernel.org \
--cc=boqun.feng@gmail.com \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neeraju@codeaurora.org \
--cc=paulmck@kernel.org \
--cc=urezki@gmail.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 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.