Re: memconsole: a virtual console to record the Oops message fordebugging purpose.

From: Pavel Machek
Date: Sun Jun 21 2009 - 03:04:01 EST


On Sun 2009-06-14 09:29:48, Changli Gao wrote:
> Dear Linus:
>
> In the production environment, it is hard to find the causion of an
> Oops message if a bug causes the kernel panics. Though the Oops
> message is printed on the screen, we can't read the whole message in
> most cases due to the size of the screen, and it is hard to save the
> Oops message for debugging. I know kdump is a choice, but it needs
> more memory, and in most cases, Oops messages are enough to find out
> the bugs. The other choices are netconsole and serial line, but they
> both need extra computers.
>
> memconsole as a virtual console, will save the messages into a block
> of boot memory reserved. Because the memory won't be cleaned(if the
> self-check on memory is disabled) between two starts, the oops
> messages as the other console messages will be saved between them, and
> you have a chance to see what happened in the last start.
>
> In order to avoid the corruption of the memory used by memconsole, I
> find the memory from the end to the start.
>
> Here is the code, and the code is mess currently. Am I in the right
> direction? Are my assumptions right?
>
> the following code is appended to the file mm/bootmem.c

Generate proper patch...

> void *memconsole_mem_start = NULL;
> EXPORT_SYMBOL_GPL(memconsole_mem_start);
> unsigned int memconsole_mem_size = 0;
> EXPORT_SYMBOL_GPL(memconsole_mem_size);
>
> static int __init memconsole_setup(char *str)
> {
> unsigned long start;
>
> memconsole_mem_size = simple_strtoul(str, NULL, 10);
> memconsole_mem_size = PAGE_ALIGN(memconsole_mem_size);
> for (start = max_low_pfn - (memconsole_mem_size >> PAGE_SHIFT);
> start >= min_low_pfn;
> start -= (memconsole_mem_size >> PAGE_SHIFT)) {
> if (reserve_bootmem_generic(start << PAGE_SHIFT,
> memconsole_mem_size,
> BOOTMEM_EXCLUSIVE) >= 0)
> break;
> }
> if (start < min_low_pfn)
> panic("Can't reserve bootmem for memconsole\n");
> memconsole_mem_start = phys_to_virt(start << PAGE_SHIFT);
> printk("reserve bootmem for memconsole %u@%p\n",
> memconsole_mem_size, memconsole_mem_start);
>
> return 1;
> }
> __setup("memconsole=", memconsole_setup);
>
> An individual kernel module is used to implement the whole function.

> Certainly, I tested it on my virtual machine, and I did work.

...and test it on real hw...?
Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
--
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/