From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yasuaki Ishimatsu Subject: [RFC PATCH v3 6/13] memory-hotplug : add memory_block_release Date: Mon, 9 Jul 2012 19:27:52 +0900 Message-ID: <4FFAB228.3090101@jp.fujitsu.com> References: <4FFAB0A2.8070304@jp.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-2022-JP" Content-Transfer-Encoding: 7bit Return-path: Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:44551 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752414Ab2GIK2J (ORCPT ); Mon, 9 Jul 2012 06:28:09 -0400 In-Reply-To: <4FFAB0A2.8070304@jp.fujitsu.com> Sender: linux-acpi-owner@vger.kernel.org List-Id: linux-acpi@vger.kernel.org To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org Cc: rientjes@google.com, liuj97@gmail.com, len.brown@intel.com, benh@kernel.crashing.org, paulus@samba.org, cl@linux.com, minchan.kim@gmail.com, akpm@linux-foundation.org, kosaki.motohiro@jp.fujitsu.com, wency@cn.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. 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: Christoph Lameter Cc: Minchan Kim CC: Andrew Morton CC: KOSAKI Motohiro CC: Wen Congyang Signed-off-by: Yasuaki Ishimatsu --- drivers/base/memory.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) Index: linux-3.5-rc6/drivers/base/memory.c =================================================================== --- linux-3.5-rc6.orig/drivers/base/memory.c 2012-07-09 18:10:54.880076739 +0900 +++ linux-3.5-rc6/drivers/base/memory.c 2012-07-09 18:19:20.471755922 +0900 @@ -109,6 +109,15 @@ bool is_memblk_offline(unsigned long sta } EXPORT_SYMBOL(is_memblk_offline); +#define to_memory_block(device) container_of(device, struct memory_block, dev) + +static void release_memory_block(struct device *dev) +{ + struct memory_block *mem = to_memory_block(dev); + + kfree(mem); +} + /* * register_memory - Setup a sysfs device for a memory block */ @@ -119,6 +128,7 @@ int register_memory(struct memory_block 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; @@ -669,7 +679,6 @@ int remove_memory_block(unsigned long no mem_remove_simple_file(mem, phys_device); mem_remove_simple_file(mem, removable); unregister_memory(mem); - kfree(mem); } else kobject_put(&mem->dev.kobj); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753030Ab2GIK2N (ORCPT ); Mon, 9 Jul 2012 06:28:13 -0400 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:44551 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752414Ab2GIK2J (ORCPT ); Mon, 9 Jul 2012 06:28:09 -0400 X-SecurityPolicyCheck: OK by SHieldMailChecker v1.7.4 Message-ID: <4FFAB228.3090101@jp.fujitsu.com> Date: Mon, 9 Jul 2012 19:27:52 +0900 From: Yasuaki Ishimatsu User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: , , , CC: , , , , , , , , , Subject: [RFC PATCH v3 6/13] memory-hotplug : add memory_block_release References: <4FFAB0A2.8070304@jp.fujitsu.com> In-Reply-To: <4FFAB0A2.8070304@jp.fujitsu.com> Content-Type: text/plain; charset="ISO-2022-JP" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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: Christoph Lameter Cc: Minchan Kim CC: Andrew Morton CC: KOSAKI Motohiro CC: Wen Congyang Signed-off-by: Yasuaki Ishimatsu --- drivers/base/memory.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) Index: linux-3.5-rc6/drivers/base/memory.c =================================================================== --- linux-3.5-rc6.orig/drivers/base/memory.c 2012-07-09 18:10:54.880076739 +0900 +++ linux-3.5-rc6/drivers/base/memory.c 2012-07-09 18:19:20.471755922 +0900 @@ -109,6 +109,15 @@ bool is_memblk_offline(unsigned long sta } EXPORT_SYMBOL(is_memblk_offline); +#define to_memory_block(device) container_of(device, struct memory_block, dev) + +static void release_memory_block(struct device *dev) +{ + struct memory_block *mem = to_memory_block(dev); + + kfree(mem); +} + /* * register_memory - Setup a sysfs device for a memory block */ @@ -119,6 +128,7 @@ int register_memory(struct memory_block 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; @@ -669,7 +679,6 @@ int remove_memory_block(unsigned long no mem_remove_simple_file(mem, phys_device); mem_remove_simple_file(mem, removable); unregister_memory(mem); - kfree(mem); } else kobject_put(&mem->dev.kobj); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx131.postini.com [74.125.245.131]) by kanga.kvack.org (Postfix) with SMTP id AFF1C6B0078 for ; Mon, 9 Jul 2012 06:28:10 -0400 (EDT) Received: from m2.gw.fujitsu.co.jp (unknown [10.0.50.72]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id 52C5A3EE0BC for ; Mon, 9 Jul 2012 19:28:09 +0900 (JST) Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id 3630445DE52 for ; Mon, 9 Jul 2012 19:28:09 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id 174F945DD78 for ; Mon, 9 Jul 2012 19:28:09 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 00DD11DB8038 for ; Mon, 9 Jul 2012 19:28:09 +0900 (JST) Received: from g01jpexchyt01.g01.fujitsu.local (g01jpexchyt01.g01.fujitsu.local [10.128.194.40]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id A25D61DB8041 for ; Mon, 9 Jul 2012 19:28:08 +0900 (JST) Message-ID: <4FFAB228.3090101@jp.fujitsu.com> Date: Mon, 9 Jul 2012 19:27:52 +0900 From: Yasuaki Ishimatsu MIME-Version: 1.0 Subject: [RFC PATCH v3 6/13] memory-hotplug : add memory_block_release References: <4FFAB0A2.8070304@jp.fujitsu.com> In-Reply-To: <4FFAB0A2.8070304@jp.fujitsu.com> Content-Type: text/plain; charset="ISO-2022-JP" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org Cc: rientjes@google.com, liuj97@gmail.com, len.brown@intel.com, benh@kernel.crashing.org, paulus@samba.org, cl@linux.com, minchan.kim@gmail.com, akpm@linux-foundation.org, kosaki.motohiro@jp.fujitsu.com, wency@cn.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. 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: Christoph Lameter Cc: Minchan Kim CC: Andrew Morton CC: KOSAKI Motohiro CC: Wen Congyang Signed-off-by: Yasuaki Ishimatsu --- drivers/base/memory.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) Index: linux-3.5-rc6/drivers/base/memory.c =================================================================== --- linux-3.5-rc6.orig/drivers/base/memory.c 2012-07-09 18:10:54.880076739 +0900 +++ linux-3.5-rc6/drivers/base/memory.c 2012-07-09 18:19:20.471755922 +0900 @@ -109,6 +109,15 @@ bool is_memblk_offline(unsigned long sta } EXPORT_SYMBOL(is_memblk_offline); +#define to_memory_block(device) container_of(device, struct memory_block, dev) + +static void release_memory_block(struct device *dev) +{ + struct memory_block *mem = to_memory_block(dev); + + kfree(mem); +} + /* * register_memory - Setup a sysfs device for a memory block */ @@ -119,6 +128,7 @@ int register_memory(struct memory_block 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; @@ -669,7 +679,6 @@ int remove_memory_block(unsigned long no mem_remove_simple_file(mem, phys_device); mem_remove_simple_file(mem, removable); unregister_memory(mem); - kfree(mem); } else kobject_put(&mem->dev.kobj); -- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from fgwmail5.fujitsu.co.jp (fgwmail5.fujitsu.co.jp [192.51.44.35]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D9D292C0209 for ; Mon, 9 Jul 2012 20:28:10 +1000 (EST) Received: from m4.gw.fujitsu.co.jp (unknown [10.0.50.74]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id 383EB3EE081 for ; Mon, 9 Jul 2012 19:28:09 +0900 (JST) Received: from smail (m4 [127.0.0.1]) by outgoing.m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 2002545DE50 for ; Mon, 9 Jul 2012 19:28:09 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (s4.gw.fujitsu.co.jp [10.0.50.94]) by m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 0930445DE4D for ; Mon, 9 Jul 2012 19:28:09 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id EFEED1DB803B for ; Mon, 9 Jul 2012 19:28:08 +0900 (JST) Received: from g01jpexchyt01.g01.fujitsu.local (g01jpexchyt01.g01.fujitsu.local [10.128.194.40]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id A0BC21DB802F for ; Mon, 9 Jul 2012 19:28:08 +0900 (JST) Message-ID: <4FFAB228.3090101@jp.fujitsu.com> Date: Mon, 9 Jul 2012 19:27:52 +0900 From: Yasuaki Ishimatsu MIME-Version: 1.0 To: , , , Subject: [RFC PATCH v3 6/13] memory-hotplug : add memory_block_release References: <4FFAB0A2.8070304@jp.fujitsu.com> In-Reply-To: <4FFAB0A2.8070304@jp.fujitsu.com> Content-Type: text/plain; charset="ISO-2022-JP" Cc: len.brown@intel.com, wency@cn.fujitsu.com, paulus@samba.org, minchan.kim@gmail.com, kosaki.motohiro@jp.fujitsu.com, rientjes@google.com, cl@linux.com, akpm@linux-foundation.org, liuj97@gmail.com List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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. 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: Christoph Lameter Cc: Minchan Kim CC: Andrew Morton CC: KOSAKI Motohiro CC: Wen Congyang Signed-off-by: Yasuaki Ishimatsu --- drivers/base/memory.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) Index: linux-3.5-rc6/drivers/base/memory.c =================================================================== --- linux-3.5-rc6.orig/drivers/base/memory.c 2012-07-09 18:10:54.880076739 +0900 +++ linux-3.5-rc6/drivers/base/memory.c 2012-07-09 18:19:20.471755922 +0900 @@ -109,6 +109,15 @@ bool is_memblk_offline(unsigned long sta } EXPORT_SYMBOL(is_memblk_offline); +#define to_memory_block(device) container_of(device, struct memory_block, dev) + +static void release_memory_block(struct device *dev) +{ + struct memory_block *mem = to_memory_block(dev); + + kfree(mem); +} + /* * register_memory - Setup a sysfs device for a memory block */ @@ -119,6 +128,7 @@ int register_memory(struct memory_block 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; @@ -669,7 +679,6 @@ int remove_memory_block(unsigned long no mem_remove_simple_file(mem, phys_device); mem_remove_simple_file(mem, removable); unregister_memory(mem); - kfree(mem); } else kobject_put(&mem->dev.kobj);