aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorSeth Jennings <sjenning@linux.vnet.ibm.com>2013-08-20 13:12:57 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-21 14:47:39 -0400
commitb1eaef3da5a7bbc48fa9dbefaa2a28e45367fdb1 (patch)
tree2c64447a090dfc9704700f7536ab6b70f5b7a1d7 /drivers/base
parent65f44679580de05d267f026ed8164539ec5c7a88 (diff)
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>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/memory.c13
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,
613 int scn_nr = __section_nr(section); 613 int scn_nr = __section_nr(section);
614 int ret = 0; 614 int ret = 0;
615 615
616 mutex_lock(&mem_sysfs_mutex);
617
618 if (context == BOOT) { 616 if (context == BOOT) {
619 /* same memory block ? */ 617 /* same memory block ? */
620 if (mem_p && *mem_p) 618 if (mem_p && *mem_p)
@@ -643,7 +641,6 @@ static int add_memory_section(int nid, struct mem_section *section,
643 ret = register_mem_sect_under_node(mem, nid); 641 ret = register_mem_sect_under_node(mem, nid);
644 } 642 }
645 643
646 mutex_unlock(&mem_sysfs_mutex);
647 return ret; 644 return ret;
648} 645}
649 646
@@ -653,7 +650,13 @@ static int add_memory_section(int nid, struct mem_section *section,
653 */ 650 */
654int register_new_memory(int nid, struct mem_section *section) 651int register_new_memory(int nid, struct mem_section *section)
655{ 652{
656 return add_memory_section(nid, section, NULL, MEM_OFFLINE, HOTPLUG); 653 int ret;
654
655 mutex_lock(&mem_sysfs_mutex);
656 ret = add_memory_section(nid, section, NULL, MEM_OFFLINE, HOTPLUG);
657 mutex_unlock(&mem_sysfs_mutex);
658
659 return ret;
657} 660}
658 661
659#ifdef CONFIG_MEMORY_HOTREMOVE 662#ifdef CONFIG_MEMORY_HOTREMOVE
@@ -746,6 +749,7 @@ int __init memory_dev_init(void)
746 * Create entries for memory sections that were found 749 * Create entries for memory sections that were found
747 * during boot and have been initialized 750 * during boot and have been initialized
748 */ 751 */
752 mutex_lock(&mem_sysfs_mutex);
749 for (i = 0; i < NR_MEM_SECTIONS; i++) { 753 for (i = 0; i < NR_MEM_SECTIONS; i++) {
750 if (!present_section_nr(i)) 754 if (!present_section_nr(i))
751 continue; 755 continue;
@@ -757,6 +761,7 @@ int __init memory_dev_init(void)
757 if (!ret) 761 if (!ret)
758 ret = err; 762 ret = err;
759 } 763 }
764 mutex_unlock(&mem_sysfs_mutex);
760 765
761out: 766out:
762 if (ret) 767 if (ret)