login
Header Space

 
 

[PATCH 1 of 4] hotplug-memory: add add_memory_resource

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Ingo Molnar <mingo@...>
Cc: LKML <linux-kernel@...>, Rusty Russell <rusty@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>, Yasunori Goto <y-goto@...>, Christoph Lameter <clameter@...>, Dave Hansen <dave@...>, Andrew Morton <akpm@...>
Date: Thursday, March 27, 2008 - 8:28 pm

The Xen balloon driver uses hotplug memory to extend the amount of
pseudo-physical memory available to a virtual domain.  Since this memory
is virtual, it can go anywhere within the kernel's pseudo-physical
address space.

This patch adds a new hotplug memory call, add_memory_resource(), which
adds memory corresponding to a pre-constructed resource.  This allows
callers to use allocate_resource() to allocate a suitable chunk of
address space for the new memory (as well as cosmetic details, like a
descriptive name).

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Yasunori Goto <y-goto@jp.fujitsu.com>
Cc: Christoph Lameter <clameter@sgi.com>
Cc: Dave Hansen <dave@linux.vnet.ibm.com>
---
 include/linux/memory_hotplug.h |    3 +++
 mm/memory_hotplug.c            |   20 ++++++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -171,7 +171,10 @@
 
 #endif /* ! CONFIG_MEMORY_HOTPLUG */
 
+struct resource;
+
 extern int add_memory(int nid, u64 start, u64 size);
+extern int add_memory_resource(int nid, struct resource *res);
 extern int arch_add_memory(int nid, u64 start, u64 size);
 extern int remove_memory(u64 start, u64 size);
 extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -278,14 +278,28 @@
 
 int add_memory(int nid, u64 start, u64 size)
 {
-	pg_data_t *pgdat = NULL;
-	int new_pgdat = 0;
 	struct resource *res;
 	int ret;
 
 	res = register_memory_resource(start, size);
 	if (!res)
 		return -EEXIST;
+
+	ret = add_memory_resource(nid, res);
+
+	if (ret)
+		release_memory_resource(res);
+
+	return ret;
+}
+
+int add_memory_resource(int nid, struct resource *res)
+{
+	pg_data_t *pgdat = NULL;
+	int new_pgdat = 0;
+	int ret;
+	u64 start = res->start;
+	u64 size = res->end - res->start + 1;
 
 	if (!node_online(nid)) {
 		pgdat = hotadd_new_pgdat(nid, start);
@@ -320,8 +334,6 @@
 	/* rollback pgdat allocation and others */
 	if (new_pgdat)
 		rollback_node_hotadd(nid, pgdat);
-	if (res)
-		release_memory_resource(res);
 
 	return ret;
 }


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0 of 4] [RFC] hotplug memory: minor updates, Jeremy Fitzhardinge, (Thu Mar 27, 8:28 pm)
Re: [PATCH 0 of 4] [RFC] hotplug memory: minor updates, Ingo Molnar, (Fri Mar 28, 5:12 am)
Re: [PATCH 0 of 4] [RFC] hotplug memory: minor updates, Jeremy Fitzhardinge, (Fri Mar 28, 12:07 pm)
Re: [PATCH 0 of 4] [RFC] hotplug memory: minor updates, Ingo Molnar, (Fri Mar 28, 6:04 pm)
[PATCH 2 of 4] hotplug-memory: adding non-section-aligned me..., Jeremy Fitzhardinge, (Thu Mar 27, 8:28 pm)
Re: [PATCH 2 of 4] hotplug-memory: adding non-section-aligne..., KAMEZAWA Hiroyuki, (Thu Mar 27, 9:27 pm)
Re: [PATCH 2 of 4] hotplug-memory: adding non-section-aligne..., KAMEZAWA Hiroyuki, (Thu Mar 27, 9:54 pm)
Re: [PATCH 2 of 4] hotplug-memory: adding non-section-aligne..., Jeremy Fitzhardinge, (Thu Mar 27, 10:13 pm)
Re: [PATCH 2 of 4] hotplug-memory: adding non-section-aligne..., KAMEZAWA Hiroyuki, (Thu Mar 27, 10:33 pm)
Re: [PATCH 2 of 4] hotplug-memory: adding non-section-aligne..., Jeremy Fitzhardinge, (Fri Mar 28, 5:30 pm)
Re: [PATCH 2 of 4] hotplug-memory: adding non-section-aligne..., Jeremy Fitzhardinge, (Thu Mar 27, 10:51 pm)
Re: [PATCH 2 of 4] hotplug-memory: adding non-section-aligne..., Jeremy Fitzhardinge, (Fri Mar 28, 12:07 am)
Re: [PATCH 2 of 4] hotplug-memory: adding non-section-aligne..., KAMEZAWA Hiroyuki, (Thu Mar 27, 11:17 pm)
Re: [PATCH 2 of 4] hotplug-memory: adding non-section-aligne..., Jeremy Fitzhardinge, (Fri Mar 28, 12:20 am)
Re: [PATCH 2 of 4] hotplug-memory: adding non-section-aligne..., KAMEZAWA Hiroyuki, (Fri Mar 28, 12:39 am)
Re: [PATCH 2 of 4] hotplug-memory: adding non-section-aligne..., Jeremy Fitzhardinge, (Fri Mar 28, 2:19 pm)
[PATCH 3 of 4] sparsemem: reduce i386 PAE section size, Jeremy Fitzhardinge, (Thu Mar 27, 8:28 pm)
Re: [PATCH 3 of 4] sparsemem: reduce i386 PAE section size, Christoph Lameter, (Thu Mar 27, 8:35 pm)
Re: [PATCH 3 of 4] sparsemem: reduce i386 PAE section size, Jeremy Fitzhardinge, (Thu Mar 27, 10:26 pm)
Re: [PATCH 3 of 4] sparsemem: reduce i386 PAE section size, Christoph Lameter, (Thu Mar 27, 10:27 pm)
Re: [PATCH 3 of 4] sparsemem: reduce i386 PAE section size, Jeremy Fitzhardinge, (Fri Mar 28, 2:18 am)
Re: [PATCH 3 of 4] sparsemem: reduce i386 PAE section size, Jeremy Fitzhardinge, (Fri Mar 28, 2:05 pm)
[PATCH 4 of 4] paravirt_ops: don't steal memory resources in..., Jeremy Fitzhardinge, (Thu Mar 27, 8:28 pm)
[PATCH 1 of 4] hotplug-memory: add add_memory_resource, Jeremy Fitzhardinge, (Thu Mar 27, 8:28 pm)
speck-geostationary