Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754861AbYC1BKA (ORCPT ); Thu, 27 Mar 2008 21:10:00 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754389AbYC1BJb (ORCPT ); Thu, 27 Mar 2008 21:09:31 -0400 Received: from zrnetservice.com ([209.133.52.163]:58081 "EHLO www.zrnetservice.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754830AbYC1BJa (ORCPT ); Thu, 27 Mar 2008 21:09:30 -0400 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [PATCH 1 of 4] hotplug-memory: add add_memory_resource X-Mercurial-Node: 56436b88c2e0702e1250faf352c35e4e10599d64 Message-Id: <56436b88c2e0702e1250.1206664117@localhost> In-Reply-To: Date: Thu, 27 Mar 2008 17:28:37 -0700 From: Jeremy Fitzhardinge To: Ingo Molnar Cc: LKML , Rusty Russell , KAMEZAWA Hiroyuki , Yasunori Goto , Christoph Lameter , Dave Hansen , Andrew Morton Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2601 Lines: 85 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 Cc: KAMEZAWA Hiroyuki Cc: Yasunori Goto Cc: Christoph Lameter Cc: Dave Hansen --- 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; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/