From fa42683a02b919546aa885296210476a4b8443f2 Mon Sep 17 00:00:00 2001 From: Michael Holzheu Date: Fri, 2 Dec 2011 14:13:12 +1100 Subject: [PATCH] kdump: add udev events for memory online/offline Currently no udev events for memory hotplug "online" and "offline" are generated: # udevadm monitor # echo offline > /sys/devices/system/memory/memory4/state ==> No event When kdump is loaded, kexec detects the current memory configuration and stores it in the pre-allocated ELF core header. Therefore, for kdump it is necessary to reload the kdump kernel with kexec when the memory configuration changes (e.g. for online/offline hotplug memory). In order to do this automatically, udev rules should be used. This kernel patch adds udev events for "online" and "offline". Together with this kernel patch, the following udev rules for online/offline have to be added to "/etc/udev/rules.d/98-kexec.rules": SUBSYSTEM=="memory", ACTION=="online", PROGRAM="/etc/init.d/kdump restart" SUBSYSTEM=="memory", ACTION=="offline", PROGRAM="/etc/init.d/kdump restart" Signed-off-by: Michael Holzheu Cc: Heiko Carstens Cc: Vivek Goyal Cc: "Eric W. Biederman" Cc: Kay Sievers Cc: Dave Hansen Cc: Martin Schwidefsky Cc: Greg KH Signed-off-by: Andrew Morton --- drivers/base/memory.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 8272d92d22c0..9408829b46b4 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -313,11 +313,22 @@ static int memory_block_change_state(struct memory_block *mem, ret = memory_block_action(mem->start_section_nr, to_state); - if (ret) + if (ret) { mem->state = from_state_req; - else - mem->state = to_state; + goto out; + } + mem->state = to_state; + switch (mem->state) { + case MEM_OFFLINE: + kobject_uevent(&mem->sysdev.kobj, KOBJ_OFFLINE); + break; + case MEM_ONLINE: + kobject_uevent(&mem->sysdev.kobj, KOBJ_ONLINE); + break; + default: + break; + } out: mutex_unlock(&mem->state_mutex); return ret; -- 2.39.2