locking fixes
Linus,
Please pull the latest locking-urgent-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking-urgent-for-linus
# HEAD: c571b72e2b845ca0519670cb7c4b5fe5f56498a5 Revert "locking/mutex: Complain upon mutex API misuse in IRQ contexts"
Tone down mutex debugging complaints, and annotate/fix spinlock debugging data accesses for KCSAN.
Thanks,
Ingo
------------------>
Davidlohr Bueso (1):
Revert "locking/mutex: Complain upon mutex API misuse in IRQ contexts"
Marco Elver (1):
locking/spinlock/debug: Fix various data races
kernel/locking/mutex.c | 4 ---- kernel/locking/spinlock_debug.c | 32 ++++++++++++++++---------------- 2 files changed, 16 insertions(+), 20 deletions(-)
kernel/locking/mutex.c +0 -4
@@ -733,9 +733,6 @@ static noinline void __sched __mutex_unlock_slowpath(struct mutex *lock, unsigne*/ void __sched mutex_unlock(struct mutex *lock) { -#ifdef CONFIG_DEBUG_MUTEXES -WARN_ON (in_interrupt ()); -#endif #ifndef CONFIG_DEBUG_LOCK_ALLOC if (__mutex_unlock_fast (lock))return ;
@@ -1416,7 +1413,6 @@ int __sched mutex_trylock(struct mutex *lock)#ifdef CONFIG_DEBUG_MUTEXES DEBUG_LOCKS_WARN_ON (lock->magic != lock); -WARN_ON (in_interrupt ());#endif locked =__mutex_trylock (lock);
kernel/locking/spinlock_debug.c +16 -16
@@ -51,19 +51,19 @@ EXPORT_SYMBOL(__rwlock_init);static void spin_dump (raw_spinlock_t *lock,const char *msg) { -struct task_struct *owner =NULL ; +struct task_struct *owner =READ_ONCE (lock->owner); -if (lock->owner && lock->owner !=SPINLOCK_OWNER_INIT ) - owner = lock->owner; +if (owner ==SPINLOCK_OWNER_INIT ) + owner =NULL ;printk (KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n" , msg,raw_smp_processor_id (), current->comm,task_pid_nr (current));printk (KERN_EMERG " lock: %pS, .magic: %08x, .owner: %s/%d, " ".owner_cpu: %d\n" , - lock, lock->magic, + lock,READ_ONCE (lock->magic), owner ? owner->comm :"<none>" , owner ?task_pid_nr (owner) :-1 , - lock->owner_cpu); +READ_ONCE (lock->owner_cpu));dump_stack (); }
@@ -80,16 +80,16 @@ static void spin_bug(raw_spinlock_t *lock, const char *msg)static inline void debug_spin_lock_before (raw_spinlock_t *lock) { -SPIN_BUG_ON (lock->magic !=SPINLOCK_MAGIC , lock,"bad magic" ); -SPIN_BUG_ON (lock->owner == current, lock,"recursion" ); -SPIN_BUG_ON (lock->owner_cpu ==raw_smp_processor_id (), +SPIN_BUG_ON (READ_ONCE (lock->magic) !=SPINLOCK_MAGIC , lock,"bad magic" ); +SPIN_BUG_ON (READ_ONCE (lock->owner) == current, lock,"recursion" ); +SPIN_BUG_ON (READ_ONCE (lock->owner_cpu) ==raw_smp_processor_id (), lock,"cpu recursion" ); }static inline void debug_spin_lock_after (raw_spinlock_t *lock) { - lock->owner_cpu =raw_smp_processor_id (); - lock->owner = current; +WRITE_ONCE (lock->owner_cpu,raw_smp_processor_id ()); +WRITE_ONCE (lock->owner, current); }static inline void debug_spin_unlock (raw_spinlock_t *lock)
@@ -99,8 +99,8 @@ static inline void debug_spin_unlock(raw_spinlock_t *lock)SPIN_BUG_ON (lock->owner != current, lock,"wrong owner" );SPIN_BUG_ON (lock->owner_cpu !=raw_smp_processor_id (), lock,"wrong CPU" ); - lock->owner =SPINLOCK_OWNER_INIT ; - lock->owner_cpu =-1 ; +WRITE_ONCE (lock->owner,SPINLOCK_OWNER_INIT ); +WRITE_ONCE (lock->owner_cpu,-1 ); }/*
@@ -187,8 +187,8 @@ static inline void debug_write_lock_before(rwlock_t *lock)static inline void debug_write_lock_after (rwlock_t *lock) { - lock->owner_cpu =raw_smp_processor_id (); - lock->owner = current; +WRITE_ONCE (lock->owner_cpu,raw_smp_processor_id ()); +WRITE_ONCE (lock->owner, current); }static inline void debug_write_unlock (rwlock_t *lock)
@@ -197,8 +197,8 @@ static inline void debug_write_unlock(rwlock_t *lock)RWLOCK_BUG_ON (lock->owner != current, lock,"wrong owner" );RWLOCK_BUG_ON (lock->owner_cpu !=raw_smp_processor_id (), lock,"wrong CPU" ); - lock->owner =SPINLOCK_OWNER_INIT ; - lock->owner_cpu =-1 ; +WRITE_ONCE (lock->owner,SPINLOCK_OWNER_INIT ); +WRITE_ONCE (lock->owner_cpu,-1 ); }void do_raw_write_lock (rwlock_t *lock)
The pull request you sent on Tue, 17 Dec 2019 12:27:19 +0100:
The pull request you sent on Tue, 17 Dec 2019 12:27:19 +0100:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitlocking-urgent-for-linus
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/9e8a0d5ff8408b1e54be0546df0b2ca9d04264cd
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker