diff options
| author | Peter Zijlstra <peterz@infradead.org> | 2015-07-24 15:03:40 +0200 |
|---|---|---|
| committer | Moyster <oysterized@gmail.com> | 2017-06-17 15:53:29 +0200 |
| commit | 3e051796ba490a350c4a9ff127eb5e1a0fbee733 (patch) | |
| tree | 3c6781eea340e270ebb8743aeb2ed2c4dc12465f /include | |
| parent | 98f964ef27281880c8aee92be338c909e642434b (diff) | |
locking/static_keys: Add static_key_{en,dis}able() helpers
commit e33886b38cc82a9fc3b2d655dfc7f50467594138 upstream.
Add two helpers to make it easier to treat the refcount as boolean.
[js] do not involve WARN_ON_ONCE as it causes build failures
Suggested-by: Jason Baron <jasonbaron0@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
[wt: only backported for use in next fix ;
s/static_key_count(key)/atomic_read(&key->enabled)/]
Signed-off-by: Willy Tarreau <w@1wt.eu>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/jump_label.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index 0976fc46d..7f831b28e 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -208,4 +208,20 @@ static inline bool static_key_enabled(struct static_key *key) return (atomic_read(&key->enabled) > 0); } +static inline void static_key_enable(struct static_key *key) +{ + int count = atomic_read(&key->enabled); + + if (!count) + static_key_slow_inc(key); +} + +static inline void static_key_disable(struct static_key *key) +{ + int count = atomic_read(&key->enabled); + + if (count) + static_key_slow_dec(key); +} + #endif /* _LINUX_JUMP_LABEL_H */ |
