diff options
author | Seth Jennings <sjenning@linux.vnet.ibm.com> | 2013-08-20 12:12:57 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-08-21 11:47:39 -0700 |
commit | b1eaef3da5a7bbc48fa9dbefaa2a28e45367fdb1 (patch) | |
tree | 2c64447a090dfc9704700f7536ab6b70f5b7a1d7 | |
parent | 65f44679580de05d267f026ed8164539ec5c7a88 (diff) | |
download | linux-b1eaef3da5a7bbc48fa9dbefaa2a28e45367fdb1.tar.bz2 |
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: Seth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/base/memory.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index ddd14ce6654c..ed3ada244a07 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) |