diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-06-25 09:14:44 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-06-25 09:14:44 -0400 |
| commit | e3b22bc3d705b4a265247a9e2a1dea9ecf01a0cd (patch) | |
| tree | 834f54242f3296b5874110bbe20bde4b04f6e0fc /include/linux | |
| parent | 2de23071f5f7eb80a6cccf45438b271da81246af (diff) | |
| parent | 4c5ea0a9cd02d6aa8adc86e100b2a4cff8d614ff (diff) | |
Merge branch 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull locking fix from Thomas Gleixner:
"A single fix to address a race in the static key logic"
* 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
locking/static_key: Fix concurrent static_key_slow_inc()
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/jump_label.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index 0536524bb9eb..68904469fba1 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h | |||
| @@ -117,13 +117,18 @@ struct module; | |||
| 117 | 117 | ||
| 118 | #include <linux/atomic.h> | 118 | #include <linux/atomic.h> |
| 119 | 119 | ||
| 120 | #ifdef HAVE_JUMP_LABEL | ||
| 121 | |||
| 120 | static inline int static_key_count(struct static_key *key) | 122 | static inline int static_key_count(struct static_key *key) |
| 121 | { | 123 | { |
| 122 | return atomic_read(&key->enabled); | 124 | /* |
| 125 | * -1 means the first static_key_slow_inc() is in progress. | ||
| 126 | * static_key_enabled() must return true, so return 1 here. | ||
| 127 | */ | ||
| 128 | int n = atomic_read(&key->enabled); | ||
| 129 | return n >= 0 ? n : 1; | ||
| 123 | } | 130 | } |
| 124 | 131 | ||
| 125 | #ifdef HAVE_JUMP_LABEL | ||
| 126 | |||
| 127 | #define JUMP_TYPE_FALSE 0UL | 132 | #define JUMP_TYPE_FALSE 0UL |
| 128 | #define JUMP_TYPE_TRUE 1UL | 133 | #define JUMP_TYPE_TRUE 1UL |
| 129 | #define JUMP_TYPE_MASK 1UL | 134 | #define JUMP_TYPE_MASK 1UL |
| @@ -162,6 +167,11 @@ extern void jump_label_apply_nops(struct module *mod); | |||
| 162 | 167 | ||
| 163 | #else /* !HAVE_JUMP_LABEL */ | 168 | #else /* !HAVE_JUMP_LABEL */ |
| 164 | 169 | ||
| 170 | static inline int static_key_count(struct static_key *key) | ||
| 171 | { | ||
| 172 | return atomic_read(&key->enabled); | ||
| 173 | } | ||
| 174 | |||
| 165 | static __always_inline void jump_label_init(void) | 175 | static __always_inline void jump_label_init(void) |
| 166 | { | 176 | { |
| 167 | static_key_initialized = true; | 177 | static_key_initialized = true; |
