Skip to content

Commit ac99b86

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
jump_label: Provide jump_label_key initializers
Provide two initializers for jump_label_key that initialize it enabled or disabled. Also modify all jump_label code to allow for jump_labels to be initialized enabled. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Jason Baron <jbaron@redhat.com> Link: http://lkml.kernel.org/n/tip-p40e3yj21b68y03z1yv825e7@git.kernel.org Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 9cdbe1c commit ac99b86

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎include/linux/jump_label.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,7 @@ static inline void jump_label_rate_limit(struct jump_label_key_deferred *key,
128128
}
129129
#endif /* HAVE_JUMP_LABEL */
130130

131+
#define jump_label_key_enabled ((struct jump_label_key){ .enabled = ATOMIC_INIT(1), })
132+
#define jump_label_key_disabled ((struct jump_label_key){ .enabled = ATOMIC_INIT(0), })
133+
131134
#endif /* _LINUX_JUMP_LABEL_H */

‎kernel/jump_label.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,13 @@ void jump_label_apply_nops(struct module *mod)
248248
if (iter_start == iter_stop)
249249
return;
250250

251-
for (iter = iter_start; iter < iter_stop; iter++)
252-
arch_jump_label_transform_static(iter, JUMP_LABEL_DISABLE);
251+
for (iter = iter_start; iter < iter_stop; iter++) {
252+
struct jump_label_key *iterk;
253+
254+
iterk = (struct jump_label_key *)(unsigned long)iter->key;
255+
arch_jump_label_transform_static(iter, jump_label_enabled(iterk) ?
256+
JUMP_LABEL_ENABLE : JUMP_LABEL_DISABLE);
257+
}
253258
}
254259

255260
static int jump_label_add_module(struct module *mod)
@@ -289,8 +294,7 @@ static int jump_label_add_module(struct module *mod)
289294
key->next = jlm;
290295

291296
if (jump_label_enabled(key))
292-
__jump_label_update(key, iter, iter_stop,
293-
JUMP_LABEL_ENABLE);
297+
__jump_label_update(key, iter, iter_stop, JUMP_LABEL_ENABLE);
294298
}
295299

296300
return 0;

0 commit comments

Comments
 (0)