[tip: locking/urgent] bit_spinlock: Fix the __bitlock() macro definition

From: tip-bot2 for Bart Van Assche

Date: Mon Nov 23 2026 - 04:44:25 EST


The following commit has been merged into the locking/urgent branch of tip:

Commit-ID: af1a4ab4bf3bcb969ad5ee9e7fca1d23703adf32
Gitweb: https://git.kernel.org/tip/af1a4ab4bf3bcb969ad5ee9e7fca1d23703adf32
Author: Bart Van Assche <bvanassche@xxxxxxx>
AuthorDate: Wed, 18 Nov 2026 15:09:57 -08:00
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitterDate: Mon, 23 Nov 2026 10:38:52 +01:00

bit_spinlock: Fix the __bitlock() macro definition

Surround the 'bitnum' argument and the entire __bitlock() macro expansion
with parentheses because 'bitnum' could be an expression that includes an
operator with a lower precedence than the addition operator (e.g. the
exclusive-or operator) and to prevent operator precedence issues in
callers.

Fixes: eb7d96a13bf4 ("bit_spinlock: Support Clang's context analysis")
Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Acked-by: Marco Elver <elver@xxxxxxxxxx>
Link: https://patch.msgid.link/38cdec9322fa710f84c018e0b318894c6234c411.1795043161.git.bvanassche@xxxxxxx
---
include/linux/bit_spinlock.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/bit_spinlock.h b/include/linux/bit_spinlock.h
index 7869a6e..c31d4f4 100644
--- a/include/linux/bit_spinlock.h
+++ b/include/linux/bit_spinlock.h
@@ -17,7 +17,7 @@
* static analysis can use.
*/
context_lock_struct(__context_bitlock) { };
-#define __bitlock(bitnum, addr) (struct __context_bitlock *)(bitnum + (addr))
+#define __bitlock(bitnum, addr) ((struct __context_bitlock *)((bitnum) + (addr)))

/*
* bit-based spin_lock()