[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.44L0.1908161505400.1525-100000@iolanthe.rowland.org>
Date: Fri, 16 Aug 2019 15:19:43 -0400 (EDT)
From: Alan Stern <stern@...land.harvard.edu>
To: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
cc: rostedt <rostedt@...dmis.org>,
Valentin Schneider <valentin.schneider@....com>,
linux-kernel <linux-kernel@...r.kernel.org>,
"Joel Fernandes, Google" <joel@...lfernandes.org>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
paulmck <paulmck@...ux.ibm.com>,
Boqun Feng <boqun.feng@...il.com>,
Will Deacon <will.deacon@....com>,
David Howells <dhowells@...hat.com>,
Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH 1/1] Fix: trace sched switch start/stop racy updates
On Fri, 16 Aug 2019, Mathieu Desnoyers wrote:
> If you choose not to use READ_ONCE(), then the "load tearing" issue can
> cause similar spurious 1 -> 0 -> 1 transitions near 16-bit counter
> overflow as described above. The "Invented load" also becomes an issue,
> because the compiler could use the loaded value for a branch, and re-load
> that value between two branches which are expected to use the same value,
> effectively generating a corrupted state.
>
> I think we need a statement about whether READ_ONCE/WRITE_ONCE should
> be used in this kind of situation, or if we are fine dealing with the
> awkward compiler side-effects when they will occur.
The only real downside (apart from readability) of READ_ONCE and
WRITE_ONCE is that they prevent the compiler from optimizing accesses
to the location being read or written. But if you're just doing a
single access in each place, not multiple accesses, then there's
nothing to optimize anyway. So there's no real reason not to use
READ_ONCE or WRITE_ONCE.
Alan Stern
Powered by blists - more mailing lists