All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: holzheu@linux.vnet.ibm.com
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
	Kay Sievers <kay.sievers@vrfy.org>,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
	Dave Hansen <haveblue@us.ibm.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	schwidefsky@de.ibm.com, Vivek Goyal <vgoyal@redhat.com>
Subject: Re: [PATCH] kdump: Add udev events for memory online/offline
Date: Fri, 28 Oct 2011 15:46:30 -0700	[thread overview]
Message-ID: <20111028154630.77c7b96c.akpm@linux-foundation.org> (raw)
In-Reply-To: <1319707965.2830.1.camel@br98xy6r>

On Thu, 27 Oct 2011 11:32:45 +0200
Michael Holzheu <holzheu@linux.vnet.ibm.com> wrote:

> From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
> 
> 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@linux.vnet.ibm.com>
> ---
>  drivers/base/memory.c |   10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> --- a/drivers/base/memory.c
> +++ b/drivers/base/memory.c
> @@ -310,11 +310,15 @@ store_mem_state(struct sys_device *dev,
>  
>  	mem = container_of(dev, struct memory_block, sysdev);
>  
> -	if (!strncmp(buf, "online", min((int)count, 6)))
> +	if (!strncmp(buf, "online", min((int)count, 6))) {
>  		ret = memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE);
> -	else if(!strncmp(buf, "offline", min((int)count, 7)))
> +		if (ret == 0)
> +			kobject_uevent(&dev->kobj, KOBJ_ONLINE);
> +	} else if (!strncmp(buf, "offline", min((int)count, 7))) {
>  		ret = memory_block_change_state(mem, MEM_OFFLINE, MEM_ONLINE);
> -
> +		if (ret == 0)
> +			kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
> +	}
>  	if (ret)
>  		return ret;
>  	return count;

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?


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: holzheu@linux.vnet.ibm.com
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
	Vivek Goyal <vgoyal@redhat.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	schwidefsky@de.ibm.com, kexec@lists.infradead.org,
	linux-kernel@vger.kernel.org, Kay Sievers <kay.sievers@vrfy.org>,
	Dave Hansen <haveblue@us.ibm.com>
Subject: Re: [PATCH] kdump: Add udev events for memory online/offline
Date: Fri, 28 Oct 2011 15:46:30 -0700	[thread overview]
Message-ID: <20111028154630.77c7b96c.akpm@linux-foundation.org> (raw)
In-Reply-To: <1319707965.2830.1.camel@br98xy6r>

On Thu, 27 Oct 2011 11:32:45 +0200
Michael Holzheu <holzheu@linux.vnet.ibm.com> wrote:

> From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
> 
> 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@linux.vnet.ibm.com>
> ---
>  drivers/base/memory.c |   10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> --- a/drivers/base/memory.c
> +++ b/drivers/base/memory.c
> @@ -310,11 +310,15 @@ store_mem_state(struct sys_device *dev,
>  
>  	mem = container_of(dev, struct memory_block, sysdev);
>  
> -	if (!strncmp(buf, "online", min((int)count, 6)))
> +	if (!strncmp(buf, "online", min((int)count, 6))) {
>  		ret = memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE);
> -	else if(!strncmp(buf, "offline", min((int)count, 7)))
> +		if (ret == 0)
> +			kobject_uevent(&dev->kobj, KOBJ_ONLINE);
> +	} else if (!strncmp(buf, "offline", min((int)count, 7))) {
>  		ret = memory_block_change_state(mem, MEM_OFFLINE, MEM_ONLINE);
> -
> +		if (ret == 0)
> +			kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
> +	}
>  	if (ret)
>  		return ret;
>  	return count;

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?


  parent reply	other threads:[~2011-10-28 22:46 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-26 16:08 kdump: No udev events for memory hotplug? Michael Holzheu
2011-10-26 16:08 ` Michael Holzheu
2011-10-26 19:24 ` Vivek Goyal
2011-10-26 19:24   ` Vivek Goyal
2011-10-27  7:30   ` Heiko Carstens
2011-10-27  7:30     ` Heiko Carstens
2011-10-27  9:32     ` [PATCH] kdump: Add udev events for memory online/offline Michael Holzheu
2011-10-27  9:32       ` Michael Holzheu
2011-10-28 22:41       ` Andrew Morton
2011-10-28 22:41         ` Andrew Morton
2011-10-28 22:57         ` Dave Hansen
2011-10-28 22:57           ` Dave Hansen
2011-10-28 22:46       ` Andrew Morton [this message]
2011-10-28 22:46         ` Andrew Morton
2011-10-31 13:21         ` [PATCH v2] " Michael Holzheu
2011-10-31 13:21           ` Michael Holzheu
2011-11-14  2:37           ` WANG Cong
2011-10-27 12:45     ` kdump: No udev events for memory hotplug? Dave Hansen
2011-10-27 12:45       ` Dave Hansen
2011-10-27 13:18       ` Américo Wang
2011-10-27 13:18         ` Américo Wang
2011-10-27  7:45 ` Américo Wang
2011-10-27  7:45   ` Américo Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111028154630.77c7b96c.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=haveblue@us.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=holzheu@linux.vnet.ibm.com \
    --cc=kay.sievers@vrfy.org \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=vgoyal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.