lkml.org 
[lkml]   [2014]   [Apr]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 2/8] printk: Release lockbuf_lock before calling console_trylock_for_printk()
On Tue, 25 Mar 2014 18:54:55 +0100 Jan Kara <jack@suse.cz> wrote:

> There's no reason to hold lockbuf_lock when entering
> console_trylock_for_printk(). The first thing this function does is
> calling down_trylock(console_sem) and if that fails it immediately
> unlocks lockbuf_lock. So lockbuf_lock isn't needed for that branch.
> When down_trylock() succeeds, the rest of console_trylock() is OK
> without lockbuf_lock (it is called without it from other places), and
> the only remaining thing in console_trylock_for_printk() is
> can_use_console() call. For that call console_sem is enough (it
> iterates all consoles and checks CON_ANYTIME flag).
>
> So we drop logbuf_lock before entering console_trylock_for_printk()
> which simplifies the code.
>

I suppose we should document have_callable_console()'s locking
requirements, and I don't think that "early in boot" part is true?

--- a/kernel/printk/printk.c~printk-release-lockbuf_lock-before-calling-console_trylock_for_printk-fix
+++ a/kernel/printk/printk.c
@@ -1377,7 +1377,9 @@ static void zap_locks(void)
sema_init(&console_sem, 1);
}

-/* Check if we have any console registered that can be called early in boot. */
+/*
+ * Check if we have any console registered. Requires console_sem.
+ */
static int have_callable_console(void)
{
struct console *con;
_


\
 
 \ /
  Last update: 2014-04-23 23:21    [W:0.200 / U:2.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site