Skip to content

Commit

Permalink
kernel/printk.c: document possible deadlock against scheduler
Browse files Browse the repository at this point in the history
kernel/printk.c: document possible deadlock against scheduler

The printk's comment states that it can be called from every context,
which might lead to false illusion that it could be called from everywhere
without any restrictions.

This is however not true - a call to printk() could deadlock if called from
scheduler code (namely from schedule(), wake_up(), etc) on runqueue lock
when it tries to wake up klogd. Document this.

Signed-off-by: Jiri Kosina <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Jiri Kosina authored and Linus Torvalds committed Jul 16, 2007
1 parent 017f021 commit 1492192
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kernel/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ static int have_callable_console(void)
* @fmt: format string
*
* This is printk(). It can be called from any context. We want it to work.
* Be aware of the fact that if oops_in_progress is not set, we might try to
* wake klogd up which could deadlock on runqueue lock if printk() is called
* from scheduler code.
*
* We try to grab the console_sem. If we succeed, it's easy - we log the output and
* call the console drivers. If we fail to get the semaphore we place the output
Expand Down

0 comments on commit 1492192

Please sign in to comment.