[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-b92e793bbe4a1c49dbf78d8d526561e7a7dd568a@git.kernel.org>
Date: Sun, 28 Apr 2019 23:41:16 -0700
From: tip-bot for Jakub Kicinski <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: tglx@...utronix.de, mingo@...nel.org, linux-kernel@...r.kernel.org,
paulmck@...ux.vnet.ibm.com, simon.horman@...ronome.com,
peterz@...radead.org, will.deacon@....com, hpa@...or.com,
jakub.kicinski@...ronome.com, torvalds@...ux-foundation.org,
akpm@...ux-foundation.org
Subject: [tip:locking/core] locking/static_key: Factor out the fast path of
static_key_slow_dec()
Commit-ID: b92e793bbe4a1c49dbf78d8d526561e7a7dd568a
Gitweb: https://git.kernel.org/tip/b92e793bbe4a1c49dbf78d8d526561e7a7dd568a
Author: Jakub Kicinski <jakub.kicinski@...ronome.com>
AuthorDate: Fri, 29 Mar 2019 17:08:53 -0700
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Mon, 29 Apr 2019 08:29:21 +0200
locking/static_key: Factor out the fast path of static_key_slow_dec()
static_key_slow_dec() checks if the atomic enable count is larger
than 1, and if so there decrements it before taking the jump_label_lock.
Move this logic into a helper for reuse in rate limitted keys.
Signed-off-by: Jakub Kicinski <jakub.kicinski@...ronome.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Reviewed-by: Simon Horman <simon.horman@...ronome.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Paul E. McKenney <paulmck@...ux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Will Deacon <will.deacon@....com>
Cc: alexei.starovoitov@...il.com
Cc: ard.biesheuvel@...aro.org
Cc: oss-drivers@...ronome.com
Cc: yamada.masahiro@...ionext.com
Link: https://lkml.kernel.org/r/20190330000854.30142-3-jakub.kicinski@netronome.com
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
kernel/jump_label.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 73bbbaddbd9c..02c3d11264dd 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -202,13 +202,13 @@ void static_key_disable(struct static_key *key)
}
EXPORT_SYMBOL_GPL(static_key_disable);
-static void __static_key_slow_dec_cpuslocked(struct static_key *key,
- unsigned long rate_limit,
- struct delayed_work *work)
+static bool static_key_slow_try_dec(struct static_key *key)
{
int val;
- lockdep_assert_cpus_held();
+ val = atomic_fetch_add_unless(&key->enabled, -1, 1);
+ if (val == 1)
+ return false;
/*
* The negative count check is valid even when a negative
@@ -217,11 +217,18 @@ static void __static_key_slow_dec_cpuslocked(struct static_key *key,
* returns is unbalanced, because all other static_key_slow_inc()
* instances block while the update is in progress.
*/
- val = atomic_fetch_add_unless(&key->enabled, -1, 1);
- if (val != 1) {
- WARN(val < 0, "jump label: negative count!\n");
+ WARN(val < 0, "jump label: negative count!\n");
+ return true;
+}
+
+static void __static_key_slow_dec_cpuslocked(struct static_key *key,
+ unsigned long rate_limit,
+ struct delayed_work *work)
+{
+ lockdep_assert_cpus_held();
+
+ if (static_key_slow_try_dec(key))
return;
- }
jump_label_lock();
if (atomic_dec_and_test(&key->enabled)) {
Powered by blists - more mailing lists