login
Header Space

 
 

Re: Trying to make use of hotplug memory for xen balloon driver

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Dave Hansen <dave@...>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>, Yasunori Goto <y-goto@...>, Christoph Lameter <clameter@...>, Linux Kernel Mailing List <linux-kernel@...>, Anthony Liguori <anthony@...>, Chris Wright <chrisw@...>
Date: Wednesday, March 26, 2008 - 8:15 pm

Dave Hansen wrote:

Sorry, I should have been clearer.  add_memory_resource() is a function 
I added; it's effectively add_memory() with the resource-allocating part 
factored out:

--- 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,
===================================================================
--- 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;
 }



X86 Xen does it with a combination of hypervisor and userspace.  Mostly 
it comes down to asking the hypervisor to provide a machine page to put 
under a guest pseudo-physical page.

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

Messages in current thread:
Trying to make use of hotplug memory for xen balloon driver, Jeremy Fitzhardinge, (Wed Mar 26, 7:11 pm)
Re: Trying to make use of hotplug memory for xen balloon dri..., KAMEZAWA Hiroyuki, (Wed Mar 26, 8:50 pm)
Re: Trying to make use of hotplug memory for xen balloon dri..., Jeremy Fitzhardinge, (Thu Mar 27, 1:57 am)
Re: Trying to make use of hotplug memory for xen balloon dri..., KAMEZAWA Hiroyuki, (Thu Mar 27, 2:11 am)
Re: Trying to make use of hotplug memory for xen balloon dri..., Jeremy Fitzhardinge, (Thu Mar 27, 4:54 pm)
Re: Trying to make use of hotplug memory for xen balloon dri..., KAMEZAWA Hiroyuki, (Thu Mar 27, 8:20 pm)
Re: Trying to make use of hotplug memory for xen balloon dri..., Jeremy Fitzhardinge, (Thu Mar 27, 2:09 am)
Re: Trying to make use of hotplug memory for xen balloon dri..., Jeremy Fitzhardinge, (Thu Mar 27, 6:23 pm)
Re: Trying to make use of hotplug memory for xen balloon dri..., Christoph Lameter, (Wed Mar 26, 9:23 pm)
Re: Trying to make use of hotplug memory for xen balloon dri..., Jeremy Fitzhardinge, (Wed Mar 26, 8:15 pm)
speck-geostationary