Subject: Re: linux-next: build failure after merge of the akpm tree

From: Andrew Morton <[email-masked]>
Date: Thu, 5 Jan 2012 15:45:15 -0800

On Thu, 5 Jan 2012 15:19:58 -0800
Greg KH <[email-masked]> wrote:

> On Thu, Jan 05, 2012 at 06:29:37PM +1100, Stephen Rothwell wrote:
> > Hi Andrew,
> > 
> > After merging the akpm tree, today's linux-next build (powerpc
> > ppc64_defconfig) failed like this:
> > 
> > drivers/base/memory.c: In function 'memory_block_change_state':
> > drivers/base/memory.c:306:22: error: 'struct memory_block' has no member named 'sysdev'
> > drivers/base/memory.c:309:22: error: 'struct memory_block' has no member named 'sysdev'
> > 
> > Caused by commit 2691cc121386 ("kdump: add udev events for memory
> > online/offline") interacting with commit 10fbcf4c6cb1 ("convert 'memory'
> > sysdev_class to a regular subsystem") from the driver-core tree.
> 
> I can't recall this kdump patch coming through before, have I seen it?

I carefully added you to the Nov 22 commit email cc list :(

> creating new uevents is not something to be done lightly, has this been
> tested with the existing userspace tools to make sure it doesn't cause
> problems?

Seems to be covered in the changelog:

From: Michael Holzheu <[email-masked]>
Subject: 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 <[email-masked]>
Cc: Heiko Carstens <[email-masked]>
Cc: Vivek Goyal <[email-masked]>
Cc: "Eric W. Biederman" <[email-masked]>
Cc: Kay Sievers <[email-masked]>
Cc: Dave Hansen <[email-masked]>
Cc: Martin Schwidefsky <[email-masked]>
Cc: Greg KH <[email-masked]>
Signed-off-by: Andrew Morton <[email-masked]>
---

 drivers/base/memory.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff -puN drivers/base/memory.c~kdump-add-udev-events-for-memory-online-offline drivers/base/memory.c
--- a/drivers/base/memory.c~kdump-add-udev-events-for-memory-online-offline
+++ a/drivers/base/memory.c
@@ -313,11 +313,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;
_