[PATCH 2/2] time: xtime lock vs printk

From: Peter Zijlstra
Date: Mon Mar 24 2008 - 08:39:45 EST


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 <a.p.zijlstra@xxxxxxxxx>
---
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

--

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/