linux-parisc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC v4 0/5] Align atomic storage
@ 2025-10-20 22:28 Finn Thain
  2025-10-20 22:28 ` [RFC v4 2/5] parisc: Drop linux/kernel.h include from asm/bug.h header Finn Thain
  0 siblings, 1 reply; 3+ messages in thread
From: Finn Thain @ 2025-10-20 22:28 UTC (permalink / raw)
  To: James E.J. Bottomley, Helge Deller, Peter Zijlstra, Will Deacon
  Cc: Andrew Morton, Andrii Nakryiko, Arnd Bergmann, Alexei Starovoitov,
	Boqun Feng, bpf, Daniel Borkmann, Geert Uytterhoeven, linux-arch,
	linux-kernel, linux-m68k, linux-parisc, Mark Rutland

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.

This patch series is a Request For Comments because the alignment
change is a time/space tradeoff. Its costs and benefits are expected
to vary across platforms and workloads. More measurements are needed.

---

Changed since v3:
 - Rebased on v6.17.
 - New patch to resolve header dependency issue on parisc.
 - Dropped documentation patch.

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 BPF header.

---

Finn Thain (4):
  bpf: Explicitly align bpf_res_spin_lock
  parisc: Drop linux/kernel.h include from asm/bug.h header
  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

 arch/parisc/include/asm/bug.h    |  2 --
 include/asm-generic/atomic64.h   |  2 +-
 include/asm-generic/rqspinlock.h |  2 +-
 include/linux/instrumented.h     | 15 +++++++++++++++
 include/linux/types.h            |  2 +-
 kernel/bpf/rqspinlock.c          |  1 -
 lib/Kconfig.debug                | 18 ++++++++++++++++++
 7 files changed, 36 insertions(+), 6 deletions(-)

-- 
2.49.1


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

* [RFC v4 2/5] parisc: Drop linux/kernel.h include from asm/bug.h header
  2025-10-20 22:28 [RFC v4 0/5] Align atomic storage Finn Thain
@ 2025-10-20 22:28 ` Finn Thain
  2025-11-08 22:39   ` Helge Deller
  0 siblings, 1 reply; 3+ messages in thread
From: Finn Thain @ 2025-10-20 22:28 UTC (permalink / raw)
  To: Peter Zijlstra, Will Deacon, James E.J. Bottomley, Helge Deller
  Cc: Andrew Morton, Arnd Bergmann, Boqun Feng, Geert Uytterhoeven,
	linux-arch, linux-kernel, linux-m68k, Mark Rutland, linux-parisc

This patch series will add WARN_ON_ONCE() calls to the header file
linux/instrumented.h. That requires including linux/bug.h,
but doing so causes the following compiler error on parisc:

In file included from ./include/linux/atomic/atomic-instrumented.h:17,
                 from ./include/linux/atomic.h:82,
                 from ./arch/parisc/include/asm/bitops.h:13,
                 from ./include/linux/bitops.h:67,
                 from ./include/linux/kernel.h:23,
                 from ./arch/parisc/include/asm/bug.h:5,
                 from ./include/linux/bug.h:5,
                 from ./include/linux/page-flags.h:10,
                 from kernel/bounds.c:10:
./include/linux/instrumented.h: In function 'instrument_atomic_alignment_check':
./include/linux/instrumented.h:69:9: error: implicit declaration of function 'WARN_ON_ONCE' [-Werror=implicit-function-declaration]
   69 |         WARN_ON_ONCE((unsigned long)v & (size - 1));
      |         ^~~~~~~~~~~~
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:182: kernel/bounds.s] Error 1

The problem is, asm/bug.h indirectly includes atomic-instrumented.h,
which means a new cycle appeared in the graph of #includes. And because
some headers in the cycle can't see all definitions, WARN_ON_ONCE()
appears to be an undeclared function.

This only happens on parisc and it's easy to fix. In the error
message above, linux/kernel.h is included by asm/bug.h. But it's no
longer needed there, so remove it.

The comment about needing BUGFLAG_TAINT seems to be incorrect as of
commit 19d436268dde ("debug: Add _ONCE() logic to report_bug()"). Also,
a comment in linux/kernel.h strongly discourages its use here.

Compile-tested only.
---
 arch/parisc/include/asm/bug.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/parisc/include/asm/bug.h b/arch/parisc/include/asm/bug.h
index 833555f74ffa..dbf65623c513 100644
--- a/arch/parisc/include/asm/bug.h
+++ b/arch/parisc/include/asm/bug.h
@@ -2,8 +2,6 @@
 #ifndef _PARISC_BUG_H
 #define _PARISC_BUG_H
 
-#include <linux/kernel.h>	/* for BUGFLAG_TAINT */
-
 /*
  * Tell the user there is some problem.
  * The offending file and line are encoded in the __bug_table section.
-- 
2.49.1


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

* Re: [RFC v4 2/5] parisc: Drop linux/kernel.h include from asm/bug.h header
  2025-10-20 22:28 ` [RFC v4 2/5] parisc: Drop linux/kernel.h include from asm/bug.h header Finn Thain
@ 2025-11-08 22:39   ` Helge Deller
  0 siblings, 0 replies; 3+ messages in thread
From: Helge Deller @ 2025-11-08 22:39 UTC (permalink / raw)
  To: Finn Thain; +Cc: linux-arch, linux-kernel, linux-m68k, linux-parisc

On 10/21/25 00:28, Finn Thain wrote:
> This patch series will add WARN_ON_ONCE() calls to the header file
> linux/instrumented.h. That requires including linux/bug.h,
> but doing so causes the following compiler error on parisc:
> 
> In file included from ./include/linux/atomic/atomic-instrumented.h:17,
>                   from ./include/linux/atomic.h:82,
>                   from ./arch/parisc/include/asm/bitops.h:13,
>                   from ./include/linux/bitops.h:67,
>                   from ./include/linux/kernel.h:23,
>                   from ./arch/parisc/include/asm/bug.h:5,
>                   from ./include/linux/bug.h:5,
>                   from ./include/linux/page-flags.h:10,
>                   from kernel/bounds.c:10:
> ./include/linux/instrumented.h: In function 'instrument_atomic_alignment_check':
> ./include/linux/instrumented.h:69:9: error: implicit declaration of function 'WARN_ON_ONCE' [-Werror=implicit-function-declaration]
>     69 |         WARN_ON_ONCE((unsigned long)v & (size - 1));
>        |         ^~~~~~~~~~~~
> cc1: some warnings being treated as errors
> make[3]: *** [scripts/Makefile.build:182: kernel/bounds.s] Error 1
> 
> The problem is, asm/bug.h indirectly includes atomic-instrumented.h,
> which means a new cycle appeared in the graph of #includes. And because
> some headers in the cycle can't see all definitions, WARN_ON_ONCE()
> appears to be an undeclared function.
> 
> This only happens on parisc and it's easy to fix. In the error
> message above, linux/kernel.h is included by asm/bug.h. But it's no
> longer needed there, so remove it.
> 
> The comment about needing BUGFLAG_TAINT seems to be incorrect as of
> commit 19d436268dde ("debug: Add _ONCE() logic to report_bug()"). Also,
> a comment in linux/kernel.h strongly discourages its use here.
> 
> Compile-tested only.
> ---
>   arch/parisc/include/asm/bug.h | 2 --
>   1 file changed, 2 deletions(-)

Acked-by: Helge Deller <deller@gmx.de> # parisc

Thanks!
Helge

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

end of thread, other threads:[~2025-11-08 22:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-20 22:28 [RFC v4 0/5] Align atomic storage Finn Thain
2025-10-20 22:28 ` [RFC v4 2/5] parisc: Drop linux/kernel.h include from asm/bug.h header Finn Thain
2025-11-08 22:39   ` Helge Deller

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