diff options
Diffstat (limited to 'include/linux/jump_label.h')
| -rw-r--r-- | include/linux/jump_label.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index 388b0d425b50..5ce8b140428f 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | 3 | ||
| 4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
| 5 | #include <linux/compiler.h> | 5 | #include <linux/compiler.h> |
| 6 | #include <linux/workqueue.h> | ||
| 6 | 7 | ||
| 7 | #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL) | 8 | #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL) |
| 8 | 9 | ||
| @@ -14,6 +15,12 @@ struct jump_label_key { | |||
| 14 | #endif | 15 | #endif |
| 15 | }; | 16 | }; |
| 16 | 17 | ||
| 18 | struct jump_label_key_deferred { | ||
| 19 | struct jump_label_key key; | ||
| 20 | unsigned long timeout; | ||
| 21 | struct delayed_work work; | ||
| 22 | }; | ||
| 23 | |||
| 17 | # include <asm/jump_label.h> | 24 | # include <asm/jump_label.h> |
| 18 | # define HAVE_JUMP_LABEL | 25 | # define HAVE_JUMP_LABEL |
| 19 | #endif /* CC_HAVE_ASM_GOTO && CONFIG_JUMP_LABEL */ | 26 | #endif /* CC_HAVE_ASM_GOTO && CONFIG_JUMP_LABEL */ |
| @@ -51,8 +58,11 @@ extern void arch_jump_label_transform_static(struct jump_entry *entry, | |||
| 51 | extern int jump_label_text_reserved(void *start, void *end); | 58 | extern int jump_label_text_reserved(void *start, void *end); |
| 52 | extern void jump_label_inc(struct jump_label_key *key); | 59 | extern void jump_label_inc(struct jump_label_key *key); |
| 53 | extern void jump_label_dec(struct jump_label_key *key); | 60 | extern void jump_label_dec(struct jump_label_key *key); |
| 61 | extern void jump_label_dec_deferred(struct jump_label_key_deferred *key); | ||
| 54 | extern bool jump_label_enabled(struct jump_label_key *key); | 62 | extern bool jump_label_enabled(struct jump_label_key *key); |
| 55 | extern void jump_label_apply_nops(struct module *mod); | 63 | extern void jump_label_apply_nops(struct module *mod); |
| 64 | extern void jump_label_rate_limit(struct jump_label_key_deferred *key, | ||
| 65 | unsigned long rl); | ||
| 56 | 66 | ||
| 57 | #else /* !HAVE_JUMP_LABEL */ | 67 | #else /* !HAVE_JUMP_LABEL */ |
| 58 | 68 | ||
| @@ -68,6 +78,10 @@ static __always_inline void jump_label_init(void) | |||
| 68 | { | 78 | { |
| 69 | } | 79 | } |
| 70 | 80 | ||
| 81 | struct jump_label_key_deferred { | ||
| 82 | struct jump_label_key key; | ||
| 83 | }; | ||
| 84 | |||
| 71 | static __always_inline bool static_branch(struct jump_label_key *key) | 85 | static __always_inline bool static_branch(struct jump_label_key *key) |
| 72 | { | 86 | { |
| 73 | if (unlikely(atomic_read(&key->enabled))) | 87 | if (unlikely(atomic_read(&key->enabled))) |
| @@ -85,6 +99,11 @@ static inline void jump_label_dec(struct jump_label_key *key) | |||
| 85 | atomic_dec(&key->enabled); | 99 | atomic_dec(&key->enabled); |
| 86 | } | 100 | } |
| 87 | 101 | ||
| 102 | static inline void jump_label_dec_deferred(struct jump_label_key_deferred *key) | ||
| 103 | { | ||
| 104 | jump_label_dec(&key->key); | ||
| 105 | } | ||
| 106 | |||
| 88 | static inline int jump_label_text_reserved(void *start, void *end) | 107 | static inline int jump_label_text_reserved(void *start, void *end) |
| 89 | { | 108 | { |
| 90 | return 0; | 109 | return 0; |
| @@ -102,6 +121,14 @@ static inline int jump_label_apply_nops(struct module *mod) | |||
| 102 | { | 121 | { |
| 103 | return 0; | 122 | return 0; |
| 104 | } | 123 | } |
| 124 | |||
| 125 | static inline void jump_label_rate_limit(struct jump_label_key_deferred *key, | ||
| 126 | unsigned long rl) | ||
| 127 | { | ||
| 128 | } | ||
| 105 | #endif /* HAVE_JUMP_LABEL */ | 129 | #endif /* HAVE_JUMP_LABEL */ |
| 106 | 130 | ||
| 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 | |||
| 107 | #endif /* _LINUX_JUMP_LABEL_H */ | 134 | #endif /* _LINUX_JUMP_LABEL_H */ |
