public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.ibm.com>
To: Oleg Nesterov <oleg@redhat.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: Mon, 29 Apr 2019 13:40:41 -0700	[thread overview]
Message-ID: <20190429204041.GU3923@linux.ibm.com> (raw)
In-Reply-To: <20190429160603.GC17715@redhat.com>

On Mon, Apr 29, 2019 at 06:06:04PM +0200, Oleg Nesterov wrote:
> On 04/28, Paul E. McKenney wrote:
> >
> > And it still looks good after review, so I have pushed it.
> 
> Thanks!
> 
> > I did add
> > READ_ONCE() and WRITE_ONCE() to unprotected uses of ->gp_state, but
> > please let me know if I messed anything up.
> 
> 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.  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 might actually be harmless given current calls, but it would be at
best an accident waiting to happen.

Or am I missing something here?

							Thanx, Paul


  reply	other threads:[~2019-04-29 20:40 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 [this message]
2019-04-30 11:27           ` Oleg Nesterov

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=20190429204041.GU3923@linux.ibm.com \
    --to=paulmck@linux.ibm.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=oleg@redhat.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