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 annotations in the spinlock implementation

Make the spinlock implementation compatible with lock context analysis
(CONTEXT_ANALYSIS := 1) by adding lock context annotations to the
_raw_##op##_...() macros.

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-4-bvanassche@acm.org

authored by

Bart Van Assche and committed by
Peter Zijlstra
b06e988c c4d3b8c7

+8 -4
+8 -4
kernel/locking/spinlock.c
··· 64 64 * time (making _this_ CPU preemptible if possible), and we also signal 65 65 * towards that other CPU that it should break the lock ASAP. 66 66 */ 67 - #define BUILD_LOCK_OPS(op, locktype) \ 67 + #define BUILD_LOCK_OPS(op, locktype, lock_ctx_op) \ 68 68 static void __lockfunc __raw_##op##_lock(locktype##_t *lock) \ 69 + lock_ctx_op(lock) \ 69 70 { \ 70 71 for (;;) { \ 71 72 preempt_disable(); \ ··· 79 78 } \ 80 79 \ 81 80 static unsigned long __lockfunc __raw_##op##_lock_irqsave(locktype##_t *lock) \ 81 + lock_ctx_op(lock) \ 82 82 { \ 83 83 unsigned long flags; \ 84 84 \ ··· 98 96 } \ 99 97 \ 100 98 static void __lockfunc __raw_##op##_lock_irq(locktype##_t *lock) \ 99 + lock_ctx_op(lock) \ 101 100 { \ 102 101 _raw_##op##_lock_irqsave(lock); \ 103 102 } \ 104 103 \ 105 104 static void __lockfunc __raw_##op##_lock_bh(locktype##_t *lock) \ 105 + lock_ctx_op(lock) \ 106 106 { \ 107 107 unsigned long flags; \ 108 108 \ ··· 127 123 * __[spin|read|write]_lock_irqsave() 128 124 * __[spin|read|write]_lock_bh() 129 125 */ 130 - BUILD_LOCK_OPS(spin, raw_spinlock); 126 + BUILD_LOCK_OPS(spin, raw_spinlock, __acquires); 131 127 132 128 #ifndef CONFIG_PREEMPT_RT 133 - BUILD_LOCK_OPS(read, rwlock); 134 - BUILD_LOCK_OPS(write, rwlock); 129 + BUILD_LOCK_OPS(read, rwlock, __acquires_shared); 130 + BUILD_LOCK_OPS(write, rwlock, __acquires); 135 131 #endif 136 132 137 133 #endif