2008-03-24 12:39:43

by Peter Zijlstra

[permalink] [raw]
Subject: [PATCH 2/2] time: xtime lock vs printk

This printk() can deadlock because it can wake up klogd(), and
task enqueueing will try to read the time in order to set a hrtimer.

Use the new printk_nowakeup() which will avoid waking klogd.

Signed-off-by: Peter Zijlstra <[email protected]>
---
kernel/time/timekeeping.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

Index: linux-2.6-2/kernel/time/timekeeping.c
===================================================================
--- linux-2.6-2.orig/kernel/time/timekeeping.c
+++ linux-2.6-2/kernel/time/timekeeping.c
@@ -191,7 +191,11 @@ static void change_clocksource(void)

tick_clock_notify();

- printk(KERN_INFO "Time: %s clocksource has been installed.\n",
+ /*
+ * We're holding xtime lock and waking up klogd would deadlock
+ * us on enqueue. Print without waking.
+ */
+ printk_nowakeup(KERN_INFO "Time: %s clocksource has been installed.\n",
clock->name);
}
#else

--


2008-03-24 14:22:13

by Daniel Walker

[permalink] [raw]
Subject: Re: [PATCH 2/2] time: xtime lock vs printk


On Mon, 2008-03-24 at 13:24 +0100, Peter Zijlstra wrote:
> - printk(KERN_INFO "Time: %s clocksource has been installed.\n",
> + /*
> + * We're holding xtime lock and waking up klogd would deadlock
> + * us on enqueue. Print without waking.
> + */
> + printk_nowakeup(KERN_INFO "Time: %s clocksource has been
> installed.\n",
> clock->name);

It doesn't seem like there is a lot of potential for more xtime write
lock holders to do printk's .. We could just remove this line, or move
this printk into an __init ..

Daniel