提交 a0f1ccfd 编写于 作者: I Ingo Molnar 提交者: Linus Torvalds

[PATCH] lockdep: do not recurse in printk

Make printk()-ing from within the lock validation code safer by using the
lockdep-recursion counter.
Signed-off-by: NIngo Molnar <mingo@elte.hu>
Signed-off-by: NArjan van de Ven <arjan@linux.intel.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 3047e99e
...@@ -518,7 +518,9 @@ asmlinkage int vprintk(const char *fmt, va_list args) ...@@ -518,7 +518,9 @@ asmlinkage int vprintk(const char *fmt, va_list args)
zap_locks(); zap_locks();
/* This stops the holder of console_sem just where we want him */ /* This stops the holder of console_sem just where we want him */
spin_lock_irqsave(&logbuf_lock, flags); local_irq_save(flags);
lockdep_off();
spin_lock(&logbuf_lock);
printk_cpu = smp_processor_id(); printk_cpu = smp_processor_id();
/* Emit the output into the temporary buffer */ /* Emit the output into the temporary buffer */
...@@ -588,7 +590,7 @@ asmlinkage int vprintk(const char *fmt, va_list args) ...@@ -588,7 +590,7 @@ asmlinkage int vprintk(const char *fmt, va_list args)
*/ */
console_locked = 1; console_locked = 1;
printk_cpu = UINT_MAX; printk_cpu = UINT_MAX;
spin_unlock_irqrestore(&logbuf_lock, flags); spin_unlock(&logbuf_lock);
/* /*
* Console drivers may assume that per-cpu resources have * Console drivers may assume that per-cpu resources have
...@@ -604,6 +606,8 @@ asmlinkage int vprintk(const char *fmt, va_list args) ...@@ -604,6 +606,8 @@ asmlinkage int vprintk(const char *fmt, va_list args)
console_locked = 0; console_locked = 0;
up(&console_sem); up(&console_sem);
} }
lockdep_on();
local_irq_restore(flags);
} else { } else {
/* /*
* Someone else owns the drivers. We drop the spinlock, which * Someone else owns the drivers. We drop the spinlock, which
...@@ -611,7 +615,9 @@ asmlinkage int vprintk(const char *fmt, va_list args) ...@@ -611,7 +615,9 @@ asmlinkage int vprintk(const char *fmt, va_list args)
* console drivers with the output which we just produced. * console drivers with the output which we just produced.
*/ */
printk_cpu = UINT_MAX; printk_cpu = UINT_MAX;
spin_unlock_irqrestore(&logbuf_lock, flags); spin_unlock(&logbuf_lock);
lockdep_on();
local_irq_restore(flags);
} }
preempt_enable(); preempt_enable();
...@@ -809,8 +815,15 @@ void release_console_sem(void) ...@@ -809,8 +815,15 @@ void release_console_sem(void)
console_may_schedule = 0; console_may_schedule = 0;
up(&console_sem); up(&console_sem);
spin_unlock_irqrestore(&logbuf_lock, flags); spin_unlock_irqrestore(&logbuf_lock, flags);
if (wake_klogd && !oops_in_progress && waitqueue_active(&log_wait)) if (wake_klogd && !oops_in_progress && waitqueue_active(&log_wait)) {
/*
* If we printk from within the lock dependency code,
* from within the scheduler code, then do not lock
* up due to self-recursion:
*/
if (!lockdep_internal())
wake_up_interruptible(&log_wait); wake_up_interruptible(&log_wait);
}
} }
EXPORT_SYMBOL(release_console_sem); EXPORT_SYMBOL(release_console_sem);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册