diff options
author | Mel Gorman <mgorman@suse.de> | 2014-06-04 19:10:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-04 19:54:08 -0400 |
commit | ea5e9539abf1258f23e725cb9cb25aa74efa29eb (patch) | |
tree | dcf19615cda8c345ef558a27a7cf593f7d4048d6 | |
parent | 800a1e750c7b04c2aa2459afca77e936e01c0029 (diff) |
include/linux/jump_label.h: expose the reference count
This patch exposes the jump_label reference count in preparation for the
next patch. cpusets cares about both the jump_label being enabled and how
many users of the cpusets there currently are.
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Jan Kara <jack@suse.cz>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/jump_label.h | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index 5c1dfb2a9e73..784304b222b3 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h | |||
@@ -69,6 +69,10 @@ struct static_key { | |||
69 | 69 | ||
70 | # include <asm/jump_label.h> | 70 | # include <asm/jump_label.h> |
71 | # define HAVE_JUMP_LABEL | 71 | # define HAVE_JUMP_LABEL |
72 | #else | ||
73 | struct static_key { | ||
74 | atomic_t enabled; | ||
75 | }; | ||
72 | #endif /* CC_HAVE_ASM_GOTO && CONFIG_JUMP_LABEL */ | 76 | #endif /* CC_HAVE_ASM_GOTO && CONFIG_JUMP_LABEL */ |
73 | 77 | ||
74 | enum jump_label_type { | 78 | enum jump_label_type { |
@@ -79,6 +83,12 @@ enum jump_label_type { | |||
79 | struct module; | 83 | struct module; |
80 | 84 | ||
81 | #include <linux/atomic.h> | 85 | #include <linux/atomic.h> |
86 | |||
87 | static inline int static_key_count(struct static_key *key) | ||
88 | { | ||
89 | return atomic_read(&key->enabled); | ||
90 | } | ||
91 | |||
82 | #ifdef HAVE_JUMP_LABEL | 92 | #ifdef HAVE_JUMP_LABEL |
83 | 93 | ||
84 | #define JUMP_LABEL_TYPE_FALSE_BRANCH 0UL | 94 | #define JUMP_LABEL_TYPE_FALSE_BRANCH 0UL |
@@ -134,10 +144,6 @@ extern void jump_label_apply_nops(struct module *mod); | |||
134 | 144 | ||
135 | #else /* !HAVE_JUMP_LABEL */ | 145 | #else /* !HAVE_JUMP_LABEL */ |
136 | 146 | ||
137 | struct static_key { | ||
138 | atomic_t enabled; | ||
139 | }; | ||
140 | |||
141 | static __always_inline void jump_label_init(void) | 147 | static __always_inline void jump_label_init(void) |
142 | { | 148 | { |
143 | static_key_initialized = true; | 149 | static_key_initialized = true; |
@@ -145,14 +151,14 @@ static __always_inline void jump_label_init(void) | |||
145 | 151 | ||
146 | static __always_inline bool static_key_false(struct static_key *key) | 152 | static __always_inline bool static_key_false(struct static_key *key) |
147 | { | 153 | { |
148 | if (unlikely(atomic_read(&key->enabled) > 0)) | 154 | if (unlikely(static_key_count(key) > 0)) |
149 | return true; | 155 | return true; |
150 | return false; | 156 | return false; |
151 | } | 157 | } |
152 | 158 | ||
153 | static __always_inline bool static_key_true(struct static_key *key) | 159 | static __always_inline bool static_key_true(struct static_key *key) |
154 | { | 160 | { |
155 | if (likely(atomic_read(&key->enabled) > 0)) | 161 | if (likely(static_key_count(key) > 0)) |
156 | return true; | 162 | return true; |
157 | return false; | 163 | return false; |
158 | } | 164 | } |
@@ -194,7 +200,7 @@ static inline int jump_label_apply_nops(struct module *mod) | |||
194 | 200 | ||
195 | static inline bool static_key_enabled(struct static_key *key) | 201 | static inline bool static_key_enabled(struct static_key *key) |
196 | { | 202 | { |
197 | return (atomic_read(&key->enabled) > 0); | 203 | return static_key_count(key) > 0; |
198 | } | 204 | } |
199 | 205 | ||
200 | #endif /* _LINUX_JUMP_LABEL_H */ | 206 | #endif /* _LINUX_JUMP_LABEL_H */ |