[lkml]   [2020]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subject[RFC PATCH 0/8] Rework READ_ONCE() to improve codegen
Hi all,

This is a follow-up RFC to the discussions we had on the mailing list at
the end of last year:

Unfortunately, we didn't get a "silver bullet" solution out of that
long thread, but I've tried to piece together some of the bits and
pieces we discussed and I've ended up with this series, which does at
least solve the pressing problem with the bitops for arm64.

The rough summary of the series is:

* Drop the GCC 4.8 workarounds, so that READ_ONCE() is a
straightforward dereference of a cast-to-volatile pointer.

* Require that the access is either 1, 2, 4 or 8 bytes in size
(even 32-bit architectures tend to use 8-byte accesses here).

* Introduce __READ_ONCE() for tearing operations with no size

* Drop pointer qualifiers from scalar types, so that volatile scalars
don't generate horrible stack-spilling mess. This is pretty ugly,
but it's also mechanical and wrapped up in a macro.

* Convert acquire/release accessors to perform the same qualifier

I gave up trying to prevent READ_ONCE() on aggregates because it is
pervasive, particularly within the mm/ layer on things like pmd_t.
Thankfully, these don't tend to be volatile.

I have more patches in this area because I'm trying to move all the
read_barrier_depends() magic into arch/alpha/, but I'm holding off until
we agree on this part first.



Cc: Michael Ellerman <>
Cc: Peter Zijlstra <>
Cc: Linus Torvalds <>
Cc: Segher Boessenkool <>
Cc: Christian Borntraeger <>
Cc: Luc Van Oostenryck <>
Cc: Arnd Bergmann <>


Will Deacon (8):
compiler/gcc: Emit build-time warning for GCC prior to version 4.8
netfilter: Avoid assigning 'const' pointer to non-const pointer
fault_inject: Don't rely on "return value" from WRITE_ONCE()
READ_ONCE: Simplify implementations of {READ,WRITE}_ONCE()
READ_ONCE: Enforce atomicity for {READ,WRITE}_ONCE() memory accesses
READ_ONCE: Drop pointer qualifiers when reading from scalar types
locking/barriers: Use '__unqual_scalar_typeof' for load-acquire macros
arm64: barrier: Use '__unqual_scalar_typeof' for acquire/release

arch/arm64/include/asm/barrier.h | 16 ++--
drivers/xen/time.c | 2 +-
include/asm-generic/barrier.h | 16 ++--
include/linux/compiler-gcc.h | 4 +
include/linux/compiler.h | 129 +++++++++++++------------------
include/linux/compiler_types.h | 15 ++++
lib/fault-inject.c | 4 +-
net/netfilter/core.c | 2 +-
net/xdp/xsk_queue.h | 2 +-
9 files changed, 93 insertions(+), 97 deletions(-)


 \ /
  Last update: 2020-01-10 17:57    [W:0.157 / U:4.684 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site