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/mutex: Add MUTEX_WARN_ON

Cleanup some #ifdef'fery.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Waiman Long <longman@redhat.com>
Reviewed-by: Yanfei Xu <yanfei.xu@windriver.com>
Link: https://lore.kernel.org/r/20210630154115.020298650@infradead.org

+10 -20
+10 -20
kernel/locking/mutex.c
··· 32 32 33 33 #ifdef CONFIG_DEBUG_MUTEXES 34 34 # include "mutex-debug.h" 35 + # define MUTEX_WARN_ON(cond) DEBUG_LOCKS_WARN_ON(cond) 35 36 #else 36 37 # include "mutex.h" 38 + # define MUTEX_WARN_ON(cond) 37 39 #endif 38 40 39 41 void ··· 115 113 break; 116 114 } 117 115 } else { 118 - #ifdef CONFIG_DEBUG_MUTEXES 119 - DEBUG_LOCKS_WARN_ON(flags & (MUTEX_FLAG_HANDOFF | MUTEX_FLAG_PICKUP)); 120 - #endif 116 + MUTEX_WARN_ON(flags & (MUTEX_FLAG_HANDOFF | MUTEX_FLAG_PICKUP)); 121 117 task = curr; 122 118 } 123 119 ··· 218 218 for (;;) { 219 219 unsigned long new; 220 220 221 - #ifdef CONFIG_DEBUG_MUTEXES 222 - DEBUG_LOCKS_WARN_ON(__owner_task(owner) != current); 223 - DEBUG_LOCKS_WARN_ON(owner & MUTEX_FLAG_PICKUP); 224 - #endif 221 + MUTEX_WARN_ON(__owner_task(owner) != current); 222 + MUTEX_WARN_ON(owner & MUTEX_FLAG_PICKUP); 225 223 226 224 new = (owner & MUTEX_FLAG_WAITERS); 227 225 new |= (unsigned long)task; ··· 752 754 * into 'unlocked' state: 753 755 */ 754 756 if (lock->ctx) { 755 - #ifdef CONFIG_DEBUG_MUTEXES 756 - DEBUG_LOCKS_WARN_ON(!lock->ctx->acquired); 757 - #endif 757 + MUTEX_WARN_ON(!lock->ctx->acquired); 758 758 if (lock->ctx->acquired > 0) 759 759 lock->ctx->acquired--; 760 760 lock->ctx = NULL; ··· 927 931 928 932 might_sleep(); 929 933 930 - #ifdef CONFIG_DEBUG_MUTEXES 931 - DEBUG_LOCKS_WARN_ON(lock->magic != lock); 932 - #endif 934 + MUTEX_WARN_ON(lock->magic != lock); 933 935 934 936 ww = container_of(lock, struct ww_mutex, base); 935 937 if (ww_ctx) { ··· 1221 1227 */ 1222 1228 owner = atomic_long_read(&lock->owner); 1223 1229 for (;;) { 1224 - #ifdef CONFIG_DEBUG_MUTEXES 1225 - DEBUG_LOCKS_WARN_ON(__owner_task(owner) != current); 1226 - DEBUG_LOCKS_WARN_ON(owner & MUTEX_FLAG_PICKUP); 1227 - #endif 1230 + MUTEX_WARN_ON(__owner_task(owner) != current); 1231 + MUTEX_WARN_ON(owner & MUTEX_FLAG_PICKUP); 1228 1232 1229 1233 if (owner & MUTEX_FLAG_HANDOFF) 1230 1234 break; ··· 1388 1396 { 1389 1397 bool locked; 1390 1398 1391 - #ifdef CONFIG_DEBUG_MUTEXES 1392 - DEBUG_LOCKS_WARN_ON(lock->magic != lock); 1393 - #endif 1399 + MUTEX_WARN_ON(lock->magic != lock); 1394 1400 1395 1401 locked = __mutex_trylock(lock); 1396 1402 if (locked)