Re: [PATCH] panic.c: export panic_on_oops

Linus Torvalds
2009-10-12T15:36:38Z

On Mon, 12 Oct 2009, Simon Kagstrom wrote:
>
> Well, this is what my patch [1] aims to fix. What it does is to put all
> messages in a circular buffer, and when an oops or panic occurs it
> writes them out.

Umm. That's wrong. We already _have_ the circular buffer.

It's called 'log_buf'.

I agree with the "save kernel buffer on panic" thing, but I disagree with
making it anything new, and hooking into "printk()" or the console
subsystem AT ALL. That's just bogus, stupid, and WRONG.

What you can do is to just flush the 'log_buf' buffer (or as much of it as
you want - the buffer may be a megabyte in size, and maybe you only want
to flush the last 8kB or something like that) on oops. And _not_ mix this
up with anything else. It's a really simple circular buffer, which just
has

- log_buf: buffer start
- log_end: number of characters ever seen
- log_buf_len: size of buffer (guaranteed to be a power-of-2)

so it's literally as easy as looking at those three values (there's a few
more that you _can_ look at, but they'd not likely be relevant for a
"panic_on_oops" thing)

> The current version only collects messages _during_ an
> oops. I'll rework it with using kfifo as per Alans suggestion though.

Don't. kfifo's aren't going to help. You're doing this at all the wrong
levels ENTIRELY, and we already have the buffer you want to flush.

Linus