lkml.org 
[lkml]   [2013]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH v2 11/25] memory_hotplug: factor out locks in mem_online_cpu()
Date
In dynamic numa, when onlining nodes, lock_memory_hotplug() is already
held when mem_online_node()'s functionality is needed.

Factor out the locking and create a new function __mem_online_node() to
allow reuse.

Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
---
include/linux/memory_hotplug.h | 1 +
mm/memory_hotplug.c | 29 ++++++++++++++++-------------
2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index cd393014..391824d 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -248,6 +248,7 @@ static inline int is_mem_section_removable(unsigned long pfn,
static inline void try_offline_node(int nid) {}
#endif /* CONFIG_MEMORY_HOTREMOVE */

+extern int __mem_online_node(int nid);
extern int mem_online_node(int nid);
extern int add_memory(int nid, u64 start, u64 size);
extern int arch_add_memory(int nid, u64 start, u64 size);
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index deea8c2..f5ea9b7 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1058,26 +1058,29 @@ static void rollback_node_hotadd(int nid, pg_data_t *pgdat)
return;
}

-
-/*
- * called by cpu_up() to online a node without onlined memory.
- */
-int mem_online_node(int nid)
+int __mem_online_node(int nid)
{
- pg_data_t *pgdat;
- int ret;
+ pg_data_t *pgdat;
+ int ret;

- lock_memory_hotplug();
pgdat = hotadd_new_pgdat(nid, 0);
- if (!pgdat) {
- ret = -ENOMEM;
- goto out;
- }
+ if (!pgdat)
+ return -ENOMEM;
+
node_set_online(nid);
ret = register_one_node(nid);
BUG_ON(ret);
+ return ret;
+}

-out:
+/*
+ * called by cpu_up() to online a node without onlined memory.
+ */
+int mem_online_node(int nid)
+{
+ int ret;
+ lock_memory_hotplug();
+ ret = __mem_online_node(nid);
unlock_memory_hotplug();
return ret;
}
--
1.8.2.1


\
 
 \ /
  Last update: 2013-04-12 03:41    [W:2.290 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site