Skip to contentSkip to conversation

Race condition on bug output.

RT Applied Steven Rostedt 2 participants 2 messages Dec 7, 2005

lore
Share & tools
lore
#0 lore raw

Hi Ingo,

I found a race condition in my kernel which can also be found in yours. When I trigger the printk in check_periodic_interval, interrupts are turned on in release_console_sem. Unfortunately, this can have an interrupt go off there (since they are turned back on there) and the write_lock system_time_lock will be taken again, thus producing a deadlock.

I'm not sure if this is the best solution, but this was the easiest.

Maybe the CONFIG_PARANOID_GENERIC_TIME should be added in the warnings in init/main.c too?

Since interrupts are kept off in the ktimer (hrtimer, whatever) in printk, this does not affect those patches. This is a PREEMPT_RT only problem.

-- Steve

kernel/printk.c +2 -1
Index: linux-2.6.14-rt22/kernel/printk.c
===================================================================
@@ -757,7 +757,8 @@
 		 * on PREEMPT_RT, call console drivers with
 		 * interrupts enabled (unless we are debugging):
 		 */
-#if defined(CONFIG_PREEMPT_RT) && !defined(CONFIG_PRINTK_IGNORE_LOGLEVEL) && !defined(CONFIG_PPC)
+#if defined(CONFIG_PREEMPT_RT) && !defined(CONFIG_PRINTK_IGNORE_LOGLEVEL) && !defined(CONFIG_PPC) \
+    && !defined(CONFIG_PARANOID_GENERIC_TIME)
 		spin_unlock_irq(&logbuf_lock);
 #else
 		spin_unlock(&logbuf_lock);
Applied
#1 lore raw
Quoted 9 lines · Steven Rostedt

Hi Ingo,

I found a race condition in my kernel which can also be found in yours. When I trigger the printk in check_periodic_interval, interrupts are turned on in release_console_sem. Unfortunately, this can have an interrupt go off there (since they are turned back on there) and the write_lock system_time_lock will be taken again, thus producing a deadlock.

Quoted 8 lines

I'm not sure if this is the best solution, but this was the easiest.

Maybe the CONFIG_PARANOID_GENERIC_TIME should be added in the warnings in init/main.c too?

Since interrupts are kept off in the ktimer (hrtimer, whatever) in printk, this does not affect those patches. This is a PREEMPT_RT only problem.

thanks, applied.

Ingo