Skip to contentSkip to conversation

linux hangs with printk on schedule()

DISCUSSION Haoqiang Zheng 2 participants 2 messages Feb 4, 2003

lore
Share & tools
lore
#0 lore raw

I found Linux hangs when printk is inserted to the function schedule(). Sure, it doesn't make much sense to add such a line to schedule(). But Linux shouldn't hang anyway, right? It's assumed that printk can be inserted safely to anywhere. So, is it a bug of Linux?

The linux I am running is 2.4.18-14, the same version used by Redhat 8.0. The scheduler is Ingo's O(1) scheduler.

Here is a fragment of the code
****************************************************************
switch (prev->state) {
------
default:
printk("deactivating task pid=%d

comm=%s\n",prev->pid,prev->comm);
             deactivate_task(prev, rq);

}
******************************************************************

#1 lore raw
Quoted 4 lines · Haoqiang Zheng

I found Linux hangs when printk is inserted to the function schedule(). Sure, it doesn't make much sense to add such a line to schedule(). But Linux shouldn't hang anyway, right? It's assumed that printk can be inserted safely to anywhere. So, is it a bug of Linux?

Its a known deadlock in 2.4:

	schedule -> printk() -> dmesg output -> klogd wakes up -> repeat

It is not a hard fix and its basically one of a few places where you cannot call printk(), which is otherwise a very robust funciton.

Robert Love