kexec/kdump and the ia64 test tree
Subsystems (3)
The kexec/kdump patch in my test tree is very stale, plus it is time for some git maintenance on the test tree (to clean away all the "Auto-update from upstream" commits that my workflow generates). So I'm planning on resetting my "test" branch to Linus-latest + kdump/kexec (so git pull/fetch will barf on my test tree, you'll need to re-clone).
Below I've include what I believe to be the latest version of the patch produced by:
1) Take 2.6.18
2) Apply Nan Hai patch for 2.6.18 (posted Sept 20th)
3) Pull in Linus-latest (c972398b ...) and resolve conflicts in smp.h, sysctl.h
4) Apply Nan hai's "Fix OS_INIT" patch that fixed Indou-san's deadlock issue (Sept 28th)
5) Fix a few warnings:
arch/ia64/kernel/iosapic.c:
`vec' may be used before set in kexec_disable_iosapic() ... I'm not totally confident that I fixed this right. Please look closely at what I did.
arch/ia64/kernel/smp.c:
Trivial fixes to stop compiler complaining that kdump_smp_send_stop() and kdump_smp_send_init() definitions were not prototypes.
6) Lots of white-space cleanup (mostly multiple spaces that should be tabs, but I also threw the whole kdump_find_rsvd_region() in arch/ia64/kernel/efi.c through scripts/Lindent as it was only using two-spaces for indentation.)
Let me know if I've goofed up the patch during this process.
I'm planning to reset my test tree on Monday (Oct 2nd).
-Tony
arch/ia64/Kconfig +23 -0
@@ -433,6 +433,29 @@ config IA64_ESI source "drivers/sn/Kconfig" +config KEXEC + bool "kexec system call (EXPERIMENTAL)" + depends on EXPERIMENTAL && !IA64_HP_SIM + help + kexec is a system call that implements the ability to shutdown your + current kernel, and to start another kernel. It is like a reboot + but it is indepedent of the system firmware. And like a reboot + you can start any kernel with it, not just Linux. + + The name comes from the similiarity to the exec system call. + + It is an ongoing process to be certain the hardware in a machine + is properly shutdown, so do not be surprised if this code does not + initially work for you. It may help to enable device hotplugging + support. As of this writing the exact hardware interface is + strongly in flux, so no good recommendation can be made. + +config CRASH_DUMP + bool "kernel crash dumps (EXPERIMENTAL)" + depends on EXPERIMENTAL && IA64_MCA_RECOVERY && !IA64_HP_SIM + help + Generate crash dump after being started by kexec. + source "drivers/firmware/Kconfig" source "fs/Kconfig.binfmt"
arch/ia64/kernel/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_IA64_CYCLONE) += cyclone.o obj-$(CONFIG_CPU_FREQ) += cpufreq/ obj-$(CONFIG_IA64_MCA_RECOVERY) += mca_recovery.o obj-$(CONFIG_KPROBES) += kprobes.o jprobes.o +obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o obj-$(CONFIG_AUDIT) += audit.o mca_recovery-y += mca_drv.o mca_drv_asm.o
arch/ia64/kernel/crash.c new file +234 -0
234 lines not on this page · raw message
arch/ia64/kernel/efi.c +62 -3
107 lines not on this page · raw message
arch/ia64/kernel/entry.S +1 -1
@@ -1575,7 +1575,7 @@ sys_call_table: data8 sys_mq_timedreceive // 1265 data8 sys_mq_notify data8 sys_mq_getsetattr - data8 sys_ni_syscall // reserved for kexec_load + data8 sys_kexec_load data8 sys_ni_syscall // reserved for vserver data8 sys_waitid // 1270 data8 sys_add_key
arch/ia64/kernel/iosapic.c +22 -0
@@ -288,6 +288,28 @@ nop (unsigned int irq)/* do nothing... */ } + +#ifdef CONFIG_KEXEC +void +kexec_disable_iosapic (void ) +{ +struct iosapic_intr_info *info; +struct iosapic_rte_info *rte; +ia64_vector vec =0 ; + +for (info = iosapic_intr_info; info < + iosapic_intr_info +IA64_NUM_VECTORS ; ++info, ++vec) { +list_for_each_entry (rte, &info->rtes, + rte_list) { +iosapic_write (rte->addr, +IOSAPIC_RTE_LOW (rte->rte_index), +IOSAPIC_MASK ); +iosapic_eoi (rte->addr, vec); + } + } +} +#endif +static void mask_irq (unsigned int irq) {
arch/ia64/kernel/machine_kexec.c new file +138 -0
138 lines not on this page · raw message
arch/ia64/kernel/relocate_kernel.S new file +489 -0
489 lines not on this page · raw message
arch/ia64/kernel/setup.c +35 -0
@@ -43,6 +43,8 @@ #include <linux/efi.h>#include <linux/initrd.h> #include <linux/pm.h> #include <linux/cpufreq.h> +#include <linux/kexec.h> +#include <linux/crash_dump.h> #include <asm/ia32.h> #include <asm/machvec.h>
@@ -253,6 +255,41 @@ #endifefi_memmap_init (&rsvd_region[n].start, &rsvd_region[n].end); n++; +#ifdef CONFIG_KEXEC +/* crashkernel=size@offset specifies the size to reserve for a crash +* kernel.(offset is ingored for keep compatibility with other archs) +* By reserving this memory we guarantee that linux never set's it +* up as a DMA target.Useful for holding code to do something +* appropriate after a kernel panic. +*/ + { +char *from =strstr (saved_command_line,"crashkernel=" ); +unsigned long base, size; +if (from) { + size =memparse (from +12 , &from); +if (size) { +sort_regions (rsvd_region, n); + base =kdump_find_rsvd_region (size, + rsvd_region, n); +if (base != ~0UL ) { + rsvd_region[n].start + (unsigned long )__va (base); + rsvd_region[n].end + (unsigned long )__va (base + size); + n++; + crashk_res.start = base; + crashk_res.end = base + size -1 ; + } + } + } + efi_memmap_res.start = ia64_boot_param->efi_memmap; + efi_memmap_res.end = efi_memmap_res.start + + ia64_boot_param->efi_memmap_size; + boot_param_res.start =__pa (ia64_boot_param); + boot_param_res.end = boot_param_res.start + +sizeof (*ia64_boot_param); + } +#endif /* end of memory marker */ rsvd_region[n].start = ~0UL ; rsvd_region[n].end = ~0UL ;
arch/ia64/kernel/smp.c +55 -1
86 lines not on this page · raw message
include/asm-ia64/kexec.h new file +53 -0
53 lines not on this page · raw message
include/asm-ia64/meminit.h +2 -1
@@ -15,11 +15,12 @@ #define meminit_h* - initrd (optional) * - command line string * - kernel code & data +* - crash dumping code reserved region * - Kernel memory map built from EFI memory map * * More could be added if necessary */ -#define IA64_MAX_RSVD_REGIONS 6 +#define IA64_MAX_RSVD_REGIONS 7struct rsvd_region {unsigned long start;/* virtual address of beginning of element */
include/asm-ia64/smp.h +3 -0
@@ -127,6 +127,9 @@ extern void lock_ipi_calllock(void);extern void unlock_ipi_calllock (void );extern void identify_siblings (struct cpuinfo_ia64 *);extern int is_multithreading_enabled (void ); +#ifdef CONFIG_KEXEC +extern void kexec_stop_this_cpu (void *); +#endif #else
include/linux/kexec.h +4 -0
@@ -108,6 +108,10 @@ int kexec_should_crash(struct task_strucextern struct kimage *kexec_image;extern struct kimage *kexec_crash_image; +#ifndef kexec_flush_icache_page +#define kexec_flush_icache_page (page) +#endif +#define KEXEC_ON_CRASH 0x00000001#define KEXEC_ARCH_MASK 0xffff0000
include/linux/sysctl.h +1 -0
@@ -152,6 +152,7 @@ enum KERN_MAX_LOCK_DEPTHt, KERN_NMI_WATCHDOGu,/* int: enable/disable nmi watchdog */ KERN_PANIC_ON_NMIv,/* int: whether we will panic on an unrecovered */ + KERN_KDUMP_ON_INITw, /* int: ia64 kdump with INIT */ };
kernel/kexec.c +1 -0
@@ -851,6 +851,7 @@ static int kimage_load_crash_segment(strmemset (ptr + uchunk,0 , mchunk - uchunk); } result =copy_from_user (ptr, buf, uchunk); +kexec_flush_icache_page (page);kunmap (page);if (result) { result = (result <0 ) ? result : -EIO ;
Quoted 25 lines · On Fri, 29 Sep 2006 14:46:23 -0700 Tony Luck <[email protected]> wrote:
The kexec/kdump patch in my test tree is very stale, plus it is time for some git maintenance on the test tree (to clean away all the "Auto-update from upstream" commits that my workflow generates). So I'm planning on resetting my "test" branch to Linus-latest + kdump/kexec (so git pull/fetch will barf on my test tree, you'll need to re-clone).
Below I've include what I believe to be the latest version of the patch produced by:
1) Take 2.6.18
2) Apply Nan Hai patch for 2.6.18 (posted Sept 20th)
3) Pull in Linus-latest (c972398b...) and resolve conflicts insmp.h,sysctl.h
4) Apply Nan hai's "FixOS_INIT" patch that fixed Indou-san's deadlock issue (Sept 28th)
5) Fix a few warnings:
arch/ia64/kernel/iosapic.c:
`vec' may be used before set inkexec_disable_iosapic()... I'm not totally confident that I fixed this right. Please look closely at what I did.
arch/ia64/kernel/smp.c:
Trivial fixes to stop compiler complaining thatkdump_smp_send_stop()andkdump_smp_send_init()definitions were not prototypes.
6) Lots of white-space cleanup (mostly multiple spaces that should be tabs, but I also threw the wholekdump_find_rsvd_region()inarch/ia64/kernel/efi.cthroughscripts/Lindentas it was only using two-spaces for indentation.)
Quoted 4 lines
Let me know if I've goofed up the patch during this process.
I'm planning to reset my test tree on Monday (Oct 2nd).
Thanks Tony.
Rebuilding of the git tree is a non-issue for me - everyone does it all the time and I just do `git-branch -D' and all is happy.
kexec and kdump are discussed on the fastboot list, which I've cc'ed here. IIRC there were concerns about earlier versions of this code.
arch/ia64/Kconfig +23 -0
@@ -433,6 +433,29 @@ config IA64_ESI source "drivers/sn/Kconfig" +config KEXEC + bool "kexec system call (EXPERIMENTAL)" + depends on EXPERIMENTAL && !IA64_HP_SIM + help + kexec is a system call that implements the ability to shutdown your + current kernel, and to start another kernel. It is like a reboot + but it is indepedent of the system firmware. And like a reboot + you can start any kernel with it, not just Linux. + + The name comes from the similiarity to the exec system call. + + It is an ongoing process to be certain the hardware in a machine + is properly shutdown, so do not be surprised if this code does not + initially work for you. It may help to enable device hotplugging + support. As of this writing the exact hardware interface is + strongly in flux, so no good recommendation can be made. + +config CRASH_DUMP + bool "kernel crash dumps (EXPERIMENTAL)" + depends on EXPERIMENTAL && IA64_MCA_RECOVERY && !IA64_HP_SIM + help + Generate crash dump after being started by kexec. + source "drivers/firmware/Kconfig" source "fs/Kconfig.binfmt"
arch/ia64/kernel/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_IA64_CYCLONE) += cyclone.o obj-$(CONFIG_CPU_FREQ) += cpufreq/ obj-$(CONFIG_IA64_MCA_RECOVERY) += mca_recovery.o obj-$(CONFIG_KPROBES) += kprobes.o jprobes.o +obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o obj-$(CONFIG_AUDIT) += audit.o mca_recovery-y += mca_drv.o mca_drv_asm.o
arch/ia64/kernel/crash.c new file +234 -0
234 lines not on this page · raw message
arch/ia64/kernel/efi.c +62 -3
107 lines not on this page · raw message
arch/ia64/kernel/entry.S +1 -1
@@ -1575,7 +1575,7 @@ sys_call_table: data8 sys_mq_timedreceive // 1265 data8 sys_mq_notify data8 sys_mq_getsetattr - data8 sys_ni_syscall // reserved for kexec_load + data8 sys_kexec_load data8 sys_ni_syscall // reserved for vserver data8 sys_waitid // 1270 data8 sys_add_key
arch/ia64/kernel/iosapic.c +22 -0
@@ -288,6 +288,28 @@ nop (unsigned int irq)/* do nothing... */ } + +#ifdef CONFIG_KEXEC +void +kexec_disable_iosapic (void ) +{ +struct iosapic_intr_info *info; +struct iosapic_rte_info *rte; +ia64_vector vec =0 ; + +for (info = iosapic_intr_info; info < + iosapic_intr_info +IA64_NUM_VECTORS ; ++info, ++vec) { +list_for_each_entry (rte, &info->rtes, + rte_list) { +iosapic_write (rte->addr, +IOSAPIC_RTE_LOW (rte->rte_index), +IOSAPIC_MASK ); +iosapic_eoi (rte->addr, vec); + } + } +} +#endif +static void mask_irq (unsigned int irq) {
arch/ia64/kernel/machine_kexec.c new file +138 -0
138 lines not on this page · raw message
arch/ia64/kernel/relocate_kernel.S new file +489 -0
489 lines not on this page · raw message
arch/ia64/kernel/setup.c +35 -0
@@ -43,6 +43,8 @@ #include <linux/efi.h>#include <linux/initrd.h> #include <linux/pm.h> #include <linux/cpufreq.h> +#include <linux/kexec.h> +#include <linux/crash_dump.h> #include <asm/ia32.h> #include <asm/machvec.h>
@@ -253,6 +255,41 @@ #endifefi_memmap_init (&rsvd_region[n].start, &rsvd_region[n].end); n++; +#ifdef CONFIG_KEXEC +/* crashkernel=size@offset specifies the size to reserve for a crash +* kernel.(offset is ingored for keep compatibility with other archs) +* By reserving this memory we guarantee that linux never set's it +* up as a DMA target.Useful for holding code to do something +* appropriate after a kernel panic. +*/ + { +char *from =strstr (saved_command_line,"crashkernel=" ); +unsigned long base, size; +if (from) { + size =memparse (from +12 , &from); +if (size) { +sort_regions (rsvd_region, n); + base =kdump_find_rsvd_region (size, + rsvd_region, n); +if (base != ~0UL ) { + rsvd_region[n].start + (unsigned long )__va (base); + rsvd_region[n].end + (unsigned long )__va (base + size); + n++; + crashk_res.start = base; + crashk_res.end = base + size -1 ; + } + } + } + efi_memmap_res.start = ia64_boot_param->efi_memmap; + efi_memmap_res.end = efi_memmap_res.start + + ia64_boot_param->efi_memmap_size; + boot_param_res.start =__pa (ia64_boot_param); + boot_param_res.end = boot_param_res.start + +sizeof (*ia64_boot_param); + } +#endif /* end of memory marker */ rsvd_region[n].start = ~0UL ; rsvd_region[n].end = ~0UL ;
arch/ia64/kernel/smp.c +55 -1
86 lines not on this page · raw message
include/asm-ia64/kexec.h new file +53 -0
53 lines not on this page · raw message
include/asm-ia64/meminit.h +2 -1
@@ -15,11 +15,12 @@ #define meminit_h* - initrd (optional) * - command line string * - kernel code & data +* - crash dumping code reserved region * - Kernel memory map built from EFI memory map * * More could be added if necessary */ -#define IA64_MAX_RSVD_REGIONS 6 +#define IA64_MAX_RSVD_REGIONS 7struct rsvd_region {unsigned long start;/* virtual address of beginning of element */
include/asm-ia64/smp.h +3 -0
@@ -127,6 +127,9 @@ extern void lock_ipi_calllock(void);extern void unlock_ipi_calllock (void );extern void identify_siblings (struct cpuinfo_ia64 *);extern int is_multithreading_enabled (void ); +#ifdef CONFIG_KEXEC +extern void kexec_stop_this_cpu (void *); +#endif #else
include/linux/kexec.h +4 -0
@@ -108,6 +108,10 @@ int kexec_should_crash(struct task_strucextern struct kimage *kexec_image;extern struct kimage *kexec_crash_image; +#ifndef kexec_flush_icache_page +#define kexec_flush_icache_page (page) +#endif +#define KEXEC_ON_CRASH 0x00000001#define KEXEC_ARCH_MASK 0xffff0000
include/linux/sysctl.h +1 -0
@@ -152,6 +152,7 @@ enum KERN_MAX_LOCK_DEPTHt, KERN_NMI_WATCHDOGu,/* int: enable/disable nmi watchdog */ KERN_PANIC_ON_NMIv,/* int: whether we will panic on an unrecovered */ + KERN_KDUMP_ON_INITw, /* int: ia64 kdump with INIT */ };
kernel/kexec.c +1 -0
@@ -851,6 +851,7 @@ static int kimage_load_crash_segment(strmemset (ptr + uchunk,0 , mchunk - uchunk); } result =copy_from_user (ptr, buf, uchunk); +kexec_flush_icache_page (page);kunmap (page);if (result) { result = (result <0 ) ? result : -EIO ;
Quoted 25 lines · Tony Luck
The kexec/kdump patch in my test tree is very stale, plus it is time for some git maintenance on the test tree (to clean away all the "Auto-update from upstream" commits that my workflow generates). So I'm planning on resetting my "test" branch to Linus-latest + kdump/kexec (so git pull/fetch will barf on my test tree, you'll need to re-clone).
Below I've include what I believe to be the latest version of the patch produced by:
1) Take 2.6.18
2) Apply Nan Hai patch for 2.6.18 (posted Sept 20th)
3) Pull in Linus-latest (c972398b...) and resolve conflicts insmp.h,sysctl.h
4) Apply Nan hai's "FixOS_INIT" patch that fixed Indou-san's deadlock issue (Sept 28th)
5) Fix a few warnings:
arch/ia64/kernel/iosapic.c:
`vec' may be used before set inkexec_disable_iosapic()... I'm not totally confident that I fixed this right. Please look closely at what I did.
arch/ia64/kernel/smp.c:
Trivial fixes to stop compiler complaining thatkdump_smp_send_stop()andkdump_smp_send_init()definitions were not prototypes.
6) Lots of white-space cleanup (mostly multiple spaces that should be tabs, but I also threw the wholekdump_find_rsvd_region()inarch/ia64/kernel/efi.cthroughscripts/Lindentas it was only using two-spaces for indentation.)
Quoted 3 lines
Let me know if I've goofed up the patch during this process.
I'm planning to reset my test tree on Monday (Oct 2nd).
Hi Tony,
overall that plan seems fine to me - though I would have prefred a more incremental approach. I will spend some time today checking over your patch and see if I can spot any insanity.
On a related note, does/did your ia64-test branch have anything of significance in it other than kexec/kdump?
Signature · 3 lines
Horms H: http://www.vergenet.net/~horms/ W: http://www.valinux.co.jp/en/
Quoted 30 lines · Horms
Quoted 25 lines · Tony Luck
The kexec/kdump patch in my test tree is very stale, plus it is time for some git maintenance on the test tree (to clean away all the "Auto-update from upstream" commits that my workflow generates). So I'm planning on resetting my "test" branch to Linus-latest + kdump/kexec (so git pull/fetch will barf on my test tree, you'll need to re-clone).
Below I've include what I believe to be the latest version of the patch produced by:
1) Take 2.6.18
2) Apply Nan Hai patch for 2.6.18 (posted Sept 20th)
3) Pull in Linus-latest (c972398b...) and resolve conflicts insmp.h,sysctl.h
4) Apply Nan hai's "FixOS_INIT" patch that fixed Indou-san's deadlock issue (Sept 28th)
5) Fix a few warnings:
arch/ia64/kernel/iosapic.c:
`vec' may be used before set inkexec_disable_iosapic()... I'm not totally confident that I fixed this right. Please look closely at what I did.
arch/ia64/kernel/smp.c:
Trivial fixes to stop compiler complaining thatkdump_smp_send_stop()andkdump_smp_send_init()definitions were not prototypes.
6) Lots of white-space cleanup (mostly multiple spaces that should be tabs, but I also threw the wholekdump_find_rsvd_region()inarch/ia64/kernel/efi.cthroughscripts/Lindentas it was only using two-spaces for indentation.)Quoted 3 lines
Let me know if I've goofed up the patch during this process.
I'm planning to reset my test tree on Monday (Oct 2nd).
Quoted 8 lines
Hi Tony,
overall that plan seems fine to me - though I would have prefred a more incremental approach. I will spend some time today checking over your patch and see if I can spot any insanity.
On a related note, does/did your ia64-test branch have anything of significance in it other than kexec/kdump?
I looked over these patches and they seem fine. In order to make the check easier for my mind to get around I split the changes out into three separate patches, relative to Nan Hai's latest patch (the 20th September one) + the OS_INIT fix + Linus' tree (d834c16516d..., a bit later than yours but nothing of significance).
1. Remove ioc_iova_disable()
This looks fine as its not called anywhere. I didn't go back and track its history, but presumably just dead code.
2. Make sure vec is initialised in kexec_disable_iosapic()
To be honest I'm not sure if your fix is correct either, but the original code is definately a problem.
3. Whitespace and reformating.
I didn't actually check all of these. What I did was to ask diff to eliminate whitespace-only changes, and then check what was left by hand. Actually, thats how I broke out 1 and 2.
In all, this seems fine. I don't think there are any spurious changes. And the code executes fine (well as fine as any version I have seen) on my Tiger 2.
As I broke out the patches in the course of checking this I have posted them each as a follup to this post, just for reference.
I have also placed them in a tempoary kexec-tony-luck branch of my git tree. Which is Linus's tree (again d834c16516d) + Nan Hai's patches, including the OS_INIT fix. I plan to merge your changes into the master branch once they are finalised.
git://www.kernel.org//pub/scm/linux/kernel/git/horms/kexec-ia64-2.6/
http://www.kernel.org/git/?p=linux/kernel/git/horms/kexec-ia64-2.6.git;a=summary
Quoted 2 lines
overall that plan seems fine to me - though I would have preferred a more incremental approach.
There are conflicting opinions on this on LKML ... some people believe that it is better that the Linux change log represent history as it should have been ... i.e. clean away all the goofs and mis-steps in the sub-trees and send Linus the one true patch (or series of patches) that do exactly what is wanted. For the case of the white-space cleanup part of the kexec/kdump patches, I can solidly get behind this opinion:
I can see no benefit to keeping separate patches that first mess-up the whitespace, and then fix it.
On the other hand ... when there are real code changes involved, there is definite benefit to preserving the dead-end development paths that were abandoned (so that future debugging/development efforts at least have the option to learn from our mistakes). The removal of ioc_iova_disable() almost falls into this category ... except that we have already dropped the places where it was called, so if we preserve it now, it would just be as the addition and immediate removal of some dead code ... which looks to have less historical value.
Quoted 2 lines
I will spend some time today checking
over your patch and see if I can spot any insanity.
Thanks for taking the time to do this.
Quoted 2 lines
On a related note, does/did your ia64-test branch have anything of significance in it other than kexec/kdump?
There were a couple of other patches in "test" that I pulled over to release and sent to Linus. So kexec is all that is in there right now.
-Tony