[PATCH 018/18] kdb-add-kdump-cmd

jidong xiao jidong.xiao at gmail.com
Fri Jul 11 08:24:44 PDT 2008


On Fri, Jul 11, 2008 at 10:37 PM, Joe Korty <joe.korty at ccur.com> wrote:
> On Fri, Jul 11, 2008 at 02:16:45AM -0400, jidong xiao wrote:
>> As I understand kexec/kdump code is arch dependent, but from your
>> patch there is no arch specific piece of code, please can you explain
>> this?
>>
>> Thanks
>> Jason Xiao
>
> Hi Jason,
> Well, kdump has a generic component as well a per-arch
> support components, so I guess if one is on an arch where
> the per-arch component is not present the the call to
> crash_kexec() will (hopefully) NOP.  However, I am not a
> user of kdump, and we are (so far) an x86-only shop, so the
> behavour of crash_kexec() on other arches is unknown to me.
>
> I've forwarded your letter to the author of the patch,
> perhaps he will be able to provide additional illumination.
>
> Regards,
> Joe

If I understand correctly, you are trying to add kexec/kdump
functionality into kdb. say, input "kdump" after the kdb prompt, then
kdump will begin to dump.

This is actually already implemented by Dan some time back, you can
refer to following link,
http://www.mail-archive.com/kdb@oss.sgi.com/msg01358.html

With this patch you can drop into kdb and enter "kdump", below is the demo:

Jason login:

Entering kdb (task 0xffffffff802fcae0 pid 0) on cpu 0 due to Keyboard Entry

[0]kdb> kdump

Linux version 2.6.18-53.el5 (root at Jason) (gcc version 4.1.2 20070626
(Red Hat 4.1.2-14)) #1 SMP Sat Jan 19 21:31:58 EST 2008

Command line: root=/dev/sda12 console=ttyS0,9600 console=tty0  irqpoll
maxcpus=1 reset_devices=1 memmap=exactmap memmap=640K at 0K
memmap=5508K at 16384K memmap=124908K at 22532K elfcorehdr=147440K
memmap=63K#340752K

BIOS-provided physical RAM map:

 BIOS-e820: 0000000000000100 - 00000000000a0000 (usable)

 BIOS-e820: 0000000000100000 - 00000000cffa8000 (usable)

 BIOS-e820: 00000000cffa8000 - 00000000cffb7c00 (ACPI data)

 BIOS-e820: 00000000cffb7c00 - 00000000d0000000 (reserved)

 BIOS-e820: 00000000e0000000 - 00000000f0000000 (reserved)

 BIOS-e820: 00000000fe000000 - 0000000100000000 (reserved)

 BIOS-e820: 0000000100000000 - 0000000230000000 (usable)
...
...


Though his patch is against x86_64, it's not difficult to port to
i386. I once tried this. But porting to ia64 is a little bit
complicated.

So I don't quite understand why you are modify the source code under
modules/ subdirectory.

Regards
Jason

>
>> On Fri, Jul 11, 2008 at 4:57 AM,  <quilt at tsunami.ccur.com> wrote:
>> > Add kdump command to KDB.  This command triggers
>> > a dump of the kernel via the kexec/kdump mechanism.
>> >
>> > Author: Jim Houston <jim.houston at ccur.com>
>> > Signed-off-by: Joe Korty <joe.korty at ccur.com>
>> >
>> > Index: 2.6.26-rc9/kdb/modules/Makefile
>> > ===================================================================
>> > --- 2.6.26-rc9.orig/kdb/modules/Makefile        2008-07-10 12:14:15.000000000 -0400
>> > +++ 2.6.26-rc9/kdb/modules/Makefile     2008-07-10 13:41:59.000000000 -0400
>> > @@ -6,7 +6,7 @@
>> >  # Copyright (c) 1999-2006 Silicon Graphics, Inc.  All Rights Reserved.
>> >  #
>> >
>> > -obj-$(CONFIG_KDB_MODULES) += kdbm_pg.o kdbm_task.o kdbm_vm.o kdbm_sched.o
>> > +obj-$(CONFIG_KDB_MODULES) += kdbm_pg.o kdbm_task.o kdbm_vm.o kdbm_sched.o kdbm_kdump.o
>> >  obj-m += kdbm_debugtypes.o
>> >  ifdef CONFIG_X86
>> >  obj-$(CONFIG_KDB_MODULES) += kdbm_x86.o
>> > Index: 2.6.26-rc9/kdb/modules/kdbm_kdump.c
>> > ===================================================================
>> > --- /dev/null   1970-01-01 00:00:00.000000000 +0000
>> > +++ 2.6.26-rc9/kdb/modules/kdbm_kdump.c 2008-07-10 13:40:59.000000000 -0400
>> > @@ -0,0 +1,43 @@
>> > +/*
>> > + * This file is subject to the terms and conditions of the GNU General Public
>> > + * License.  See the file "COPYING" in the main directory of this archive
>> > + * for more details.
>> > + *
>> > + * Copyright (c) 2006 Concurrent Computer Corp
>> > + */
>> > +
>> > +#include <linux/kdb.h>
>> > +#include <linux/kdbprivate.h>
>> > +#include <linux/module.h>
>> > +#include <linux/init.h>
>> > +#include <linux/irq.h>
>> > +#include <linux/sched.h>
>> > +#include <linux/kexec.h>
>> > +
>> > +
>> > +MODULE_AUTHOR("Concurrent Computer Corp");
>> > +MODULE_DESCRIPTION("interface to request kdump crash dump");
>> > +MODULE_LICENSE("GPL");
>> > +
>> > +static int
>> > +kdbm_kdump(int argc, const char **argv)
>> > +{
>> > +       kdb_printf("Calling crash_kexec\n");
>> > +       crash_kexec(get_irq_regs());
>> > +       kdb_printf("crash_kexec failed\n");
>> > +       return 0;
>> > +}
>> > +
>> > +static int __init kdbm_kdump_init(void)
>> > +{
>> > +       kdb_register("kdump",  kdbm_kdump, "", "request kdump crash dump", 0);
>> > +       return 0;
>> > +}
>> > +
>> > +static void __exit kdbm_kdump_exit(void)
>> > +{
>> > +       kdb_unregister("kdump");
>> > +}
>> > +
>> > +module_init(kdbm_kdump_init)
>> > +module_exit(kdbm_kdump_exit)
>> > Index: 2.6.26-rc9/kernel/kexec.c
>> > ===================================================================
>> > --- 2.6.26-rc9.orig/kernel/kexec.c      2008-07-10 12:12:51.000000000 -0400
>> > +++ 2.6.26-rc9/kernel/kexec.c   2008-07-10 13:40:59.000000000 -0400
>> > @@ -19,6 +19,7 @@
>> >  #include <linux/reboot.h>
>> >  #include <linux/ioport.h>
>> >  #include <linux/hardirq.h>
>> > +#include <linux/module.h>
>> >  #include <linux/elf.h>
>> >  #include <linux/elfcore.h>
>> >  #include <linux/utsrelease.h>
>> > @@ -1077,6 +1078,7 @@
>> >                BUG_ON(!locked);
>> >        }
>> >  }
>> > +EXPORT_SYMBOL_GPL(crash_kexec);
>> >
>> >  static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data,
>> >                            size_t data_len)
>
---------------------------
Use http://oss.sgi.com/ecartis to modify your settings or to unsubscribe.


More information about the kdb mailing list