[PATCH v2] kdump: Add udev events for memory online/offline

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2011-10-28 at 15:46 -0700, Andrew Morton wrote:
> On Thu, 27 Oct 2011 11:32:45 +0200

[snip]

> I think a safer place from which to send the uevent is
> memory_block_change_state() or even memory_block_action().  Because if
> either of those functions later gets new callers, those callers might
> forget to send the uevent?

Ok fine. I put the code into memory_block_change_state(). This also has
the advantage that we are serialized by "mem->state_mutex". Not sure if
we need that, but for CPU hotplug the udev events are also serialized
with a lock. See  "drivers/base/cpu.c" -> cpu_hotplug_driver_lock()

Do you think the following patch is acceptable?
---
From: Michael Holzheu <holzheu@xxxxxxxxxxxxxxxxxx>

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 <holzheu at linux.vnet.ibm.com>
---
 drivers/base/memory.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -291,11 +291,22 @@ static int memory_block_change_state(str
 
 	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;





[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux