[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.01.0910121130190.3438@localhost.localdomain>
Date: Mon, 12 Oct 2009 11:45:15 -0700 (PDT)
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Ingo Molnar <mingo@...e.hu>
cc: Andrew Morton <akpm@...ux-foundation.org>,
Simon Kagstrom <simon.kagstrom@...insight.net>,
Artem Bityutskiy <dedekind1@...il.com>,
David Woodhouse <dwmw2@...radead.org>,
LKML <linux-kernel@...r.kernel.org>,
"Koskinen Aaro (Nokia-D/Helsinki)" <aaro.koskinen@...ia.com>,
linux-mtd <linux-mtd@...ts.infradead.org>,
Alan Cox <alan@...rguk.ukuu.org.uk>
Subject: Re: [PATCH] panic.c: export panic_on_oops
On Mon, 12 Oct 2009, Ingo Molnar wrote:
>
> * Andrew Morton <akpm@...ux-foundation.org> wrote:
> >
> > Perhaps oops_enter() is a good place to mark the start of the log, and
> > flush it within oops_exit().
>
> Simplest would be to do the last 2K in oops_exit()? That gives the oops,
> and the history leading up to it. Since the blocking is 2K, the extra
> log output is for free.
I agree, except I don't think it should be fixed to 2k.
We should just dump as much as is "appropriate" for the dump device. It
might be the last 2kB, it might be 8kB, it might be 64kB. We don't know,
we don't care. The device may have its own per-device limits. Any extra
data we get from before the oops is just gravy (often there might be
interestign warning messages leadign up to the dump), and if the oops is
too big for the dump device, it's not something we can do anything about
anyway.
So the logic should literally be something like this:
- kernel/printk.c:
void dump_kmsg(void)
{
unsigned long len = ACCESS_ONCE(log_end);
struct dump_device *dump;
const char *s1, *s2;
unsigned long l1, l2;
s1 = "";
l1 = 0;
s2 = log_buf;
l2 = len;
/* Have we rotated around the circular buffer? */
if (len > log_buf_len) {
unsigned long pos = (len & LOG_BUF_MASK);
s1 = log_buf + pos;
l1 = log_buf_len - pos;
s2 = log_buf;
l2 = pos;
}
list_for_each_entry (dump, dump_list, list) {
dump->fn(s1, l1, s2, l2);
}
}
ie we just always give the whole buffer (as two "sections", since it's a
circular buffer) to the dumper, and then the dumper can decide how much of
those buffers it is able to dump sanely.
If the dumper has some hardware limitation where it can only dump a single
aligned block, it can decide to just look at <s2,l2> which is the "latter"
part of the dump. It's usually going to be fine, and it should be
page-aligned (and you can even round up the size to a page, since the
worst that can happen is that you'll see some old printk output at the
end)
Look ma, no locking, no buffer allocations, no nothing.
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists