public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Dave Hansen <dave@linux.vnet.ibm.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Yasunori Goto <y-goto@jp.fujitsu.com>,
	Christoph Lameter <clameter@sgi.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Anthony Liguori <anthony@codemonkey.ws>,
	Chris Wright <chrisw@sous-sol.org>
Subject: Re: Trying to make use of hotplug memory for xen balloon driver
Date: Wed, 26 Mar 2008 17:15:50 -0700	[thread overview]
Message-ID: <47EAE736.307@goop.org> (raw)
In-Reply-To: <1206576544.7883.21.camel@nimitz.home.sr71.net>

Dave Hansen wrote:
> Yeah, this is your problem.  You've only allocated the iomem *resource*
> for the memory area, which means that you've basically claimed the
> physical addresses.
>
> But, you don't have any 'struct page's there.
>
> We really screwed up the memory hotplug code and ended up with some
> incredibly arcane function names.  You might want to look at
> add_memory().  It is hidden away in mm/memory_hotplug.c :)
>   

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


> You might also note that most of the ppc64 memory hotplug is driven by
> userspace.  The hypervisor actually contacts a daemon on the guest to
> tell it where its new memory is.  That daemon does the addition
> through /sys/devices/system/memory/probe.  
>   

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

  reply	other threads:[~2008-03-27  0:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-26 23:11 Trying to make use of hotplug memory for xen balloon driver Jeremy Fitzhardinge
2008-03-27  0:09 ` Dave Hansen
2008-03-27  0:15   ` Jeremy Fitzhardinge [this message]
2008-03-27  1:23   ` Christoph Lameter
2008-03-27  0:26 ` Dave Hansen
2008-03-27 22:23   ` Jeremy Fitzhardinge
2008-03-28 18:21     ` Dave Hansen
2008-03-27  0:50 ` KAMEZAWA Hiroyuki
2008-03-27  5:57   ` Jeremy Fitzhardinge
2008-03-27  6:11     ` KAMEZAWA Hiroyuki
2008-03-27  6:09       ` Jeremy Fitzhardinge
2008-03-27 20:54       ` Jeremy Fitzhardinge
2008-03-28  0:20         ` KAMEZAWA Hiroyuki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47EAE736.307@goop.org \
    --to=jeremy@goop.org \
    --cc=anthony@codemonkey.ws \
    --cc=chrisw@sous-sol.org \
    --cc=clameter@sgi.com \
    --cc=dave@linux.vnet.ibm.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=y-goto@jp.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox