On Fri, Jun 20, 2008 at 11:01:34AM -0700, Eric W. Biederman wrote:Oh. I get it now. I was just looking at how the types of lists protect against additions to the list. Seems an atomic list would do what we want. By definition the functions on such a list should not block. Perhaps there should be a normal_restart() and an emergency_restart(). Currently, on x86, emergency_restart() is called in both sane and error situations. I suppose the firmware could get involved. It's true that the live partitions have no problem until the dead partition is rebooted and memory barriers are raised to the memory the live partitions are accessing. I suppose the rebooting partition could communicate to the firmware in the live partitions. But to communicate to a driver in the OS, and then back again to the firmware in the dead partition might be pretty messy. We do have an atomic panic_notifier_list. How about using that? The functions on the list are supposed to be non-blocking. (currently I only see 5 of them in use -- lguest_panic panic_event wdog_panic_handler panic_happened softlock_panic) Sorry, I'm not understanding that. What is that hook? Perhaps a split of emergency_restart() into normal_restart() and emergency_restart() would reserve emergency_restart() for just those cases. Then we could use the emergency procedures only in the emergency cases. See xpc_system_reboot() [drivers/misc/sgi-xp/xpc_main.c] It is called from the reboot_notifier_list when the system is being rebooted. The driver calls xpc_do_exit() go through its normal exit processing. This involves some significant waiting. And xpc_system_die(). It is called from the die_chain (on ia64). But on x86 there are these couple of cases where no callback occurs from the reboot or panic lists. The driver is to be called back when the kernel is restarted or halted due to some sort of failure. It calls xpc_die_disengage() to notify other partitions to disengage from all references to the dying partition's memory. There is some waiting for the other partitions. -Cliff Below is my current thought for covering the crash_kexec and emergency_restart cases: Subject: [PATCH] panic-notify additions This patch adds scans of the "panic_notifier_list" callback chain in the places where the kernel is going down in an error situation, but in which no notification was provided. Adds 2 calls to atomic_notifier_call_chain() in: crash_kexec(), emergency_restart() Differentiates as to the source of the call with arguments SYS_PANIC, SYS_KEXEC and SYS_EMERGENCY. The panic_notifier_list is used instead of the reboot_notifier_list because it is atomic. That is, by definition, the functions on this type of list run in an atomic context so they must not block. Diffed against 2.6.26-rc6 Signed-off-by: Cliff Wickman <cpw@sgi.com> --- include/linux/notifier.h | 3 +++ kernel/kexec.c | 2 ++ kernel/panic.c | 2 +- kernel/sys.c | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) Index: linux/include/linux/notifier.h =================================================================== --- linux.orig/include/linux/notifier.h +++ linux/include/linux/notifier.h @@ -202,6 +202,9 @@ static inline int notifier_to_errno(int #define SYS_RESTART SYS_DOWN #define SYS_HALT 0x0002 /* Notify of system halt */ #define SYS_POWER_OFF 0x0003 /* Notify of system power off */ +#define SYS_PANIC 0x0004 /* Notify of a panic */ +#define SYS_KEXEC 0x0005 /* Notify of kexec of a kernel */ +#define SYS_EMERGENCY 0x0006 /* Notify of emergency restart */ #define NETLINK_URELEASE 0x0001 /* Unicast netlink socket released */ Index: linux/kernel/kexec.c =================================================================== --- linux.orig/kernel/kexec.c +++ linux/kernel/kexec.c @@ -1068,6 +1068,8 @@ void crash_kexec(struct pt_regs *regs) if (!locked) { if (kexec_crash_image) { struct pt_regs fixed_regs; + atomic_notifier_call_chain(&panic_notifier_list, + SYS_KEXEC, "kexec"); crash_setup_regs(&fixed_regs, regs); crash_save_vmcoreinfo(); machine_crash_shutdown(&fixed_regs); Index: linux/kernel/sys.c =================================================================== --- linux.orig/kernel/sys.c +++ linux/kernel/sys.c @@ -270,6 +270,8 @@ out_unlock: */ void emergency_restart(void) { + atomic_notifier_call_chain(&panic_notifier_list, SYS_EMERGENCY, + "emergency restart"); machine_emergency_restart(); } EXPORT_SYMBOL_GPL(emergency_restart); Index: linux/kernel/panic.c =================================================================== --- linux.orig/kernel/panic.c +++ linux/kernel/panic.c @@ -98,7 +98,7 @@ NORET_TYPE void panic(const char * fmt, smp_send_stop(); #endif - atomic_notifier_call_chain(&panic_notifier_list, 0, buf); + atomic_notifier_call_chain(&panic_notifier_list, SYS_PANIC, buf); if (!panic_blink) panic_blink = no_blink; -- Cliff Wickman Silicon Graphics, Inc. cpw@sgi.com (651) 683-3824 --
| Heiko Carstens | Re: -mm merge plans for 2.6.23 -- sys_fallocate |
| Tarkan Erimer | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Eric W. Biederman | [PATCH 0/10] sysfs network namespace support |
git: | |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| David Miller | [GIT]: Networking |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Natalie Protasevich | [BUG] New Kernel Bugs |
