aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86_64/mm/init.c17
-rw-r--r--mm/memory_hotplug.c60
2 files changed, 43 insertions, 34 deletions
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index 71ecbb3f326..19c72520a86 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -474,12 +474,12 @@ int arch_add_memory(int nid, u64 start, u64 size)
474 unsigned long nr_pages = size >> PAGE_SHIFT; 474 unsigned long nr_pages = size >> PAGE_SHIFT;
475 int ret; 475 int ret;
476 476
477 init_memory_mapping(start, (start + size -1));
478
477 ret = __add_pages(zone, start_pfn, nr_pages); 479 ret = __add_pages(zone, start_pfn, nr_pages);
478 if (ret) 480 if (ret)
479 goto error; 481 goto error;
480 482
481 init_memory_mapping(start, (start + size -1));
482
483 return ret; 483 return ret;
484error: 484error:
485 printk("%s: Problem encountered in __add_pages!\n", __func__); 485 printk("%s: Problem encountered in __add_pages!\n", __func__);
@@ -501,7 +501,16 @@ int memory_add_physaddr_to_nid(u64 start)
501EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); 501EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
502#endif 502#endif
503 503
504#else /* CONFIG_MEMORY_HOTPLUG */ 504#ifndef CONFIG_ACPI_NUMA
505int memory_add_physaddr_to_nid(u64 start)
506{
507 return 0;
508}
509#endif
510
511#endif /* CONFIG_MEMORY_HOTPLUG */
512
513#ifdef CONFIG_MEMORY_HOTPLUG_RESERVE
505/* 514/*
506 * Memory Hotadd without sparsemem. The mem_maps have been allocated in advance, 515 * Memory Hotadd without sparsemem. The mem_maps have been allocated in advance,
507 * just online the pages. 516 * just online the pages.
@@ -527,7 +536,7 @@ int __add_pages(struct zone *z, unsigned long start_pfn, unsigned long nr_pages)
527 } 536 }
528 return err; 537 return err;
529} 538}
530#endif /* CONFIG_MEMORY_HOTPLUG */ 539#endif
531 540
532static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel, kcore_modules, 541static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel, kcore_modules,
533 kcore_vsyscall; 542 kcore_vsyscall;
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 7666dbd328d..fd678a662ea 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -26,6 +26,36 @@
26 26
27#include <asm/tlbflush.h> 27#include <asm/tlbflush.h>
28 28
29/* add this memory to iomem resource */
30static struct resource *register_memory_resource(u64 start, u64 size)
31{
32 struct resource *res;
33 res = kzalloc(sizeof(struct resource), GFP_KERNEL);
34 BUG_ON(!res);
35
36 res->name = "System RAM";
37 res->start = start;
38 res->end = start + size - 1;
39 res->flags = IORESOURCE_MEM;
40 if (request_resource(&iomem_resource, res) < 0) {
41 printk("System RAM resource %llx - %llx cannot be added\n",
42 (unsigned long long)res->start, (unsigned long long)res->end);
43 kfree(res);
44 res = NULL;
45 }
46 return res;
47}
48
49static void release_memory_resource(struct resource *res)
50{
51 if (!res)
52 return;
53 release_resource(res);
54 kfree(res);
55 return;
56}
57
58
29#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE 59#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
30static int __add_zone(struct zone *zone, unsigned long phys_start_pfn) 60static int __add_zone(struct zone *zone, unsigned long phys_start_pfn)
31{ 61{
@@ -223,36 +253,6 @@ static void rollback_node_hotadd(int nid, pg_data_t *pgdat)
223 return; 253 return;
224} 254}
225 255
226/* add this memory to iomem resource */
227static struct resource *register_memory_resource(u64 start, u64 size)
228{
229 struct resource *res;
230 res = kzalloc(sizeof(struct resource), GFP_KERNEL);
231 BUG_ON(!res);
232
233 res->name = "System RAM";
234 res->start = start;
235 res->end = start + size - 1;
236 res->flags = IORESOURCE_MEM;
237 if (request_resource(&iomem_resource, res) < 0) {
238 printk("System RAM resource %llx - %llx cannot be added\n",
239 (unsigned long long)res->start, (unsigned long long)res->end);
240 kfree(res);
241 res = NULL;
242 }
243 return res;
244}
245
246static void release_memory_resource(struct resource *res)
247{
248 if (!res)
249 return;
250 release_resource(res);
251 kfree(res);
252 return;
253}
254
255
256 256
257int add_memory(int nid, u64 start, u64 size) 257int add_memory(int nid, u64 start, u64 size)
258{ 258{