Re: printk() vs tty_io
From: Ingo Molnar
Date: Thu Dec 15 2011 - 13:09:24 EST
* Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Thu, Dec 15, 2011 at 1:56 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> >
> > We probably could, I can have a closer look, but the main question is,
> > are we going to commit to no wakeups from console implementations? That
> > would mean removing the USB serial console support and other such stuff.
>
> I guess we can't.
>
> So new approach:
>
> - screw it. the rq lock is just too central, you cannot call
> printk from under it. And if you have an oops under it, you're
> screwed.
>
> Peter, why do you want to try to work from under the rq
> lock?
Well, no real strong reason: we had that nasty xtime_lock
related lockup in printk() (which was arguably much worse than
the rq lock dependency - and it got fixed), and everyone assumed
that somehow we could just remove the rq lock dependency from
printk() as well.
It appears we can't - and that's OK.
Was an intellectual excercise which didnt work out.
> - Make a special "debug printk" that is not synchronous. Just
> make it buffer things, and have it actually print out from a
> worker thread or whatever. This one *only* takes the lock for
> that buffer itself, and works everywhere. We could probably
> even do tricks to make it NMI-safe.
We kind of already have such a thing: trace_printk() - which
works from the weirdest of atomic contexts as well.
IIRC Peter uses trace_printk() to develop the scheduler all the
time.
What we could perhaps do is a sort of 'shut up regular printk
and feed all printks into the trace buffers' kind of debug
switch.
> Make code that isn't an oops or other very synchronous
> "have to print out *now*" aim to use this "softer" printk.
For early and nast oopses we have a very primitive printk:
earlyprintk=keep which can just act as a full printk
replacement. I use earlyprintk=keep while regular printk is
disabled (there's no console).
[ earlyprintk can be used to debug everything except printk()
lockups, obviously. ]
Thanks,
Ingo
--
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/