aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memory_hotplug.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/memory_hotplug.c')
-rw-r--r--mm/memory_hotplug.c71
1 files changed, 37 insertions, 34 deletions
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index c37319542b70..fd678a662eae 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -13,6 +13,7 @@
13#include <linux/compiler.h> 13#include <linux/compiler.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/pagevec.h> 15#include <linux/pagevec.h>
16#include <linux/writeback.h>
16#include <linux/slab.h> 17#include <linux/slab.h>
17#include <linux/sysctl.h> 18#include <linux/sysctl.h>
18#include <linux/cpu.h> 19#include <linux/cpu.h>
@@ -21,11 +22,41 @@
21#include <linux/highmem.h> 22#include <linux/highmem.h>
22#include <linux/vmalloc.h> 23#include <linux/vmalloc.h>
23#include <linux/ioport.h> 24#include <linux/ioport.h>
25#include <linux/cpuset.h>
24 26
25#include <asm/tlbflush.h> 27#include <asm/tlbflush.h>
26 28
27extern void zonetable_add(struct zone *zone, int nid, int zid, unsigned long pfn, 29/* add this memory to iomem resource */
28 unsigned long size); 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
59#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
29static int __add_zone(struct zone *zone, unsigned long phys_start_pfn) 60static int __add_zone(struct zone *zone, unsigned long phys_start_pfn)
30{ 61{
31 struct pglist_data *pgdat = zone->zone_pgdat; 62 struct pglist_data *pgdat = zone->zone_pgdat;
@@ -45,8 +76,6 @@ static int __add_zone(struct zone *zone, unsigned long phys_start_pfn)
45 return 0; 76 return 0;
46} 77}
47 78
48extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
49 int nr_pages);
50static int __add_section(struct zone *zone, unsigned long phys_start_pfn) 79static int __add_section(struct zone *zone, unsigned long phys_start_pfn)
51{ 80{
52 int nr_pages = PAGES_PER_SECTION; 81 int nr_pages = PAGES_PER_SECTION;
@@ -191,8 +220,10 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
191 if (need_zonelists_rebuild) 220 if (need_zonelists_rebuild)
192 build_all_zonelists(); 221 build_all_zonelists();
193 vm_total_pages = nr_free_pagecache_pages(); 222 vm_total_pages = nr_free_pagecache_pages();
223 writeback_set_ratelimit();
194 return 0; 224 return 0;
195} 225}
226#endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
196 227
197static pg_data_t *hotadd_new_pgdat(int nid, u64 start) 228static pg_data_t *hotadd_new_pgdat(int nid, u64 start)
198{ 229{
@@ -222,36 +253,6 @@ static void rollback_node_hotadd(int nid, pg_data_t *pgdat)
222 return; 253 return;
223} 254}
224 255
225/* add this memory to iomem resource */
226static struct resource *register_memory_resource(u64 start, u64 size)
227{
228 struct resource *res;
229 res = kzalloc(sizeof(struct resource), GFP_KERNEL);
230 BUG_ON(!res);
231
232 res->name = "System RAM";
233 res->start = start;
234 res->end = start + size - 1;
235 res->flags = IORESOURCE_MEM;
236 if (request_resource(&iomem_resource, res) < 0) {
237 printk("System RAM resource %llx - %llx cannot be added\n",
238 (unsigned long long)res->start, (unsigned long long)res->end);
239 kfree(res);
240 res = NULL;
241 }
242 return res;
243}
244
245static void release_memory_resource(struct resource *res)
246{
247 if (!res)
248 return;
249 release_resource(res);
250 kfree(res);
251 return;
252}
253
254
255 256
256int add_memory(int nid, u64 start, u64 size) 257int add_memory(int nid, u64 start, u64 size)
257{ 258{
@@ -283,6 +284,8 @@ int add_memory(int nid, u64 start, u64 size)
283 /* we online node here. we can't roll back from here. */ 284 /* we online node here. we can't roll back from here. */
284 node_set_online(nid); 285 node_set_online(nid);
285 286
287 cpuset_track_online_nodes();
288
286 if (new_pgdat) { 289 if (new_pgdat) {
287 ret = register_one_node(nid); 290 ret = register_one_node(nid);
288 /* 291 /*