提交 b1eaef3d 编写于 作者: S Seth Jennings 提交者: Greg Kroah-Hartman

drivers: base: move mutex lock out of add_memory_section()

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: NSeth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 65f44679
...@@ -613,8 +613,6 @@ static int add_memory_section(int nid, struct mem_section *section, ...@@ -613,8 +613,6 @@ static int add_memory_section(int nid, struct mem_section *section,
int scn_nr = __section_nr(section); int scn_nr = __section_nr(section);
int ret = 0; int ret = 0;
mutex_lock(&mem_sysfs_mutex);
if (context == BOOT) { if (context == BOOT) {
/* same memory block ? */ /* same memory block ? */
if (mem_p && *mem_p) if (mem_p && *mem_p)
...@@ -643,7 +641,6 @@ static int add_memory_section(int nid, struct mem_section *section, ...@@ -643,7 +641,6 @@ static int add_memory_section(int nid, struct mem_section *section,
ret = register_mem_sect_under_node(mem, nid); ret = register_mem_sect_under_node(mem, nid);
} }
mutex_unlock(&mem_sysfs_mutex);
return ret; return ret;
} }
...@@ -653,7 +650,13 @@ static int add_memory_section(int nid, struct mem_section *section, ...@@ -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) 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 #ifdef CONFIG_MEMORY_HOTREMOVE
...@@ -746,6 +749,7 @@ int __init memory_dev_init(void) ...@@ -746,6 +749,7 @@ int __init memory_dev_init(void)
* Create entries for memory sections that were found * Create entries for memory sections that were found
* during boot and have been initialized * during boot and have been initialized
*/ */
mutex_lock(&mem_sysfs_mutex);
for (i = 0; i < NR_MEM_SECTIONS; i++) { for (i = 0; i < NR_MEM_SECTIONS; i++) {
if (!present_section_nr(i)) if (!present_section_nr(i))
continue; continue;
...@@ -757,6 +761,7 @@ int __init memory_dev_init(void) ...@@ -757,6 +761,7 @@ int __init memory_dev_init(void)
if (!ret) if (!ret)
ret = err; ret = err;
} }
mutex_unlock(&mem_sysfs_mutex);
out: out:
if (ret) if (ret)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册