Skip to content

Commit f87f3a3

Browse files
wildea01ingomolnar
authored andcommitted
locking/core: Fix deadlock during boot on systems with GENERIC_LOCKBREAK
Commit: a8a217c ("locking/core: Remove {read,spin,write}_can_lock()") removed the definition of raw_spin_can_lock(), causing the GENERIC_LOCKBREAK spin_lock() routines to poll the ->break_lock field when waiting on a lock. This has been reported to cause a deadlock during boot on s390, because the ->break_lock field is also set by the waiters, and can potentially remain set indefinitely if no other CPUs come in to take the lock after it has been released. This patch removes the explicit spinning on ->break_lock from the waiters, instead relying on the outer trylock() operation to determine when the lock is available. Reported-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Tested-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Acked-by: Peter Zijlstra <peterz@infradead.org> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Fixes: a8a217c ("locking/core: Remove {read,spin,write}_can_lock()") Link: http://lkml.kernel.org/r/1511894539-7988-2-git-send-email-will.deacon@arm.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 50c4c4e commit f87f3a3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎kernel/locking/spinlock.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ void __lockfunc __raw_##op##_lock(locktype##_t *lock) \
6868
\
6969
if (!(lock)->break_lock) \
7070
(lock)->break_lock = 1; \
71-
while ((lock)->break_lock) \
72-
arch_##op##_relax(&lock->raw_lock); \
71+
\
72+
arch_##op##_relax(&lock->raw_lock); \
7373
} \
7474
(lock)->break_lock = 0; \
7575
} \
@@ -88,8 +88,8 @@ unsigned long __lockfunc __raw_##op##_lock_irqsave(locktype##_t *lock) \
8888
\
8989
if (!(lock)->break_lock) \
9090
(lock)->break_lock = 1; \
91-
while ((lock)->break_lock) \
92-
arch_##op##_relax(&lock->raw_lock); \
91+
\
92+
arch_##op##_relax(&lock->raw_lock); \
9393
} \
9494
(lock)->break_lock = 0; \
9595
return flags; \

0 commit comments

Comments
 (0)