All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Rusty Russell <rusty@rustcorp.com.au>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Yasunori Goto <y-goto@jp.fujitsu.com>,
	Christoph Lameter <clameter@sgi.com>,
	Dave Hansen <dave@linux.vnet.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 1 of 4] hotplug-memory: add add_memory_resource
Date: Thu, 27 Mar 2008 17:28:37 -0700	[thread overview]
Message-ID: <56436b88c2e0702e1250.1206664117@localhost> (raw)
In-Reply-To: <patchbomb.1206664116@localhost>

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



  reply	other threads:[~2008-03-28  1:10 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-28  0:28 [PATCH 0 of 4] [RFC] hotplug memory: minor updates Jeremy Fitzhardinge
2008-03-28  0:28 ` Jeremy Fitzhardinge [this message]
2008-03-28  0:28 ` [PATCH 2 of 4] hotplug-memory: adding non-section-aligned memory is bad Jeremy Fitzhardinge
2008-03-28  1:27   ` KAMEZAWA Hiroyuki
2008-03-28  1:34     ` Yasunori Goto
2008-03-28  1:54       ` KAMEZAWA Hiroyuki
2008-03-28  2:13         ` Jeremy Fitzhardinge
2008-03-28  2:33           ` KAMEZAWA Hiroyuki
2008-03-28  2:51             ` Jeremy Fitzhardinge
2008-03-28  3:17               ` KAMEZAWA Hiroyuki
2008-03-28  4:20                 ` Jeremy Fitzhardinge
2008-03-28  4:39                   ` KAMEZAWA Hiroyuki
2008-03-28 18:19                     ` Jeremy Fitzhardinge
2008-03-28 18:27                       ` Dave Hansen
2008-03-28  3:21               ` Yasunori Goto
2008-03-28  4:07                 ` Jeremy Fitzhardinge
2008-03-28 21:30             ` Jeremy Fitzhardinge
2008-03-28  0:28 ` [PATCH 3 of 4] sparsemem: reduce i386 PAE section size Jeremy Fitzhardinge
2008-03-28  0:35   ` Christoph Lameter
2008-03-28  2:26     ` Jeremy Fitzhardinge
2008-03-28  2:27       ` Christoph Lameter
2008-03-28  6:18         ` Jeremy Fitzhardinge
2008-03-28 16:43           ` Dave Hansen
2008-03-28 18:05             ` Jeremy Fitzhardinge
2008-03-28 16:45   ` Dave Hansen
2008-03-28  0:28 ` [PATCH 4 of 4] paravirt_ops: don't steal memory resources in paravirt_disable_iospace Jeremy Fitzhardinge
2008-03-28  2:41   ` Rusty Russell
2008-03-28  9:12 ` [PATCH 0 of 4] [RFC] hotplug memory: minor updates Ingo Molnar
2008-03-28 16:07   ` Jeremy Fitzhardinge
2008-03-28 22:04     ` Ingo Molnar

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=56436b88c2e0702e1250.1206664117@localhost \
    --to=jeremy@goop.org \
    --cc=akpm@linux-foundation.org \
    --cc=clameter@sgi.com \
    --cc=dave@linux.vnet.ibm.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rusty@rustcorp.com.au \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.