mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Peter Zijlstra" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: "Darrick J. Wong" <djwong@kernel.org>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: locking/urgent] jump_label: Fix the fix, brown paper bags galore
Date: Wed, 31 Jul 2024 11:07:14 -0000	[thread overview]
Message-ID: <172242403495.2215.11338739604467848579.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20240731105557.GY33588@noisy.programming.kicks-ass.net>

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@infradead.org>
AuthorDate:    Wed, 31 Jul 2024 12:43:21 +02:00
Committer:     Peter Zijlstra <peterz@infradead.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@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Darrick J. Wong <djwong@kernel.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));

  reply	other threads:[~2024-07-31 11:07 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-30  3:38 Are jump labels broken on 6.11-rc1? Darrick J. Wong
2024-07-30  7:30 ` Chandan Babu R
2024-07-30 13:26   ` Peter Zijlstra
2024-07-30 13:59     ` Darrick J. Wong
2024-07-31  0:19     ` Darrick J. Wong
2024-07-31  3:10       ` Darrick J. Wong
2024-07-31  5:33         ` Darrick J. Wong
2024-07-31 10:55           ` Peter Zijlstra
2024-07-31 11:07             ` tip-bot2 for Peter Zijlstra [this message]
2024-08-05 14:35             ` Darrick J. Wong
2024-08-06  9:44               ` Peter Zijlstra
2024-08-06 10:38                 ` Peter Zijlstra
2024-08-06 22:01                   ` Darrick J. Wong
2024-08-07 14:03                   ` Thomas Gleixner
2024-08-07 14:34                     ` Peter Zijlstra
2024-08-07 14:55                       ` Thomas Gleixner
2024-08-07 15:05                         ` Darrick J. Wong
2024-08-07 22:51                           ` Darrick J. Wong
2024-08-27  3:35                           ` Darrick J. Wong
2024-09-05  8:12                             ` Peter Zijlstra
2024-09-05  9:16                               ` Peter Zijlstra
2024-09-16 16:08                                 ` Darrick J. Wong
2024-09-19 23:41                                   ` Darrick J. Wong
2024-09-06 14:41                     ` [tip: locking/urgent] jump_label: Fix static_key_slow_dec() yet again tip-bot2 for Peter Zijlstra
2024-09-10 20:16                       ` Mark Brown
2024-09-21 13:52                         ` Mark Rutland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=172242403495.2215.11338739604467848579.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=djwong@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®