linux hangs with printk on schedule()

linux hangs with printk on schedule()

Post by Haoqiang Zhen » Wed, 05 Feb 2003 02:40:14



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);
  }
******************************************************************

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

linux hangs with printk on schedule()

Post by Robert Lov » Wed, 05 Feb 2003 02:50:08



> 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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

linux hangs with printk on schedule()

Post by Andi Klee » Wed, 05 Feb 2003 02:50:10



> 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.

printk can call wake_up to wake up the klogd daemon. This will deadlock
on aquiring the scheduler lock of the local run queue.

One way to avoid it is to wrap it like this:

        oops_in_progress++;
        printk(...);
        oops_in_progress--;

And no, it's not a bug in Linux.

-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

linux hangs with printk on schedule()

Post by Haoqiang Zhen » Thu, 06 Feb 2003 05:10:07


Quote:> oops_in_progress++;
> printk(...);
> oops_in_progress--;

Thanks Robert and Andi for your help.
But the trick (avoid waking up klog by setting oops_in_progress) doesn't
seem to work for me.

I did notice the code:
*********************************************
 if (must_wake_klogd && !oops_in_progress)
  wake_up_interruptible(&log_wait);
*****************************************
But it simply still doesn't work. :-(

I am working on implementing a new SMP scheduler. It's an OS research
project. Without "printk" in the scheduler, it's really very hard to do the
debugging. I don't know how other guys do in this case. Are you guys better
equipped than me? I mean is debugging with gdb running on another machine
(connected via serial port) a common technique? I am not sure whether it's
necessary to set up an environment like that.

Haoqiang

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

linux hangs with printk on schedule()

Post by Rick Lindsle » Fri, 07 Feb 2003 04:30:05


    I am working on implementing a new SMP scheduler. It's an OS research
    project. Without "printk" in the scheduler, it's really very hard to do the
    debugging. I don't know how other guys do in this case. Are you guys better
    equipped than me? I mean is debugging with gdb running on another machine
    (connected via serial port) a common technique? I am not sure whether it's
    necessary to set up an environment like that.

Depending on what your needs are, could you simply note or count events
and do something about them later?  I've a patch which inserts counters
into schedule() (basically a very focused code coverage) so that you
can determine later what decisions were taken (and how many times they
were taken). If knowing the frequency at which a path was taken is
more important than knowing specific values each time a path was hit,
this patch might do it for you.

http://www.veryComputer.com/

If both the details and sequence is important, since this is debugging,
you might try creating a, oh, 5000 member array, treated either as
a circular buffer or a simple recording of the first 5000 events, in
which you record your interesting event for later retrieval via
(fancy) /proc or (more basic) your favorite de*.  I wouldn't
advocate this for finished code, and be warned that too much
intrusive debugging in a path like the scheduler can skew what
you're hoping to observe. (printk's, for instance, can
be very slow compared to what's happening in the scheduler.)

Rick
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://www.veryComputer.com/
Please read the FAQ at  http://www.veryComputer.com/

 
 
 

1. Hang, Hang, Hangs. No hopes!

I recently got a linux distrubtion off the internet.  It is Redhat
Linux Professional Version 8.  I think this is a new version, as im
only a newbie to the scene, but was wanting to give linux a shot.

I have a Dell Lattitude XPi P150ST with 48mb.  I run the installation
program off a boot floppy and then off the cdroms, since my laptop
never supported booting straight from CD, I used the rawrite app.

The installation program worked, I choose all the preferences and
options, but then when the installation program was about to install
programs, etc, it come up with an error message, it told me to post it
on the redhat website.  I scrolled down and the message said something
about not having enough memory to perform a certain task, as far as I
could make out.  It was a erron error or something?.

Im going to try to install it again, with the installation program
that you can do through the text interface, instead of the graphical
one.  First impressions, I did like the setup program, but not quite
when it said there was an error. - If i didnt have enough memory to
continue with installation would it not tell me straight out that I
didnt have the memory, instead of an error message.  The message had a
good few lines of programing lines or something - leave that to the
programmers!

A wannabe Linux user. Maybe.

2. Recommended Video for X

3. mandrake linux printk

4. Sun 3/50 problem

5. printk on familiar linux

6. who uses the netboot loader???

7. printk within installed device driver's modue in linux kernel 2.4.2/3

8. Document moved error shows HTTP headers

9. Linux printk

10. can't use printk in linux 2.4.2 module

11. Linux printk

12. Linux 2.4.10: printk() deadlocks