From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e2.ny.us.ibm.com (e2.ny.us.ibm.com [32.97.182.142]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e2.ny.us.ibm.com", Issuer "Equifax" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id D22E9B70E8 for ; Sat, 2 Oct 2010 04:29:51 +1000 (EST) Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by e2.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o91IEdkr022432 for ; Fri, 1 Oct 2010 14:14:39 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o91ITl6c393988 for ; Fri, 1 Oct 2010 14:29:47 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o91ITicF023116 for ; Fri, 1 Oct 2010 14:29:46 -0400 Message-ID: <4CA62896.2060307@austin.ibm.com> Date: Fri, 01 Oct 2010 13:29:42 -0500 From: Nathan Fontenot MIME-Version: 1.0 To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH 2/9] v3 Add mutex for adding/removing memory blocks References: <4CA62700.7010809@austin.ibm.com> In-Reply-To: <4CA62700.7010809@austin.ibm.com> Content-Type: text/plain; charset=ISO-8859-1 Cc: Greg KH , steiner@sgi.com, Robin Holt , KAMEZAWA Hiroyuki , Dave Hansen List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Add a new mutex for use in adding and removing of memory blocks. This is needed to avoid any race conditions in which the same memory block could be added and removed at the same time. Signed-off-by: Nathan Fontenot --- drivers/base/memory.c | 7 +++++++ 1 file changed, 7 insertions(+) Index: linux-next/drivers/base/memory.c =================================================================== --- linux-next.orig/drivers/base/memory.c 2010-09-30 14:09:36.000000000 -0500 +++ linux-next/drivers/base/memory.c 2010-09-30 14:12:41.000000000 -0500 @@ -27,6 +27,8 @@ #include #include +static DEFINE_MUTEX(mem_sysfs_mutex); + #define MEMORY_CLASS_NAME "memory" static struct sysdev_class memory_sysdev_class = { @@ -476,6 +478,8 @@ if (!mem) return -ENOMEM; + mutex_lock(&mem_sysfs_mutex); + mem->phys_index = __section_nr(section); mem->state = state; mutex_init(&mem->state_mutex); @@ -496,6 +500,7 @@ ret = register_mem_sect_under_node(mem, nid); } + mutex_unlock(&mem_sysfs_mutex); return ret; } @@ -504,6 +509,7 @@ { struct memory_block *mem; + mutex_lock(&mem_sysfs_mutex); mem = find_memory_block(section); unregister_mem_sect_under_nodes(mem); mem_remove_simple_file(mem, phys_index); @@ -512,6 +518,7 @@ mem_remove_simple_file(mem, removable); unregister_memory(mem, section); + mutex_unlock(&mem_sysfs_mutex); return 0; } From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754456Ab0JAS3t (ORCPT ); Fri, 1 Oct 2010 14:29:49 -0400 Received: from e6.ny.us.ibm.com ([32.97.182.146]:48529 "EHLO e6.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753915Ab0JAS3s (ORCPT ); Fri, 1 Oct 2010 14:29:48 -0400 Message-ID: <4CA62896.2060307@austin.ibm.com> Date: Fri, 01 Oct 2010 13:29:42 -0500 From: Nathan Fontenot User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100915 Thunderbird/3.0.8 MIME-Version: 1.0 To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org CC: Greg KH , Dave Hansen , KAMEZAWA Hiroyuki , Robin Holt , steiner@sgi.com Subject: [PATCH 2/9] v3 Add mutex for adding/removing memory blocks References: <4CA62700.7010809@austin.ibm.com> In-Reply-To: <4CA62700.7010809@austin.ibm.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new mutex for use in adding and removing of memory blocks. This is needed to avoid any race conditions in which the same memory block could be added and removed at the same time. Signed-off-by: Nathan Fontenot --- drivers/base/memory.c | 7 +++++++ 1 file changed, 7 insertions(+) Index: linux-next/drivers/base/memory.c =================================================================== --- linux-next.orig/drivers/base/memory.c 2010-09-30 14:09:36.000000000 -0500 +++ linux-next/drivers/base/memory.c 2010-09-30 14:12:41.000000000 -0500 @@ -27,6 +27,8 @@ #include #include +static DEFINE_MUTEX(mem_sysfs_mutex); + #define MEMORY_CLASS_NAME "memory" static struct sysdev_class memory_sysdev_class = { @@ -476,6 +478,8 @@ if (!mem) return -ENOMEM; + mutex_lock(&mem_sysfs_mutex); + mem->phys_index = __section_nr(section); mem->state = state; mutex_init(&mem->state_mutex); @@ -496,6 +500,7 @@ ret = register_mem_sect_under_node(mem, nid); } + mutex_unlock(&mem_sysfs_mutex); return ret; } @@ -504,6 +509,7 @@ { struct memory_block *mem; + mutex_lock(&mem_sysfs_mutex); mem = find_memory_block(section); unregister_mem_sect_under_nodes(mem); mem_remove_simple_file(mem, phys_index); @@ -512,6 +518,7 @@ mem_remove_simple_file(mem, removable); unregister_memory(mem, section); + mutex_unlock(&mem_sysfs_mutex); return 0; } From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail137.messagelabs.com (mail137.messagelabs.com [216.82.249.19]) by kanga.kvack.org (Postfix) with ESMTP id 24B696B0078 for ; Fri, 1 Oct 2010 14:29:50 -0400 (EDT) Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by e4.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o91IE41Z011731 for ; Fri, 1 Oct 2010 14:14:04 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o91ITkY0131688 for ; Fri, 1 Oct 2010 14:29:46 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o91ITicB023116 for ; Fri, 1 Oct 2010 14:29:45 -0400 Message-ID: <4CA62896.2060307@austin.ibm.com> Date: Fri, 01 Oct 2010 13:29:42 -0500 From: Nathan Fontenot MIME-Version: 1.0 Subject: [PATCH 2/9] v3 Add mutex for adding/removing memory blocks References: <4CA62700.7010809@austin.ibm.com> In-Reply-To: <4CA62700.7010809@austin.ibm.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org Cc: Greg KH , Dave Hansen , KAMEZAWA Hiroyuki , Robin Holt , steiner@sgi.com List-ID: Add a new mutex for use in adding and removing of memory blocks. This is needed to avoid any race conditions in which the same memory block could be added and removed at the same time. Signed-off-by: Nathan Fontenot --- drivers/base/memory.c | 7 +++++++ 1 file changed, 7 insertions(+) Index: linux-next/drivers/base/memory.c =================================================================== --- linux-next.orig/drivers/base/memory.c 2010-09-30 14:09:36.000000000 -0500 +++ linux-next/drivers/base/memory.c 2010-09-30 14:12:41.000000000 -0500 @@ -27,6 +27,8 @@ #include #include +static DEFINE_MUTEX(mem_sysfs_mutex); + #define MEMORY_CLASS_NAME "memory" static struct sysdev_class memory_sysdev_class = { @@ -476,6 +478,8 @@ if (!mem) return -ENOMEM; + mutex_lock(&mem_sysfs_mutex); + mem->phys_index = __section_nr(section); mem->state = state; mutex_init(&mem->state_mutex); @@ -496,6 +500,7 @@ ret = register_mem_sect_under_node(mem, nid); } + mutex_unlock(&mem_sysfs_mutex); return ret; } @@ -504,6 +509,7 @@ { struct memory_block *mem; + mutex_lock(&mem_sysfs_mutex); mem = find_memory_block(section); unregister_mem_sect_under_nodes(mem); mem_remove_simple_file(mem, phys_index); @@ -512,6 +518,7 @@ mem_remove_simple_file(mem, removable); unregister_memory(mem, section); + mutex_unlock(&mem_sysfs_mutex); return 0; } -- 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