diff options
| author | Peter Zijlstra <peterz@infradead.org> | 2015-07-24 15:03:40 +0200 |
|---|---|---|
| committer | Willy Tarreau <w@1wt.eu> | 2017-06-08 00:47:03 +0200 |
| commit | 12f1a0f987bec98b105f24225691ab1ea7c77477 (patch) | |
| tree | 43bc46b8dfab99b2331c3ac4019b2cb752084a30 /include | |
| parent | 7c72e8511794214929517c3742c63d8193a59905 (diff) | |
| download | linux-12f1a0f987bec98b105f24225691ab1ea7c77477.tar.gz linux-12f1a0f987bec98b105f24225691ab1ea7c77477.tar.bz2 linux-12f1a0f987bec98b105f24225691ab1ea7c77477.zip | |
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 0976fc46d1e0..7f831b28ee68 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 */ |
