Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

atomic: add option for weaker alignment check

Add a new Kconfig symbol to make CONFIG_DEBUG_ATOMIC more useful on those
architectures which do not align dynamic allocations to 8-byte boundaries.
Without this, CONFIG_DEBUG_ATOMIC produces excessive WARN splats.

Link: https://lkml.kernel.org/r/6d25a12934fe9199332f4d65d17c17de450139a8.1768281748.git.fthain@linux-m68k.org
Signed-off-by: Finn Thain <fthain@linux-m68k.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: "Borislav Petkov (AMD)" <bp@alien8.de>
Cc: Daniel Borkman <daniel@iogearbox.net>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Dinh Nguyen <dinguyen@kernel.org>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Gary Guo <gary@garyguo.net>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Hao Luo <haoluo@google.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: KP Singh <kpsingh@kernel.org>
Cc: Marc Rutland <mark.rutland@arm.com>
Cc: Martin KaFai Lau <martin.lau@linux.dev>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rich Felker <dalias@libc.org>
Cc: Sasha Levin (Microsoft) <sashal@kernel.org>
Cc: Song Liu <song@kernel.org>
Cc: Stafford Horne <shorne@gmail.com>
Cc: Stanislav Fomichev <sdf@fomichev.me>
Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will@kernel.org>
Cc: Yonghong Song <yonghong.song@linux.dev>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Finn Thain and committed by
Andrew Morton
9a229ae2 80047d84

+15 -1
+7 -1
include/linux/instrumented.h
··· 59 59 static __always_inline void instrument_atomic_check_alignment(const volatile void *v, size_t size) 60 60 { 61 61 #ifndef __DISABLE_EXPORTS 62 - WARN_ON_ONCE(IS_ENABLED(CONFIG_DEBUG_ATOMIC) && ((unsigned long)v & (size - 1))); 62 + if (IS_ENABLED(CONFIG_DEBUG_ATOMIC)) { 63 + unsigned int mask = size - 1; 64 + 65 + if (IS_ENABLED(CONFIG_DEBUG_ATOMIC_LARGEST_ALIGN)) 66 + mask &= sizeof(struct { long x; } __aligned_largest) - 1; 67 + WARN_ON_ONCE((unsigned long)v & mask); 68 + } 63 69 #endif 64 70 } 65 71
+8
lib/Kconfig.debug
··· 1370 1370 1371 1371 This option has potentially significant overhead. 1372 1372 1373 + config DEBUG_ATOMIC_LARGEST_ALIGN 1374 + bool "Check alignment only up to __aligned_largest" 1375 + depends on DEBUG_ATOMIC 1376 + help 1377 + If you say Y here then the check for natural alignment of 1378 + atomic accesses will be constrained to the compiler's largest 1379 + alignment for scalar types. 1380 + 1373 1381 menu "Lock Debugging (spinlocks, mutexes, etc...)" 1374 1382 1375 1383 config LOCK_DEBUGGING_SUPPORT