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.

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

authored by

Thomas Weißschuh and committed by
Peter Zijlstra
428c5652 16df0444

+2 -18
+2 -9
include/linux/jump_label.h
··· 238 238 extern void static_key_disable_cpuslocked(struct static_key *key); 239 239 extern enum jump_label_type jump_label_init_type(struct jump_entry *entry); 240 240 241 - /* 242 - * We should be using ATOMIC_INIT() for initializing .enabled, but 243 - * the inclusion of atomic.h is problematic for inclusion of jump_label.h 244 - * in 'low-level' headers. Thus, we are initializing .enabled with a 245 - * raw value, but have added a BUILD_BUG_ON() to catch any issues in 246 - * jump_label_init() see: kernel/jump_label.c. 247 - */ 248 241 #define STATIC_KEY_INIT_TRUE \ 249 - { .enabled = { 1 }, \ 242 + { .enabled = ATOMIC_INIT(1), \ 250 243 { .type = JUMP_TYPE_TRUE } } 251 244 #define STATIC_KEY_INIT_FALSE \ 252 - { .enabled = { 0 }, \ 245 + { .enabled = ATOMIC_INIT(0), \ 253 246 { .type = JUMP_TYPE_FALSE } } 254 247 255 248 #else /* !CONFIG_JUMP_LABEL */
-9
kernel/jump_label.c
··· 529 529 struct static_key *key = NULL; 530 530 struct jump_entry *iter; 531 531 532 - /* 533 - * Since we are initializing the static_key.enabled field with 534 - * with the 'raw' int values (to avoid pulling in atomic.h) in 535 - * jump_label.h, let's make sure that is safe. There are only two 536 - * cases to check since we initialize to 0 or 1. 537 - */ 538 - BUILD_BUG_ON((int)ATOMIC_INIT(0) != 0); 539 - BUILD_BUG_ON((int)ATOMIC_INIT(1) != 1); 540 - 541 532 if (static_key_initialized) 542 533 return; 543 534