Print kernel version on console during panic and oops. Sometimes during an oops or panic, we do not get the kernel version from the crash log. For example : [Fri Oct 4 03:49:48 2013][ 204.396041] BUG: unable to handle kernel NULL pointer dereference at 0000000000000010 [Fri Oct 4 03:49:48 2013][ 204.400010] IP: [] rb_insert_color+0x1c/0xe5 [Fri Oct 4 03:49:48 2013][ 204.400010] Oops: 0000 [#1] PREEMPT SMP [Fri Oct 4 03:49:48 2013][ 204.400010] last sysfs file: /sys/devices/pci0000:00/0000:00:08.0/net/ma1/operstate [Fri Oct 4 03:49:48 2013][ 204.400010] Stack: [Fri Oct 4 03:49:48 2013][ 204.400010] Call Trace: [Fri Oct 4 03:49:49 2013][ 204.400010] Code: 06 48 8b 17 83 e2 03 48 09 c2 48 89 17 c9 c3 55 48 89 e5 41 57 41 56 49 89 f6 41 55 49 89 fd 41 54 53 e9 a4 00 00 00 49 83 e4 fc <49> 8b 44 24 10 48 39 c3 75 44 49 8b 44 24 08 48 85 c0 74 08 48 [Fri Oct 4 03:49:49 2013][ 204.400010] RIP [] rb_insert_color+0x1c/0xe5 [Fri Oct 4 03:49:49 2013][ 204.400010] CR2: 0000000000000010 [Fri Oct 4 03:49:51 2013]1RU scd /sys/bus/pci/devices/0000:01:06.0/resource0 found, stopping phys (0xc3e803f2) This is because the console loglevel is lower than the default log level of the printk printing the version. It would be great if we had the kernel version printed along with all the other information. This would help us debug/reporduce the crash with the kernel built with the same change number. Please also note that sometimes it is not possible to get the whole crash log from /var/log/console. The console log is only what we have. Signed-off-by : Ani Sinha Index: linux-2.6.38/arch/x86/kernel/dumpstack.c =================================================================== --- linux-2.6.38.orig/arch/x86/kernel/dumpstack.c +++ linux-2.6.38/arch/x86/kernel/dumpstack.c @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -199,10 +200,10 @@ void dump_stack(void) { unsigned long stack; - printk("Pid: %d, comm: %.20s %s %s %.*s\n", + printk(KERN_EMERG "Pid: %d, comm: %.20s %s %s %.*s\n", current->pid, current->comm, print_tainted(), init_utsname()->release, - (int)strcspn(init_utsname()->version, " "), + (int)strcspn(init_utsname()->version, " "), init_utsname()->version); show_trace(NULL, NULL, &stack); } @@ -304,6 +305,10 @@ int __kprobes __die(const char *str, str printk_address(regs->ip, 1); printk(" RSP <%016lx>\n", regs->sp); #endif + printk(KERN_EMERG "Kernel version : %s %s %.*s\n", print_tainted(), + init_utsname()->release, + (int)strcspn(init_utsname()->version, " "), + init_utsname()->version); return 0; }