LKML Archive on lore.kernel.org
 help / color / Atom feed
* [RFC PATCH 0/8] Rework READ_ONCE() to improve codegen
@ 2020-01-10 16:56 Will Deacon
  2020-01-10 16:56 ` [RFC PATCH 1/8] compiler/gcc: Emit build-time warning for GCC prior to version 4.8 Will Deacon
                   ` (11 more replies)
  0 siblings, 12 replies; 32+ messages in thread
From: Will Deacon @ 2020-01-10 16:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, kernel-team, Will Deacon, Michael Ellerman,
	Peter Zijlstra, Linus Torvalds, Segher Boessenkool,
	Christian Borntraeger, Luc Van Oostenryck, Arnd Bergmann

Hi all,

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

https://lore.kernel.org/lkml/875zimp0ay.fsf@mpe.ellerman.id.au

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
    restriction.

  * 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
    stripping.

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.

Cheers,

Will

Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Segher Boessenkool <segher@kernel.crashing.org>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>

--->8

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
    macros

 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(-)

-- 
2.25.0.rc1.283.g88dfdc4193-goog


^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, back to index

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10 16:56 [RFC PATCH 0/8] Rework READ_ONCE() to improve codegen Will Deacon
2020-01-10 16:56 ` [RFC PATCH 1/8] compiler/gcc: Emit build-time warning for GCC prior to version 4.8 Will Deacon
2020-01-10 17:35   ` Arnd Bergmann
2020-01-10 17:53     ` Joe Perches
2020-01-13 14:39       ` Arnd Bergmann
2020-01-13 15:35         ` Masahiro Yamada
2020-01-13 14:27     ` Will Deacon
2020-01-14 21:39     ` Nick Desaulniers
2020-01-15 10:35       ` David Laight
2020-01-15 10:49       ` Arnd Bergmann
2020-01-10 16:56 ` [RFC PATCH 2/8] netfilter: Avoid assigning 'const' pointer to non-const pointer Will Deacon
2020-01-10 16:56 ` [RFC PATCH 3/8] fault_inject: Don't rely on "return value" from WRITE_ONCE() Will Deacon
2020-01-10 16:56 ` [RFC PATCH 4/8] READ_ONCE: Simplify implementations of {READ,WRITE}_ONCE() Will Deacon
2020-01-10 16:56 ` [RFC PATCH 5/8] READ_ONCE: Enforce atomicity for {READ,WRITE}_ONCE() memory accesses Will Deacon
2020-01-10 19:24   ` Arnd Bergmann
2020-01-13 16:16     ` Will Deacon
2020-01-10 16:56 ` [RFC PATCH 6/8] READ_ONCE: Drop pointer qualifiers when reading from scalar types Will Deacon
2020-01-10 18:54   ` Linus Torvalds
2020-01-13 14:59     ` Will Deacon
2020-01-13 17:42       ` Luc Van Oostenryck
2020-01-13 19:31       ` Linus Torvalds
2020-01-10 16:56 ` [RFC PATCH 7/8] locking/barriers: Use '__unqual_scalar_typeof' for load-acquire macros Will Deacon
2020-01-10 19:42   ` Arnd Bergmann
2020-01-13 15:01     ` Will Deacon
2020-01-10 16:56 ` [RFC PATCH 8/8] arm64: barrier: Use '__unqual_scalar_typeof' for acquire/release macros Will Deacon
2020-01-10 17:45   ` Mark Rutland
2020-01-10 17:58 ` [RFC PATCH 0/8] Rework READ_ONCE() to improve codegen Arnd Bergmann
2020-01-10 19:46 ` Arnd Bergmann
2020-01-10 20:14   ` Linus Torvalds
2020-01-13 13:03     ` Arnd Bergmann
2020-01-13 11:20 ` David Laight
2020-01-13 12:40 ` Christian Borntraeger

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git