linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC v3 0/5] Align atomic storage
@ 2025-10-07 22:19 Finn Thain
  2025-10-07 22:19 ` [RFC v3 4/5] atomic: Add alignment check to instrumented atomic operations Finn Thain
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Finn Thain @ 2025-10-07 22:19 UTC (permalink / raw)
  To: Andrii Nakryiko, Alexei Starovoitov, Daniel Borkmann,
	Peter Zijlstra, Will Deacon
  Cc: Andrew Morton, Arnd Bergmann, Boqun Feng, bpf, Jonathan Corbet,
	Eduard Zingerman, Geert Uytterhoeven, Hao Luo, John Fastabend,
	Jiri Olsa, KP Singh, Lance Yang, linux-arch, linux-doc,
	linux-kernel, linux-m68k, Mark Rutland, Martin KaFai Lau,
	Stanislav Fomichev, Song Liu, Yonghong Song

This series adds the __aligned attribute to atomic_t and atomic64_t
definitions in include/asm-generic.

It also adds Kconfig options to enable a new runtime warning to help
reveal misaligned atomic accesses on platforms which don't trap that.

Some people might assume scalars are aligned to 4-byte boundaries, while
others might assume natural alignment. Best not to encourage such
assumptions in the documentation.

Moreover, being that locks are performance sensitive, and being that
atomic operations tend to involve further assumptions, there seems to be
room for improvement here.

Pertinent to this discussion are the section "Memory Efficiency" in
Documentation/RCU/Design/Requirements/Requirements.rst
and the section "GUARANTEES" in Documentation/memory-barriers.txt

---
Changed since v2:
 - Specify natural alignment for atomic64_t.
 - CONFIG_DEBUG_ATOMIC checks for natural alignment again.
 - New patch to add weakened alignment check.
 - New patch for explicit alignment in BFP header.

---

Finn Thain (4):
  documentation: Discourage alignment assumptions
  bpf: Explicitly align bpf_res_spin_lock
  atomic: Specify alignment for atomic_t and atomic64_t
  atomic: Add option for weaker alignment check

Peter Zijlstra (1):
  atomic: Add alignment check to instrumented atomic operations

 .../core-api/unaligned-memory-access.rst      |  7 -------
 include/asm-generic/atomic64.h                |  2 +-
 include/asm-generic/rqspinlock.h              |  2 +-
 include/linux/instrumented.h                  | 12 ++++++++++++
 include/linux/types.h                         |  2 +-
 kernel/bpf/rqspinlock.c                       |  1 -
 lib/Kconfig.debug                             | 19 +++++++++++++++++++
 7 files changed, 34 insertions(+), 11 deletions(-)

-- 
2.49.1


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

end of thread, other threads:[~2025-10-16 22:14 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-07 22:19 [RFC v3 0/5] Align atomic storage Finn Thain
2025-10-07 22:19 ` [RFC v3 4/5] atomic: Add alignment check to instrumented atomic operations Finn Thain
2025-10-07 22:19 ` [RFC v3 1/5] documentation: Discourage alignment assumptions Finn Thain
2025-10-14 10:23   ` David Laight
2025-10-15  7:40     ` Finn Thain
2025-10-15 13:53       ` David Laight
2025-10-16  6:53         ` Finn Thain
2025-10-16 13:30   ` Arnd Bergmann
2025-10-16 22:14     ` Finn Thain
2025-10-07 22:19 ` [RFC v3 5/5] atomic: Add option for weaker alignment check Finn Thain
2025-10-07 22:19 ` [RFC v3 3/5] atomic: Specify alignment for atomic_t and atomic64_t Finn Thain
2025-10-07 22:19 ` [RFC v3 2/5] bpf: Explicitly align bpf_res_spin_lock Finn Thain
2025-10-09  2:10   ` Alexei Starovoitov
2025-10-09  2:56     ` Finn Thain
2025-10-09  7:02     ` Peter Zijlstra
2025-10-09 15:17       ` Alexei Starovoitov
2025-10-09 16:01         ` Arnd Bergmann
2025-10-09 16:12           ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).