mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 21:03:32 +00:00
[PATCH] hot-add-mem x86_64: use CONFIG_MEMORY_HOTPLUG_RESERVE
The api for hot-add memory already has a construct for finding nodes based on an address, memory_add_physaddr_to_nid. This patch allows the fucntion to do something besides return 0. It uses the nodes_add infomation to lookup to node info for a hot add event. Signed-off-by: Keith Mannthey <kmannth@us.ibm.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Andi Kleen <ak@muc.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
53947027ad
commit
45e0b78b05
2 changed files with 43 additions and 34 deletions
|
@ -474,12 +474,12 @@ int arch_add_memory(int nid, u64 start, u64 size)
|
||||||
unsigned long nr_pages = size >> PAGE_SHIFT;
|
unsigned long nr_pages = size >> PAGE_SHIFT;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
init_memory_mapping(start, (start + size -1));
|
||||||
|
|
||||||
ret = __add_pages(zone, start_pfn, nr_pages);
|
ret = __add_pages(zone, start_pfn, nr_pages);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
init_memory_mapping(start, (start + size -1));
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
error:
|
error:
|
||||||
printk("%s: Problem encountered in __add_pages!\n", __func__);
|
printk("%s: Problem encountered in __add_pages!\n", __func__);
|
||||||
|
@ -501,7 +501,16 @@ int memory_add_physaddr_to_nid(u64 start)
|
||||||
EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
|
EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else /* CONFIG_MEMORY_HOTPLUG */
|
#ifndef CONFIG_ACPI_NUMA
|
||||||
|
int memory_add_physaddr_to_nid(u64 start)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CONFIG_MEMORY_HOTPLUG */
|
||||||
|
|
||||||
|
#ifdef CONFIG_MEMORY_HOTPLUG_RESERVE
|
||||||
/*
|
/*
|
||||||
* Memory Hotadd without sparsemem. The mem_maps have been allocated in advance,
|
* Memory Hotadd without sparsemem. The mem_maps have been allocated in advance,
|
||||||
* just online the pages.
|
* just online the pages.
|
||||||
|
@ -527,7 +536,7 @@ int __add_pages(struct zone *z, unsigned long start_pfn, unsigned long nr_pages)
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_MEMORY_HOTPLUG */
|
#endif
|
||||||
|
|
||||||
static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel, kcore_modules,
|
static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel, kcore_modules,
|
||||||
kcore_vsyscall;
|
kcore_vsyscall;
|
||||||
|
|
|
@ -26,6 +26,36 @@
|
||||||
|
|
||||||
#include <asm/tlbflush.h>
|
#include <asm/tlbflush.h>
|
||||||
|
|
||||||
|
/* add this memory to iomem resource */
|
||||||
|
static struct resource *register_memory_resource(u64 start, u64 size)
|
||||||
|
{
|
||||||
|
struct resource *res;
|
||||||
|
res = kzalloc(sizeof(struct resource), GFP_KERNEL);
|
||||||
|
BUG_ON(!res);
|
||||||
|
|
||||||
|
res->name = "System RAM";
|
||||||
|
res->start = start;
|
||||||
|
res->end = start + size - 1;
|
||||||
|
res->flags = IORESOURCE_MEM;
|
||||||
|
if (request_resource(&iomem_resource, res) < 0) {
|
||||||
|
printk("System RAM resource %llx - %llx cannot be added\n",
|
||||||
|
(unsigned long long)res->start, (unsigned long long)res->end);
|
||||||
|
kfree(res);
|
||||||
|
res = NULL;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void release_memory_resource(struct resource *res)
|
||||||
|
{
|
||||||
|
if (!res)
|
||||||
|
return;
|
||||||
|
release_resource(res);
|
||||||
|
kfree(res);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
|
#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
|
||||||
static int __add_zone(struct zone *zone, unsigned long phys_start_pfn)
|
static int __add_zone(struct zone *zone, unsigned long phys_start_pfn)
|
||||||
{
|
{
|
||||||
|
@ -223,36 +253,6 @@ static void rollback_node_hotadd(int nid, pg_data_t *pgdat)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add this memory to iomem resource */
|
|
||||||
static struct resource *register_memory_resource(u64 start, u64 size)
|
|
||||||
{
|
|
||||||
struct resource *res;
|
|
||||||
res = kzalloc(sizeof(struct resource), GFP_KERNEL);
|
|
||||||
BUG_ON(!res);
|
|
||||||
|
|
||||||
res->name = "System RAM";
|
|
||||||
res->start = start;
|
|
||||||
res->end = start + size - 1;
|
|
||||||
res->flags = IORESOURCE_MEM;
|
|
||||||
if (request_resource(&iomem_resource, res) < 0) {
|
|
||||||
printk("System RAM resource %llx - %llx cannot be added\n",
|
|
||||||
(unsigned long long)res->start, (unsigned long long)res->end);
|
|
||||||
kfree(res);
|
|
||||||
res = NULL;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void release_memory_resource(struct resource *res)
|
|
||||||
{
|
|
||||||
if (!res)
|
|
||||||
return;
|
|
||||||
release_resource(res);
|
|
||||||
kfree(res);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int add_memory(int nid, u64 start, u64 size)
|
int add_memory(int nid, u64 start, u64 size)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue