Re: [PATCH v5 17/36] locking/rwsem: Support Clang's context analysis

From: Bart Van Assche

Date: Fri Dec 19 2025 - 15:55:23 EST


On 12/19/25 7:40 AM, Marco Elver wrote:
static inline void rwsem_assert_held_nolockdep(const struct rw_semaphore *sem)
+ __assumes_ctx_lock(sem)
{
WARN_ON(atomic_long_read(&sem->count) == RWSEM_UNLOCKED_VALUE);
}
static inline void rwsem_assert_held_write_nolockdep(const struct rw_semaphore *sem)
+ __assumes_ctx_lock(sem)
{
WARN_ON(!(atomic_long_read(&sem->count) & RWSEM_WRITER_LOCKED));
}
@@ -119,6 +121,7 @@ do { \
static struct lock_class_key __key; \
\
__init_rwsem((sem), #sem, &__key); \
+ __assume_ctx_lock(sem); \
} while (0)

Just like as for lockdep.h, I think that the above annotations should be changed into __must_hold().

Thanks,

Bart.