[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20190430112749.GA23020@redhat.com>
Date: Tue, 30 Apr 2019 13:27:49 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: "Paul E. McKenney" <paulmck@...ux.ibm.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Joel Fernandes <joel@...lfernandes.org>,
Josh Triplett <josh@...htriplett.org>,
Lai Jiangshan <jiangshanlai@...il.com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Steven Rostedt <rostedt@...dmis.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] rcu/sync: simplify the state machine
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.
Powered by blists - more mailing lists