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

jump_label: Free jump_entry::key bit1 for build use

Have jump_label_init() set jump_entry::key bit1 to either 0 ot 1
unconditionally. This makes it available for build-time games.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20210506194157.906893264@infradead.org

authored by

Peter Zijlstra and committed by
Ingo Molnar
5af0ea29 001951be

+11 -6
+5 -2
include/linux/jump_label.h
··· 171 171 return (unsigned long)entry->key & 2UL; 172 172 } 173 173 174 - static inline void jump_entry_set_init(struct jump_entry *entry) 174 + static inline void jump_entry_set_init(struct jump_entry *entry, bool set) 175 175 { 176 - entry->key |= 2; 176 + if (set) 177 + entry->key |= 2; 178 + else 179 + entry->key &= ~2; 177 180 } 178 181 179 182 static inline int jump_entry_size(struct jump_entry *entry)
+6 -4
kernel/jump_label.c
··· 483 483 484 484 for (iter = iter_start; iter < iter_stop; iter++) { 485 485 struct static_key *iterk; 486 + bool in_init; 486 487 487 488 /* rewrite NOPs */ 488 489 if (jump_label_type(iter) == JUMP_LABEL_NOP) 489 490 arch_jump_label_transform_static(iter, JUMP_LABEL_NOP); 490 491 491 - if (init_section_contains((void *)jump_entry_code(iter), 1)) 492 - jump_entry_set_init(iter); 492 + in_init = init_section_contains((void *)jump_entry_code(iter), 1); 493 + jump_entry_set_init(iter, in_init); 493 494 494 495 iterk = jump_entry_key(iter); 495 496 if (iterk == key) ··· 635 634 636 635 for (iter = iter_start; iter < iter_stop; iter++) { 637 636 struct static_key *iterk; 637 + bool in_init; 638 638 639 - if (within_module_init(jump_entry_code(iter), mod)) 640 - jump_entry_set_init(iter); 639 + in_init = within_module_init(jump_entry_code(iter), mod); 640 + jump_entry_set_init(iter, in_init); 641 641 642 642 iterk = jump_entry_key(iter); 643 643 if (iterk == key)