linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: "Paul E. McKenney" <paulmck@linux.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Joel Fernandes <joel@joelfernandes.org>,
	Josh Triplett <josh@joshtriplett.org>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] rcu/sync: simplify the state machine
Date: Tue, 30 Apr 2019 13:27:49 +0200	[thread overview]
Message-ID: <20190430112749.GA23020@redhat.com> (raw)
In-Reply-To: <20190429204041.GU3923@linux.ibm.com>

On 04/29, Paul E. McKenney wrote:
>
> On Mon, Apr 29, 2019 at 06:06:04PM +0200, Oleg Nesterov wrote:
> >
> > Well, at least WRITE_ONCE()'s look certainly unneeded to me, gp_state
> > is protected by rss_lock.
> >
> > WARN_ON_ONCE(gp_state) can read gp_state lockless, but even in this case
> > I do not understand what READ_ONCE() tries to prevent...
> >
> > Nevermind, this won't hurt and as I already said I don't understand the
> > _ONCE() magic anyway ;)
>
> If I understand correctly, rcu_sync_is_idle() can be inline and returns
> ->gp_state.

Ah, sorry! I didn't mean rcu_sync_is_idle(). To be honeest, I didn't even
notice this change, but it looks obviously fine to me, with or without this
patch.

And yes,

> Without the READ_ONCE(), the compiler might fuse reads from
> consecutive calls to rcu_sync_is_idle() or (under register pressure)
> re-read from it, getting inconsistent results.  For example, this:
>
> 	tmp = rcu_sync_is_idle(rsp);
> 	do_something(tmp);
> 	do_something_else(tmp);
>
> Might become this:
>
> 	do_something(rcu_sync_is_idle(rsp));
> 	do_something_else(rcu_sync_is_idle(rsp));


this is very clear. Even for me ;)

Thanks,

Oleg.


      reply	other threads:[~2019-04-30 11:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-25 16:40 [PATCH 0/1] rcu/sync: simplify the state machine Oleg Nesterov
2019-04-25 16:49 ` Oleg Nesterov
2019-04-25 16:50 ` [PATCH 1/1] " Oleg Nesterov
2019-04-27 21:02   ` Paul E. McKenney
2019-04-28 22:26     ` Paul E. McKenney
2019-04-29 16:06       ` Oleg Nesterov
2019-04-29 20:40         ` Paul E. McKenney
2019-04-30 11:27           ` Oleg Nesterov [this message]

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=20190430112749.GA23020@redhat.com \
    --to=oleg@redhat.com \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=paulmck@linux.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    /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).