Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

locking: Add lock context support in do_raw_{read,write}_trylock()

Convert do_raw_{read,write}_trylock() from macros into inline functions
and annotate these inline functions with __cond_acquires_shared() or
__cond_acquires() as appropriate. This change is necessary to build
kernel drivers or subsystems that use rwlock synchronization objects with
lock context analysis enabled. The return type 'int' matches the return
type for CONFIG_DEBUG_SPINLOCK=y.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260313171510.230998-3-bvanassche@acm.org

authored by

Bart Van Assche and committed by
Peter Zijlstra
c4d3b8c7 756a0e01

+12 -2
+12 -2
include/linux/rwlock.h
··· 37 37 extern void do_raw_write_unlock(rwlock_t *lock) __releases(lock); 38 38 #else 39 39 # define do_raw_read_lock(rwlock) do {__acquire_shared(lock); arch_read_lock(&(rwlock)->raw_lock); } while (0) 40 - # define do_raw_read_trylock(rwlock) arch_read_trylock(&(rwlock)->raw_lock) 40 + static inline int do_raw_read_trylock(rwlock_t *rwlock) 41 + __cond_acquires_shared(true, rwlock) 42 + __no_context_analysis 43 + { 44 + return arch_read_trylock(&(rwlock)->raw_lock); 45 + } 41 46 # define do_raw_read_unlock(rwlock) do {arch_read_unlock(&(rwlock)->raw_lock); __release_shared(lock); } while (0) 42 47 # define do_raw_write_lock(rwlock) do {__acquire(lock); arch_write_lock(&(rwlock)->raw_lock); } while (0) 43 - # define do_raw_write_trylock(rwlock) arch_write_trylock(&(rwlock)->raw_lock) 48 + static inline int do_raw_write_trylock(rwlock_t *rwlock) 49 + __cond_acquires(true, rwlock) 50 + __no_context_analysis 51 + { 52 + return arch_write_trylock(&(rwlock)->raw_lock); 53 + } 44 54 # define do_raw_write_unlock(rwlock) do {arch_write_unlock(&(rwlock)->raw_lock); __release(lock); } while (0) 45 55 #endif 46 56