linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/7] drivers: base: move mutex lock out of add_memory_section()
@ 2013-08-20 17:12 Seth Jennings
  2013-08-20 17:12 ` [PATCH 2/7] drivers: base: remove unneeded variable Seth Jennings
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Seth Jennings @ 2013-08-20 17:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Seth Jennings, Dave Hansen, Nathan Fontenot, Cody P Schafer,
	Andrew Morton, Lai Jiangshan, Rafael J. Wysocki, Yinghai Lu,
	Wanpeng Li, linux-kernel, linux-mm, linuxppc-dev

There is no point in releasing the mutex for each section that is added
during boot time.  Just hold it over the entire initialization loop.

Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
---
 drivers/base/memory.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 2b7813e..278bb3da 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -613,8 +613,6 @@ static int add_memory_section(int nid, struct mem_section *section,
 	int scn_nr = __section_nr(section);
 	int ret = 0;
 
-	mutex_lock(&mem_sysfs_mutex);
-
 	if (context == BOOT) {
 		/* same memory block ? */
 		if (mem_p && *mem_p)
@@ -643,7 +641,6 @@ static int add_memory_section(int nid, struct mem_section *section,
 			ret = register_mem_sect_under_node(mem, nid);
 	}
 
-	mutex_unlock(&mem_sysfs_mutex);
 	return ret;
 }
 
@@ -653,7 +650,13 @@ static int add_memory_section(int nid, struct mem_section *section,
  */
 int register_new_memory(int nid, struct mem_section *section)
 {
-	return add_memory_section(nid, section, NULL, MEM_OFFLINE, HOTPLUG);
+	int ret;
+
+	mutex_lock(&mem_sysfs_mutex);
+	ret = add_memory_section(nid, section, NULL, MEM_OFFLINE, HOTPLUG);
+	mutex_unlock(&mem_sysfs_mutex);
+
+	return ret;
 }
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
@@ -746,6 +749,7 @@ int __init memory_dev_init(void)
 	 * Create entries for memory sections that were found
 	 * during boot and have been initialized
 	 */
+	mutex_lock(&mem_sysfs_mutex);
 	for (i = 0; i < NR_MEM_SECTIONS; i++) {
 		if (!present_section_nr(i))
 			continue;
@@ -757,6 +761,7 @@ int __init memory_dev_init(void)
 		if (!ret)
 			ret = err;
 	}
+	mutex_unlock(&mem_sysfs_mutex);
 
 out:
 	if (ret)
-- 
1.8.3.4

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-08-22 15:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-20 17:12 [PATCH 1/7] drivers: base: move mutex lock out of add_memory_section() Seth Jennings
2013-08-20 17:12 ` [PATCH 2/7] drivers: base: remove unneeded variable Seth Jennings
2013-08-20 17:12 ` [PATCH 3/7] drivers: base: use device get/put functions Seth Jennings
2013-08-20 17:13 ` [PATCH 4/7] drivers: base: unshare add_memory_section() from hotplug Seth Jennings
2013-08-20 17:13 ` [PATCH 5/7] drivers: base: reduce add_memory_section() for boot-time only Seth Jennings
2013-08-20 17:13 ` [PATCH 6/7] drivers: base: remove improper get/put in add_memory_section() Seth Jennings
2013-08-20 17:13 ` [PATCH 7/7] drivers: base: refactor add_memory_section() to add_memory_block() Seth Jennings
2013-08-22  8:20   ` Yasuaki Ishimatsu
2013-08-22  8:30     ` Yasuaki Ishimatsu
2013-08-22 15:11     ` Seth Jennings
2013-08-20 17:24 ` [PATCH 1/7] drivers: base: move mutex lock out of add_memory_section() Seth Jennings
2013-08-21 18:50   ` Greg Kroah-Hartman
2013-08-22  8:44   ` Yasuaki Ishimatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).