mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 17:40:53 +07:00
printk: Release console_sem after logbuf_lock
Release console_sem after unlocking the logbuf_lock so that we don't generate wakeups while holding logbuf_lock. This avoids some lock inversion troubles once we remove the lockdep_off bits between logbuf_lock and rq->lock (prints while holding rq->lock vs doing wakeups while holding logbuf_lock). There's of course still an actual deadlock where the printk()s under rq->lock will issue a wakeup from the up() call, but lockdep won't warn about that since semaphores are not tracked. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Andrew Morton <akpm@linux-foundation.org> Link: http://lkml.kernel.org/n/tip-j8swthl12u73h4znbvitljzd@git.kernel.org Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
59c5f46fbe
commit
0b5e1c5255
@ -782,7 +782,7 @@ static inline int can_use_console(unsigned int cpu)
|
||||
static int console_trylock_for_printk(unsigned int cpu)
|
||||
__releases(&logbuf_lock)
|
||||
{
|
||||
int retval = 0;
|
||||
int retval = 0, wake = 0;
|
||||
|
||||
if (console_trylock()) {
|
||||
retval = 1;
|
||||
@ -795,12 +795,14 @@ static int console_trylock_for_printk(unsigned int cpu)
|
||||
*/
|
||||
if (!can_use_console(cpu)) {
|
||||
console_locked = 0;
|
||||
up(&console_sem);
|
||||
wake = 1;
|
||||
retval = 0;
|
||||
}
|
||||
}
|
||||
printk_cpu = UINT_MAX;
|
||||
spin_unlock(&logbuf_lock);
|
||||
if (wake)
|
||||
up(&console_sem);
|
||||
return retval;
|
||||
}
|
||||
static const char recursion_bug_msg [] =
|
||||
@ -1271,8 +1273,8 @@ void console_unlock(void)
|
||||
if (unlikely(exclusive_console))
|
||||
exclusive_console = NULL;
|
||||
|
||||
up(&console_sem);
|
||||
spin_unlock_irqrestore(&logbuf_lock, flags);
|
||||
up(&console_sem);
|
||||
if (wake_klogd)
|
||||
wake_up_klogd();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user