From 3c7e5c572f3bac968b9a7fb64c7328b00be6ab5d Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 15 Apr 2008 13:09:54 -0700 Subject: [PATCH] --- yaml --- r: 88336 b: refs/heads/master c: 093a07e2fdfaddab7fc7d4adc76cc569c86603d7 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/kernel/printk.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index ce2a7635f4c5..90a0b1c4f30f 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 0de19a456cb59106420864927fdec152310f70b6 +refs/heads/master: 093a07e2fdfaddab7fc7d4adc76cc569c86603d7 diff --git a/trunk/kernel/printk.c b/trunk/kernel/printk.c index c46a20a19a15..bdd4ea8c3f2b 100644 --- a/trunk/kernel/printk.c +++ b/trunk/kernel/printk.c @@ -643,8 +643,21 @@ static int acquire_console_semaphore_for_printk(unsigned int cpu) { int retval = 0; - if (can_use_console(cpu)) - retval = !try_acquire_console_sem(); + if (!try_acquire_console_sem()) { + retval = 1; + + /* + * If we can't use the console, we need to release + * the console semaphore by hand to avoid flushing + * the buffer. We need to hold the console semaphore + * in order to do this test safely. + */ + if (!can_use_console(cpu)) { + console_locked = 0; + up(&console_sem); + retval = 0; + } + } printk_cpu = UINT_MAX; spin_unlock(&logbuf_lock); return retval;