]> git.hungrycats.org Git - linux/commitdiff
include/linux/jump_label.h: expose the reference count
authorMel Gorman <mgorman@suse.de>
Thu, 28 Aug 2014 18:35:18 +0000 (19:35 +0100)
committerJiri Slaby <jslaby@suse.cz>
Fri, 26 Sep 2014 09:52:02 +0000 (11:52 +0200)
commit ea5e9539abf1258f23e725cb9cb25aa74efa29eb upstream.

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>
Signed-off-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
include/linux/jump_label.h

index a5079072da663e6b1e426504c3dfa39438e42127..9216e465289a2394c05981ab5285cf3dad8b0b81 100644 (file)
@@ -62,6 +62,10 @@ struct static_key {
 
 # include <asm/jump_label.h>
 # define HAVE_JUMP_LABEL
+#else
+struct static_key {
+       atomic_t enabled;
+};
 #endif /* CC_HAVE_ASM_GOTO && CONFIG_JUMP_LABEL */
 
 enum jump_label_type {
@@ -72,6 +76,12 @@ enum jump_label_type {
 struct module;
 
 #include <linux/atomic.h>
+
+static inline int static_key_count(struct static_key *key)
+{
+       return atomic_read(&key->enabled);
+}
+
 #ifdef HAVE_JUMP_LABEL
 
 #define JUMP_LABEL_TRUE_BRANCH 1UL
@@ -122,24 +132,20 @@ extern void jump_label_apply_nops(struct module *mod);
 
 #else  /* !HAVE_JUMP_LABEL */
 
-struct static_key {
-       atomic_t enabled;
-};
-
 static __always_inline void jump_label_init(void)
 {
 }
 
 static __always_inline bool static_key_false(struct static_key *key)
 {
-       if (unlikely(atomic_read(&key->enabled)) > 0)
+       if (unlikely(static_key_count(key) > 0))
                return true;
        return false;
 }
 
 static __always_inline bool static_key_true(struct static_key *key)
 {
-       if (likely(atomic_read(&key->enabled)) > 0)
+       if (likely(static_key_count(key) > 0))
                return true;
        return false;
 }
@@ -179,7 +185,7 @@ static inline int jump_label_apply_nops(struct module *mod)
 
 static inline bool static_key_enabled(struct static_key *key)
 {
-       return (atomic_read(&key->enabled) > 0);
+       return static_key_count(key) > 0;
 }
 
 #endif /* _LINUX_JUMP_LABEL_H */