From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384557; b=tVnlQOdpuHsL/2WGK1Xf+rcZSviPT3YzIL/XhXprps1PNYcjPsdOdVzKvQkXNDqFIpHy XzFnz7MHaX581Q4Y2a5jC7uFY5DVdsm2uV+2EV1EHv2H93WQQBowpIOgPL4qTZ2mOtIiQ hpqM7XARxJ8sDKOG1MlCq0MrqOMjMai8wXXG2nij6zqQAyibvsWVWHbV5t3jQxym1FRvB 9TV1ZXqHWLKwR7Vbw4A/WdSPDLad+yXKrnwrfVYF/tcJRv6DffBNiz3yXgquyr4TDpN+r L9HySitWC0h8MObo61eRcVmDw9WvuczK4LJ166LqZUMtwYG/lIjAkxxHU1Zw+0DbcUQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384557; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=HRFecsKiviLI00LdHa0vtxgn1AAZzptrHtrZQ2ISnd4=; b=PV5Klo65ZngVpogHLX4uGI27w0+/4+6zgSl0ryP54Jsldw5uUGEwvpzRYBi0qdlMtdyK 4MY5rSiOWjAwYP4kI7SQ3N9OX3DBsT5ZCMPf86n5CNxjiH4pY4/EJhmhYawLwQQWKkem6 RaSS0GjT8EjOXCi44Wp5kFamWs07uH39vEI6tbIB8sAF0kdBiE1Onvdq6c+qBNYsEXAa3 gnXoXSXn5PCujePeGwUTTWsJa2JVEqdH02UmL7NSPKICVRjxnRveHO+o2uLLw+6E5ZRV3 DnirzCoIKp9NPyqfPGSpnul2Pa982BlyxEXhU1grVrELNSBKkW43sEMpwzZwh1ZmQBg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="irRXj7/G"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 626E7606A322; Fri, 4 Dec 2026 11:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=irRXj7/G Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6FE51F000C2; Fri, 4 Dec 2026 11:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384557; bh=HRFecsKiviLI00LdHa0vtxgn1AAZzptrHtrZQ2ISnd4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=irRXj7/Gvp4DgFewbkAP96mAk1j0msE2ZUqgvwon+sUWsjGftVFa/PHcHF+2hKZ3Z dT40+WyPtCDDu7KqzigPaItQrWpOpsDTIpCC3o52pwMqv+g0GM9qtkgFXutrCQNFGW zwKezs26Z4qpbS3ZRNxn3cXCUij74WeWwS0rmF+E= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Laight , "Peter Zijlstra (Intel)" , Ingo Molnar , Linus Torvalds , Waiman Long , linux-kernel@vger.kernel.org, Sasha Levin Subject: [PATCH 6.6 0193/1167] locking/osq: Switch osq_wait_next()/atomic_cmpxchg() ordering Date: Fri, 4 Dec 2026 18:53:40 +0900 Message-ID: <20261204100707.089924102@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Peter Zijlstra [ Upstream commit 1b9e01fcc47aff00d2fd64693c5dcd620eff5865 ] The atomic_cmpxchg() in osq_wait_next() removes the current CPU's node from the tail of the queue and puts @old_cpu back. This is very much like an 'unlock', which is RELEASE, rather than ACQUIRE. Additionally, on success (the only case where the ordering is effective), this returns NULL which means both callsites will do nothing more, there are no subsequent operations to order against. Furthermore, the osq_lock() caller will then return false, indicating failure to acquire -- the mutex must go block. Again, not making a case for ACQUIRE. Neither atomics nor locks provide ordering on failure. Since ACQUIRE makes no sense, while RELEASE makes it more symmetric with osq_unlock(), switch the ordering. This then makes osq_unlock() consistently RELEASE. Fixes: c55a6ffa6285 ("locking/osq: Relax atomic semantics") Suggested-by: David Laight Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Cc: Linus Torvalds Cc: Waiman Long Cc: linux-kernel@vger.kernel.org Signed-off-by: Sasha Levin --- kernel/locking/osq_lock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/locking/osq_lock.c b/kernel/locking/osq_lock.c index ebb1493915ce9..b3748ed287ebb 100644 --- a/kernel/locking/osq_lock.c +++ b/kernel/locking/osq_lock.c @@ -53,7 +53,7 @@ osq_wait_next(struct optimistic_spin_queue *lock, for (;;) { if (atomic_read(&lock->tail) == curr && - atomic_cmpxchg_acquire(&lock->tail, curr, old_cpu) == curr) { + atomic_cmpxchg_release(&lock->tail, curr, old_cpu) == curr) { /* * We were the last queued, we moved @lock back. @prev * will now observe @lock and will complete its -- 2.53.0