From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx195.postini.com [74.125.245.195]) by kanga.kvack.org (Postfix) with SMTP id 1F1F86B0044 for ; Thu, 27 Sep 2012 06:20:15 -0400 (EDT) Received: by qadc11 with SMTP id c11so2172737qad.14 for ; Thu, 27 Sep 2012 03:20:14 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1348724705-23779-2-git-send-email-wency@cn.fujitsu.com> References: <1348724705-23779-1-git-send-email-wency@cn.fujitsu.com> <1348724705-23779-2-git-send-email-wency@cn.fujitsu.com> Date: Thu, 27 Sep 2012 18:20:13 +0800 Message-ID: Subject: Re: [PATCH 1/4] memory-hotplug: add memory_block_release From: Ni zhan Chen Content-Type: multipart/alternative; boundary=20cf300fae61f28a9304caac48e5 Sender: owner-linux-mm@kvack.org List-ID: To: wency@cn.fujitsu.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, rientjes@google.com, liuj97@gmail.com, len.brown@intel.com, benh@kernel.crashing.org, paulus@samba.org, minchan.kim@gmail.com, akpm@linux-foundation.org, kosaki.motohiro@jp.fujitsu.com, isimatu.yasuaki@jp.fujitsu.com --20cf300fae61f28a9304caac48e5 Content-Type: text/plain; charset=ISO-8859-1 Hi Congyang, 2012/9/27 > From: Yasuaki Ishimatsu > > When calling remove_memory_block(), the function shows following message at > device_release(). > > Device 'memory528' does not have a release() function, it is broken and > must > be fixed. > What's the difference between the patch and original implemetation? > remove_memory_block() calls kfree(mem). I think it shouled be called from > device_release(). So the patch implements memory_block_release() > > CC: David Rientjes > CC: Jiang Liu > CC: Len Brown > CC: Benjamin Herrenschmidt > CC: Paul Mackerras > Cc: Minchan Kim > CC: Andrew Morton > CC: KOSAKI Motohiro > CC: Wen Congyang > Signed-off-by: Yasuaki Ishimatsu > --- > drivers/base/memory.c | 9 ++++++++- > 1 files changed, 8 insertions(+), 1 deletions(-) > > diff --git a/drivers/base/memory.c b/drivers/base/memory.c > index 7dda4f7..da457e5 100644 > --- a/drivers/base/memory.c > +++ b/drivers/base/memory.c > @@ -70,6 +70,13 @@ void unregister_memory_isolate_notifier(struct > notifier_block *nb) > } > EXPORT_SYMBOL(unregister_memory_isolate_notifier); > > +static void release_memory_block(struct device *dev) > +{ > + struct memory_block *mem = container_of(dev, struct memory_block, > dev); > + > + kfree(mem); > +} > + > /* > * register_memory - Setup a sysfs device for a memory block > */ > @@ -80,6 +87,7 @@ int register_memory(struct memory_block *memory) > > memory->dev.bus = &memory_subsys; > memory->dev.id = memory->start_section_nr / sections_per_block; > + memory->dev.release = release_memory_block; > > error = device_register(&memory->dev); > return error; > @@ -630,7 +638,6 @@ int remove_memory_block(unsigned long node_id, struct > mem_section *section, > mem_remove_simple_file(mem, phys_device); > mem_remove_simple_file(mem, removable); > unregister_memory(mem); > - kfree(mem); > } else > kobject_put(&mem->dev.kobj); > > -- > 1.7.1 > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: email@kvack.org > --20cf300fae61f28a9304caac48e5 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi=A0Congyang,

2012/9/27 <wency@cn.f= ujitsu.com>
From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

When calling remove_memory_block(), the function shows following message at=
device_release().

Device 'memory528' does not have a release() function, it is broken= and must
be fixed.

What's the difference bet= ween the patch and original implemetation? =A0


remove_memory_block() calls kfree(mem). I think it shouled be called from device_release(). So the patch implements memory_block_release()

CC: David Rientjes <rientjes@goog= le.com>
CC: Jiang Liu <liuj97@gmail.com&= gt;
CC: Len Brown <len.brown@intel.co= m>
CC: Benjamin Herrenschmidt <= benh@kernel.crashing.org>
CC: Paul Mackerras <paulus@samba.org= >
Cc: Minchan Kim <minchan.kim@gm= ail.com>
CC: Andrew Morton <akpm@lin= ux-foundation.org>
CC: KOSAKI Motohiro <k= osaki.motohiro@jp.fujitsu.com>
CC: Wen Congyang <wency@cn.fujit= su.com>
Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
---
=A0drivers/base/memory.c | =A0 =A09 ++++++++-
=A01 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 7dda4f7..da457e5 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -70,6 +70,13 @@ void unregister_memory_isolate_notifier(struct notifier_= block *nb)
=A0}
=A0EXPORT_SYMBOL(unregister_memory_isolate_notifier);

+static void release_memory_block(struct device *dev)
+{
+ =A0 =A0 =A0 struct memory_block *mem =3D container_of(dev, struct memory_= block, dev);
+
+ =A0 =A0 =A0 kfree(mem);
+}
+
=A0/*
=A0 * register_memory - Setup a sysfs device for a memory block
=A0 */
@@ -80,6 +87,7 @@ int register_memory(struct memory_block *memory)

=A0 =A0 =A0 =A0 memory->dev.bus =3D &memory_subsys;
=A0 =A0 =A0 =A0 memory->dev.= id =3D memory->start_section_nr / sections_per_block;
+ =A0 =A0 =A0 memory->dev.release =3D release_memory_block;

=A0 =A0 =A0 =A0 error =3D device_register(&memory->dev);
=A0 =A0 =A0 =A0 return error;
@@ -630,7 +638,6 @@ int remove_memory_block(unsigned long node_id, struct m= em_section *section,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 mem_remove_simple_file(mem, phys_device); =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 mem_remove_simple_file(mem, removable);
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 unregister_memory(mem);
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 kfree(mem);
=A0 =A0 =A0 =A0 } else
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 kobject_put(&mem->dev.kobj);

--
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.= =A0For more info on Linux MM,
see: http://www.linu= x-mm.org/ .
Don't email: <a href=3Dmailto:"dont@kvack.org"> email@kva= ck.org </a>

--20cf300fae61f28a9304caac48e5-- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org