Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Mel Gorman and committed by
Linus Torvalds
ea5e9539 800a1e75

+13 -7
+13 -7
include/linux/jump_label.h
··· 69 69 70 70 # include <asm/jump_label.h> 71 71 # define HAVE_JUMP_LABEL 72 + #else 73 + struct static_key { 74 + atomic_t enabled; 75 + }; 72 76 #endif /* CC_HAVE_ASM_GOTO && CONFIG_JUMP_LABEL */ 73 77 74 78 enum jump_label_type { ··· 83 79 struct module; 84 80 85 81 #include <linux/atomic.h> 82 + 83 + static inline int static_key_count(struct static_key *key) 84 + { 85 + return atomic_read(&key->enabled); 86 + } 87 + 86 88 #ifdef HAVE_JUMP_LABEL 87 89 88 90 #define JUMP_LABEL_TYPE_FALSE_BRANCH 0UL ··· 144 134 145 135 #else /* !HAVE_JUMP_LABEL */ 146 136 147 - struct static_key { 148 - atomic_t enabled; 149 - }; 150 - 151 137 static __always_inline void jump_label_init(void) 152 138 { 153 139 static_key_initialized = true; ··· 151 145 152 146 static __always_inline bool static_key_false(struct static_key *key) 153 147 { 154 - if (unlikely(atomic_read(&key->enabled) > 0)) 148 + if (unlikely(static_key_count(key) > 0)) 155 149 return true; 156 150 return false; 157 151 } 158 152 159 153 static __always_inline bool static_key_true(struct static_key *key) 160 154 { 161 - if (likely(atomic_read(&key->enabled) > 0)) 155 + if (likely(static_key_count(key) > 0)) 162 156 return true; 163 157 return false; 164 158 } ··· 200 194 201 195 static inline bool static_key_enabled(struct static_key *key) 202 196 { 203 - return (atomic_read(&key->enabled) > 0); 197 + return static_key_count(key) > 0; 204 198 } 205 199 206 200 #endif /* _LINUX_JUMP_LABEL_H */