[PATCH 1/2] locking/rwlock: Pass rwlock to __acquire*() and __release*()
From: Bart Van Assche
Date: Fri Dec 04 2026 - 16:58:39 EST
The !CONFIG_DEBUG_SPINLOCK definitions of do_raw_read_lock(),
do_raw_read_unlock(), do_raw_write_lock(), and do_raw_write_unlock() in
include/linux/rwlock.h pass the hardcoded identifier lock instead of the
macro parameter rwlock to __acquire*() and __release*(). This compiles
only by coincidence when callers name their local rwlock_t pointer lock.
Pass the macro parameter rwlock instead.
Fixes: b97c4bc16734 ("locking: Make sparse work with inline spinlocks and rwlocks")
Fixes: f16a802d402d ("locking/rwlock, spinlock: Support Clang's context analysis")
Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>
---
include/linux/rwlock.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/linux/rwlock.h b/include/linux/rwlock.h
index 4e67cd934d8f..396eb022bbd1 100644
--- a/include/linux/rwlock.h
+++ b/include/linux/rwlock.h
@@ -36,22 +36,22 @@ do { \
extern int do_raw_write_trylock(rwlock_t *lock) __cond_acquires(true, lock);
extern void do_raw_write_unlock(rwlock_t *lock) __releases(lock);
#else
-# define do_raw_read_lock(rwlock) do {__acquire_shared(lock); arch_read_lock(&(rwlock)->raw_lock); } while (0)
+# define do_raw_read_lock(rwlock) do {__acquire_shared(rwlock); arch_read_lock(&(rwlock)->raw_lock); } while (0)
static inline int do_raw_read_trylock(rwlock_t *rwlock)
__cond_acquires_shared(true, rwlock)
__no_context_analysis
{
return arch_read_trylock(&(rwlock)->raw_lock);
}
-# define do_raw_read_unlock(rwlock) do {arch_read_unlock(&(rwlock)->raw_lock); __release_shared(lock); } while (0)
-# define do_raw_write_lock(rwlock) do {__acquire(lock); arch_write_lock(&(rwlock)->raw_lock); } while (0)
+# define do_raw_read_unlock(rwlock) do {arch_read_unlock(&(rwlock)->raw_lock); __release_shared(rwlock); } while (0)
+# define do_raw_write_lock(rwlock) do {__acquire(rwlock); arch_write_lock(&(rwlock)->raw_lock); } while (0)
static inline int do_raw_write_trylock(rwlock_t *rwlock)
__cond_acquires(true, rwlock)
__no_context_analysis
{
return arch_write_trylock(&(rwlock)->raw_lock);
}
-# define do_raw_write_unlock(rwlock) do {arch_write_unlock(&(rwlock)->raw_lock); __release(lock); } while (0)
+# define do_raw_write_unlock(rwlock) do {arch_write_unlock(&(rwlock)->raw_lock); __release(rwlock); } while (0)
#endif
/*