[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20251118-jump_label-cleanup-v1-1-440a424d7282@linutronix.de>
Date: Tue, 18 Nov 2025 08:34:01 +0100
From: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
To: Peter Zijlstra <peterz@...radead.org>,
Josh Poimboeuf <jpoimboe@...nel.org>, Jason Baron <jbaron@...mai.com>,
Steven Rostedt <rostedt@...dmis.org>, Ard Biesheuvel <ardb@...nel.org>
Cc: linux-kernel@...r.kernel.org,
Thomas Weißschuh <thomas.weissschuh@...utronix.de>
Subject: [PATCH 1/2] jump_label: use ATOMIC_INIT() for initialization of
.enabled
Currently ATOMIC_INIT() is not used because in the past that macro was
provided by linux/atomic.h which is not usable from linux/jump_label.h.
However since commit 7ca8cf5347f7 ("locking/atomic: Move ATOMIC_INIT
into linux/types.h") the macro only requires linux/types.h.
Remove the now unnecessary workaround and the associated assertions.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
---
include/linux/jump_label.h | 11 ++---------
kernel/jump_label.c | 9 ---------
2 files changed, 2 insertions(+), 18 deletions(-)
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index fdb79dd1ebd8c4e79bc03068393fed27ca8a6e05..e494b360d36da49ac4ce1cb3a32d50c34e2e3e42 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -238,18 +238,11 @@ extern void static_key_enable_cpuslocked(struct static_key *key);
extern void static_key_disable_cpuslocked(struct static_key *key);
extern enum jump_label_type jump_label_init_type(struct jump_entry *entry);
-/*
- * We should be using ATOMIC_INIT() for initializing .enabled, but
- * the inclusion of atomic.h is problematic for inclusion of jump_label.h
- * in 'low-level' headers. Thus, we are initializing .enabled with a
- * raw value, but have added a BUILD_BUG_ON() to catch any issues in
- * jump_label_init() see: kernel/jump_label.c.
- */
#define STATIC_KEY_INIT_TRUE \
- { .enabled = { 1 }, \
+ { .enabled = ATOMIC_INIT(1), \
{ .type = JUMP_TYPE_TRUE } }
#define STATIC_KEY_INIT_FALSE \
- { .enabled = { 0 }, \
+ { .enabled = ATOMIC_INIT(0), \
{ .type = JUMP_TYPE_FALSE } }
#else /* !CONFIG_JUMP_LABEL */
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 7cb19e6014266adb2d38d49ad0806766895c58b0..e851e4b37d0efcfc97eac5a81d1987ed32922b91 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -529,15 +529,6 @@ void __init jump_label_init(void)
struct static_key *key = NULL;
struct jump_entry *iter;
- /*
- * Since we are initializing the static_key.enabled field with
- * with the 'raw' int values (to avoid pulling in atomic.h) in
- * jump_label.h, let's make sure that is safe. There are only two
- * cases to check since we initialize to 0 or 1.
- */
- BUILD_BUG_ON((int)ATOMIC_INIT(0) != 0);
- BUILD_BUG_ON((int)ATOMIC_INIT(1) != 1);
-
if (static_key_initialized)
return;
--
2.51.0
Powered by blists - more mailing lists