X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=kernel%2Fprintk.c;h=bdd4ea8c3f2b67520c1a55e0ba34a0a247d350fc;hb=562954d5e01d08154cf15c7e12e6e9ec803f50f7;hp=c46a20a19a153f06e938d469bf760ee893b63114;hpb=8c178beeb20ce3801c4851d41342d0ca32ad292c;p=linux-2.6 diff --git a/kernel/printk.c b/kernel/printk.c index c46a20a19a..bdd4ea8c3f 100644 --- a/kernel/printk.c +++ b/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;