[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <172242403495.2215.11338739604467848579.tip-bot2@tip-bot2>
Date: Wed, 31 Jul 2024 11:07:14 -0000
From: "tip-bot2 for Peter Zijlstra" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: "Darrick J. Wong" <djwong@...nel.org>,
 "Peter Zijlstra (Intel)" <peterz@...radead.org>, x86@...nel.org,
 linux-kernel@...r.kernel.org
Subject:
 [tip: locking/urgent] jump_label: Fix the fix, brown paper bags galore
The following commit has been merged into the locking/urgent branch of tip:
Commit-ID:     224fa3552029a3d14bec7acf72ded8171d551b88
Gitweb:        https://git.kernel.org/tip/224fa3552029a3d14bec7acf72ded8171d551b88
Author:        Peter Zijlstra <peterz@...radead.org>
AuthorDate:    Wed, 31 Jul 2024 12:43:21 +02:00
Committer:     Peter Zijlstra <peterz@...radead.org>
CommitterDate: Wed, 31 Jul 2024 12:57:39 +02:00
jump_label: Fix the fix, brown paper bags galore
Per the example of:
  !atomic_cmpxchg(&key->enabled, 0, 1)
the inverse was written as:
  atomic_cmpxchg(&key->enabled, 1, 0)
except of course, that while !old is only true for old == 0, old is
true for everything except old == 0.
Fix it to read:
  atomic_cmpxchg(&key->enabled, 1, 0) == 1
such that only the 1->0 transition returns true and goes on to disable
the keys.
Fixes: 83ab38ef0a0b ("jump_label: Fix concurrency issues in static_key_slow_dec()")
Reported-by: Darrick J. Wong <djwong@...nel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Tested-by: Darrick J. Wong <djwong@...nel.org>
Link: https://lkml.kernel.org/r/20240731105557.GY33588@noisy.programming.kicks-ass.net
---
 kernel/jump_label.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 4ad5ed8..6dc76b5 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -236,7 +236,7 @@ void static_key_disable_cpuslocked(struct static_key *key)
 	}
 
 	jump_label_lock();
-	if (atomic_cmpxchg(&key->enabled, 1, 0))
+	if (atomic_cmpxchg(&key->enabled, 1, 0) == 1)
 		jump_label_update(key);
 	jump_label_unlock();
 }
@@ -289,7 +289,7 @@ static void __static_key_slow_dec_cpuslocked(struct static_key *key)
 		return;
 
 	guard(mutex)(&jump_label_mutex);
-	if (atomic_cmpxchg(&key->enabled, 1, 0))
+	if (atomic_cmpxchg(&key->enabled, 1, 0) == 1)
 		jump_label_update(key);
 	else
 		WARN_ON_ONCE(!static_key_slow_try_dec(key));
Powered by blists - more mailing lists
 
