Blame view
include/linux/jump_label.h
3.13 KB
bf5438fca jump label: Base ... |
1 2 |
#ifndef _LINUX_JUMP_LABEL_H #define _LINUX_JUMP_LABEL_H |
d430d3d7e jump label: Intro... |
3 4 |
#include <linux/types.h> #include <linux/compiler.h> |
b20295207 perf, core: Rate ... |
5 |
#include <linux/workqueue.h> |
d430d3d7e jump label: Intro... |
6 |
|
45f81b1c9 jump label: Add w... |
7 |
#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL) |
d430d3d7e jump label: Intro... |
8 9 10 11 12 13 14 15 |
struct jump_label_key { atomic_t enabled; struct jump_entry *entries; #ifdef CONFIG_MODULES struct jump_label_mod *next; #endif }; |
b20295207 perf, core: Rate ... |
16 17 18 19 20 |
struct jump_label_key_deferred { struct jump_label_key key; unsigned long timeout; struct delayed_work work; }; |
bf5438fca jump label: Base ... |
21 22 |
# include <asm/jump_label.h> # define HAVE_JUMP_LABEL |
97ce2c88f jump-label: initi... |
23 |
#endif /* CC_HAVE_ASM_GOTO && CONFIG_JUMP_LABEL */ |
bf5438fca jump label: Base ... |
24 25 |
enum jump_label_type { |
d430d3d7e jump label: Intro... |
26 |
JUMP_LABEL_DISABLE = 0, |
bf5438fca jump label: Base ... |
27 |
JUMP_LABEL_ENABLE, |
bf5438fca jump label: Base ... |
28 29 30 31 32 |
}; struct module; #ifdef HAVE_JUMP_LABEL |
d430d3d7e jump label: Intro... |
33 |
#ifdef CONFIG_MODULES |
d5d9a3b12 jump_label: use p... |
34 |
#define JUMP_LABEL_INIT {ATOMIC_INIT(0), NULL, NULL} |
d430d3d7e jump label: Intro... |
35 |
#else |
d5d9a3b12 jump_label: use p... |
36 |
#define JUMP_LABEL_INIT {ATOMIC_INIT(0), NULL} |
d430d3d7e jump label: Intro... |
37 38 39 40 41 42 |
#endif static __always_inline bool static_branch(struct jump_label_key *key) { return arch_static_branch(key); } |
bf5438fca jump label: Base ... |
43 44 |
extern struct jump_entry __start___jump_table[]; extern struct jump_entry __stop___jump_table[]; |
97ce2c88f jump-label: initi... |
45 |
extern void jump_label_init(void); |
91bad2f8d jump label: Fix d... |
46 47 |
extern void jump_label_lock(void); extern void jump_label_unlock(void); |
bf5438fca jump label: Base ... |
48 |
extern void arch_jump_label_transform(struct jump_entry *entry, |
37348804e jump_label: if a ... |
49 |
enum jump_label_type type); |
20284aa77 jump_label: add a... |
50 51 |
extern void arch_jump_label_transform_static(struct jump_entry *entry, enum jump_label_type type); |
4c3ef6d79 jump label: Add j... |
52 |
extern int jump_label_text_reserved(void *start, void *end); |
d430d3d7e jump label: Intro... |
53 54 |
extern void jump_label_inc(struct jump_label_key *key); extern void jump_label_dec(struct jump_label_key *key); |
b20295207 perf, core: Rate ... |
55 |
extern void jump_label_dec_deferred(struct jump_label_key_deferred *key); |
d430d3d7e jump label: Intro... |
56 57 |
extern bool jump_label_enabled(struct jump_label_key *key); extern void jump_label_apply_nops(struct module *mod); |
b20295207 perf, core: Rate ... |
58 59 |
extern void jump_label_rate_limit(struct jump_label_key_deferred *key, unsigned long rl); |
bf5438fca jump label: Base ... |
60 |
|
97ce2c88f jump-label: initi... |
61 |
#else /* !HAVE_JUMP_LABEL */ |
bf5438fca jump label: Base ... |
62 |
|
60063497a atomic: use <linu... |
63 |
#include <linux/atomic.h> |
bf5438fca jump label: Base ... |
64 |
|
d430d3d7e jump label: Intro... |
65 |
#define JUMP_LABEL_INIT {ATOMIC_INIT(0)} |
bf5438fca jump label: Base ... |
66 |
|
d430d3d7e jump label: Intro... |
67 68 69 |
struct jump_label_key { atomic_t enabled; }; |
bf5438fca jump label: Base ... |
70 |
|
97ce2c88f jump-label: initi... |
71 72 73 |
static __always_inline void jump_label_init(void) { } |
b20295207 perf, core: Rate ... |
74 75 76 |
struct jump_label_key_deferred { struct jump_label_key key; }; |
d430d3d7e jump label: Intro... |
77 78 79 80 81 82 |
static __always_inline bool static_branch(struct jump_label_key *key) { if (unlikely(atomic_read(&key->enabled))) return true; return false; } |
bf5438fca jump label: Base ... |
83 |
|
d430d3d7e jump label: Intro... |
84 85 86 87 |
static inline void jump_label_inc(struct jump_label_key *key) { atomic_inc(&key->enabled); } |
bf5438fca jump label: Base ... |
88 |
|
d430d3d7e jump label: Intro... |
89 |
static inline void jump_label_dec(struct jump_label_key *key) |
bf5438fca jump label: Base ... |
90 |
{ |
d430d3d7e jump label: Intro... |
91 |
atomic_dec(&key->enabled); |
bf5438fca jump label: Base ... |
92 |
} |
b20295207 perf, core: Rate ... |
93 94 95 96 |
static inline void jump_label_dec_deferred(struct jump_label_key_deferred *key) { jump_label_dec(&key->key); } |
4c3ef6d79 jump label: Add j... |
97 98 99 100 |
static inline int jump_label_text_reserved(void *start, void *end) { return 0; } |
91bad2f8d jump label: Fix d... |
101 102 |
static inline void jump_label_lock(void) {} static inline void jump_label_unlock(void) {} |
d430d3d7e jump label: Intro... |
103 104 105 106 |
static inline bool jump_label_enabled(struct jump_label_key *key) { return !!atomic_read(&key->enabled); } |
bf5438fca jump label: Base ... |
107 |
|
d430d3d7e jump label: Intro... |
108 109 110 111 |
static inline int jump_label_apply_nops(struct module *mod) { return 0; } |
b20295207 perf, core: Rate ... |
112 113 114 115 116 |
static inline void jump_label_rate_limit(struct jump_label_key_deferred *key, unsigned long rl) { } |
97ce2c88f jump-label: initi... |
117 |
#endif /* HAVE_JUMP_LABEL */ |
d430d3d7e jump label: Intro... |
118 |
|
ac99b862f jump_label: Provi... |
119 120 |
#define jump_label_key_enabled ((struct jump_label_key){ .enabled = ATOMIC_INIT(1), }) #define jump_label_key_disabled ((struct jump_label_key){ .enabled = ATOMIC_INIT(0), }) |
97ce2c88f jump-label: initi... |
121 |
#endif /* _LINUX_JUMP_LABEL_H */ |