* [PATCH v2 0/2] jump_label: drop some workarounds in static key initialization
@ 2026-03-13 8:22 Thomas Weißschuh
2026-03-13 8:22 ` [PATCH v2 1/2] jump_label: use ATOMIC_INIT() for initialization of .enabled Thomas Weißschuh
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Thomas Weißschuh @ 2026-03-13 8:22 UTC (permalink / raw)
To: Peter Zijlstra, Josh Poimboeuf, Jason Baron, Steven Rostedt,
Ard Biesheuvel, Alice Ryhl
Cc: linux-kernel, Thomas Weißschuh
These workarounds are not necessary anymore so remove them.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
Changes in v2:
- Rebase on v7.0-rc1.
- Link to v1: https://lore.kernel.org/r/20251118-jump_label-cleanup-v1-0-440a424d7282@linutronix.de
---
Thomas Weißschuh (2):
jump_label: use ATOMIC_INIT() for initialization of .enabled
jump_label: remove workaround for old compilers in initializations
include/linux/jump_label.h | 22 ++++------------------
kernel/jump_label.c | 9 ---------
2 files changed, 4 insertions(+), 27 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251110-jump_label-cleanup-d7036bd1e533
Best regards,
--
Thomas Weißschuh <thomas.weissschuh@linutronix.de>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] jump_label: use ATOMIC_INIT() for initialization of .enabled
2026-03-13 8:22 [PATCH v2 0/2] jump_label: drop some workarounds in static key initialization Thomas Weißschuh
@ 2026-03-13 8:22 ` Thomas Weißschuh
2026-03-18 8:02 ` [tip: locking/core] " tip-bot2 for Thomas Weißschuh
2026-03-13 8:22 ` [PATCH v2 2/2] jump_label: remove workaround for old compilers in initializations Thomas Weißschuh
2026-03-13 8:35 ` [PATCH v2 0/2] jump_label: drop some workarounds in static key initialization Peter Zijlstra
2 siblings, 1 reply; 6+ messages in thread
From: Thomas Weißschuh @ 2026-03-13 8:22 UTC (permalink / raw)
To: Peter Zijlstra, Josh Poimboeuf, Jason Baron, Steven Rostedt,
Ard Biesheuvel, Alice Ryhl
Cc: linux-kernel, Thomas Weißschuh
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@linutronix.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 fdb79dd1ebd8..e494b360d36d 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 7cb19e601426..e851e4b37d0e 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.53.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] jump_label: remove workaround for old compilers in initializations
2026-03-13 8:22 [PATCH v2 0/2] jump_label: drop some workarounds in static key initialization Thomas Weißschuh
2026-03-13 8:22 ` [PATCH v2 1/2] jump_label: use ATOMIC_INIT() for initialization of .enabled Thomas Weißschuh
@ 2026-03-13 8:22 ` Thomas Weißschuh
2026-03-18 8:02 ` [tip: locking/core] " tip-bot2 for Thomas Weißschuh
2026-03-13 8:35 ` [PATCH v2 0/2] jump_label: drop some workarounds in static key initialization Peter Zijlstra
2 siblings, 1 reply; 6+ messages in thread
From: Thomas Weißschuh @ 2026-03-13 8:22 UTC (permalink / raw)
To: Peter Zijlstra, Josh Poimboeuf, Jason Baron, Steven Rostedt,
Ard Biesheuvel, Alice Ryhl
Cc: linux-kernel, Thomas Weißschuh
The extra braces for the initialization of the anonymous union members
were added in commit cd8d860dcce9 ("jump_label: Fix anonymous union
initialization") to compensate for limitations in gcc < 4.6.
Versions of gcc this old are not supported anymore,
so drop the workaround.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
include/linux/jump_label.h | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index e494b360d36d..b9c7b0ebf7b9 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -87,13 +87,6 @@ struct static_key {
atomic_t enabled;
#ifdef CONFIG_JUMP_LABEL
/*
- * Note:
- * To make anonymous unions work with old compilers, the static
- * initialization of them requires brackets. This creates a dependency
- * on the order of the struct with the initializers. If any fields
- * are added, STATIC_KEY_INIT_TRUE and STATIC_KEY_INIT_FALSE may need
- * to be modified.
- *
* bit 0 => 1 if key is initially true
* 0 if initially false
* bit 1 => 1 if points to struct static_key_mod
@@ -240,10 +233,10 @@ extern enum jump_label_type jump_label_init_type(struct jump_entry *entry);
#define STATIC_KEY_INIT_TRUE \
{ .enabled = ATOMIC_INIT(1), \
- { .type = JUMP_TYPE_TRUE } }
+ .type = JUMP_TYPE_TRUE }
#define STATIC_KEY_INIT_FALSE \
{ .enabled = ATOMIC_INIT(0), \
- { .type = JUMP_TYPE_FALSE } }
+ .type = JUMP_TYPE_FALSE }
#else /* !CONFIG_JUMP_LABEL */
--
2.53.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/2] jump_label: drop some workarounds in static key initialization
2026-03-13 8:22 [PATCH v2 0/2] jump_label: drop some workarounds in static key initialization Thomas Weißschuh
2026-03-13 8:22 ` [PATCH v2 1/2] jump_label: use ATOMIC_INIT() for initialization of .enabled Thomas Weißschuh
2026-03-13 8:22 ` [PATCH v2 2/2] jump_label: remove workaround for old compilers in initializations Thomas Weißschuh
@ 2026-03-13 8:35 ` Peter Zijlstra
2 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2026-03-13 8:35 UTC (permalink / raw)
To: Thomas Weißschuh
Cc: Josh Poimboeuf, Jason Baron, Steven Rostedt, Ard Biesheuvel,
Alice Ryhl, linux-kernel
On Fri, Mar 13, 2026 at 09:22:17AM +0100, Thomas Weißschuh wrote:
> These workarounds are not necessary anymore so remove them.
> Thomas Weißschuh (2):
> jump_label: use ATOMIC_INIT() for initialization of .enabled
> jump_label: remove workaround for old compilers in initializations
Excellent, thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
* [tip: locking/core] jump_label: remove workaround for old compilers in initializations
2026-03-13 8:22 ` [PATCH v2 2/2] jump_label: remove workaround for old compilers in initializations Thomas Weißschuh
@ 2026-03-18 8:02 ` tip-bot2 for Thomas Weißschuh
0 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Thomas Weißschuh @ 2026-03-18 8:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: thomas.weissschuh, Peter Zijlstra (Intel), x86, linux-kernel
The following commit has been merged into the locking/core branch of tip:
Commit-ID: acb38872d4cbec5b6825345d9d757e21d2d9d953
Gitweb: https://git.kernel.org/tip/acb38872d4cbec5b6825345d9d757e21d2d9d953
Author: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
AuthorDate: Fri, 13 Mar 2026 09:22:19 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 16 Mar 2026 13:16:49 +01:00
jump_label: remove workaround for old compilers in initializations
The extra braces for the initialization of the anonymous union members
were added in commit cd8d860dcce9 ("jump_label: Fix anonymous union
initialization") to compensate for limitations in gcc < 4.6.
Versions of gcc this old are not supported anymore,
so drop the workaround.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260313-jump_label-cleanup-v2-2-35d3c0bde549@linutronix.de
---
include/linux/jump_label.h | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index e494b36..b9c7b0e 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -87,13 +87,6 @@ struct static_key {
atomic_t enabled;
#ifdef CONFIG_JUMP_LABEL
/*
- * Note:
- * To make anonymous unions work with old compilers, the static
- * initialization of them requires brackets. This creates a dependency
- * on the order of the struct with the initializers. If any fields
- * are added, STATIC_KEY_INIT_TRUE and STATIC_KEY_INIT_FALSE may need
- * to be modified.
- *
* bit 0 => 1 if key is initially true
* 0 if initially false
* bit 1 => 1 if points to struct static_key_mod
@@ -240,10 +233,10 @@ extern enum jump_label_type jump_label_init_type(struct jump_entry *entry);
#define STATIC_KEY_INIT_TRUE \
{ .enabled = ATOMIC_INIT(1), \
- { .type = JUMP_TYPE_TRUE } }
+ .type = JUMP_TYPE_TRUE }
#define STATIC_KEY_INIT_FALSE \
{ .enabled = ATOMIC_INIT(0), \
- { .type = JUMP_TYPE_FALSE } }
+ .type = JUMP_TYPE_FALSE }
#else /* !CONFIG_JUMP_LABEL */
^ permalink raw reply [flat|nested] 6+ messages in thread
* [tip: locking/core] jump_label: use ATOMIC_INIT() for initialization of .enabled
2026-03-13 8:22 ` [PATCH v2 1/2] jump_label: use ATOMIC_INIT() for initialization of .enabled Thomas Weißschuh
@ 2026-03-18 8:02 ` tip-bot2 for Thomas Weißschuh
0 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Thomas Weißschuh @ 2026-03-18 8:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: thomas.weissschuh, Peter Zijlstra (Intel), x86, linux-kernel
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 428c56525bf5dbc3bd5e30014df1f5213f8bd7c8
Gitweb: https://git.kernel.org/tip/428c56525bf5dbc3bd5e30014df1f5213f8bd7c8
Author: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
AuthorDate: Fri, 13 Mar 2026 09:22:18 +01:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Mon, 16 Mar 2026 13:16:48 +01:00
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@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260313-jump_label-cleanup-v2-1-35d3c0bde549@linutronix.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 fdb79dd..e494b36 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 7cb19e6..e851e4b 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;
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-03-18 8:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-13 8:22 [PATCH v2 0/2] jump_label: drop some workarounds in static key initialization Thomas Weißschuh
2026-03-13 8:22 ` [PATCH v2 1/2] jump_label: use ATOMIC_INIT() for initialization of .enabled Thomas Weißschuh
2026-03-18 8:02 ` [tip: locking/core] " tip-bot2 for Thomas Weißschuh
2026-03-13 8:22 ` [PATCH v2 2/2] jump_label: remove workaround for old compilers in initializations Thomas Weißschuh
2026-03-18 8:02 ` [tip: locking/core] " tip-bot2 for Thomas Weißschuh
2026-03-13 8:35 ` [PATCH v2 0/2] jump_label: drop some workarounds in static key initialization Peter Zijlstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®