Re: [patch] Real-Time Preemption, -RT-2.6.9-rc4-mm1-U8

From: Michal Schmidt
Date: Wed Oct 20 2004 - 16:50:26 EST


Ingo Molnar wrote:
disable_irq() should work fine though. (it doesnt disable local
interrupts, it only disables that particular irq line.) So something
else disabled interrupts - ah, netconsole.c itself. Does the patch below
fix things up for you?

Ingo
> [patch snipped]

That patch was not enough. The BUGs were still showing up the same as before.
I tried to debug it myself. I've found an interesting thing in kernel/printk.c:release_console_sem(). There is the following sequence:

spin_lock_irqsave(&logbuf_lock, flags);
/* ... some code ... */
spin_unlock(&logbuf_lock);
call_console_drivers(...);
local_irq_restore(flags);

I know very little about locking, but I didn't like this two-phased unlock. So I replaced it with a single spin_unlock_irqrestore. Patch attached.
I'm almost certain that there is a reason for the two-phased unlocking and that this patch will break something, but so far it works for me. netconsole now works without complaining.

Michal diff -Nurp linux-2.6.9-rc4-mm1-RT-U8/kernel/printk.c linux-2.6.9-rc4-mm1-RT-U8-m/kernel/printk.c
--- linux-2.6.9-rc4-mm1-RT-U8/kernel/printk.c 2004-10-20 22:20:55.000000000 +0200
+++ linux-2.6.9-rc4-mm1-RT-U8-m/kernel/printk.c 2004-10-20 22:24:40.000000000 +0200
@@ -646,9 +646,8 @@ void release_console_sem(void)
_con_start = con_start;
_log_end = log_end;
con_start = log_end; /* Flush */
- spin_unlock(&logbuf_lock);
+ spin_unlock_irqrestore(&logbuf_lock, flags);
call_console_drivers(_con_start, _log_end);
- local_irq_restore(flags);
}
console_locked = 0;
console_may_schedule = 0;