aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/memory_hotplug.c18
-rw-r--r--mm/page_alloc.c17
2 files changed, 26 insertions, 9 deletions
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 85eb4d342ac5..089cc97aed3c 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -389,6 +389,11 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
389 int nid; 389 int nid;
390 int ret; 390 int ret;
391 struct memory_notify arg; 391 struct memory_notify arg;
392 /*
393 * mutex to protect zone->pageset when it's still shared
394 * in onlined_pages()
395 */
396 static DEFINE_MUTEX(zone_pageset_mutex);
392 397
393 arg.start_pfn = pfn; 398 arg.start_pfn = pfn;
394 arg.nr_pages = nr_pages; 399 arg.nr_pages = nr_pages;
@@ -415,12 +420,14 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
415 * This means the page allocator ignores this zone. 420 * This means the page allocator ignores this zone.
416 * So, zonelist must be updated after online. 421 * So, zonelist must be updated after online.
417 */ 422 */
423 mutex_lock(&zone_pageset_mutex);
418 if (!populated_zone(zone)) 424 if (!populated_zone(zone))
419 need_zonelists_rebuild = 1; 425 need_zonelists_rebuild = 1;
420 426
421 ret = walk_system_ram_range(pfn, nr_pages, &onlined_pages, 427 ret = walk_system_ram_range(pfn, nr_pages, &onlined_pages,
422 online_pages_range); 428 online_pages_range);
423 if (ret) { 429 if (ret) {
430 mutex_unlock(&zone_pageset_mutex);
424 printk(KERN_DEBUG "online_pages %lx at %lx failed\n", 431 printk(KERN_DEBUG "online_pages %lx at %lx failed\n",
425 nr_pages, pfn); 432 nr_pages, pfn);
426 memory_notify(MEM_CANCEL_ONLINE, &arg); 433 memory_notify(MEM_CANCEL_ONLINE, &arg);
@@ -429,8 +436,12 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
429 436
430 zone->present_pages += onlined_pages; 437 zone->present_pages += onlined_pages;
431 zone->zone_pgdat->node_present_pages += onlined_pages; 438 zone->zone_pgdat->node_present_pages += onlined_pages;
439 if (need_zonelists_rebuild)
440 build_all_zonelists(zone);
441 else
442 zone_pcp_update(zone);
432 443
433 zone_pcp_update(zone); 444 mutex_unlock(&zone_pageset_mutex);
434 setup_per_zone_wmarks(); 445 setup_per_zone_wmarks();
435 calculate_zone_inactive_ratio(zone); 446 calculate_zone_inactive_ratio(zone);
436 if (onlined_pages) { 447 if (onlined_pages) {
@@ -438,10 +449,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
438 node_set_state(zone_to_nid(zone), N_HIGH_MEMORY); 449 node_set_state(zone_to_nid(zone), N_HIGH_MEMORY);
439 } 450 }
440 451
441 if (need_zonelists_rebuild) 452 vm_total_pages = nr_free_pagecache_pages();
442 build_all_zonelists();
443 else
444 vm_total_pages = nr_free_pagecache_pages();
445 453
446 writeback_set_ratelimit(); 454 writeback_set_ratelimit();
447 455
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 595d0ac211e2..21c52d2d8624 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2572,7 +2572,7 @@ int numa_zonelist_order_handler(ctl_table *table, int write,
2572 NUMA_ZONELIST_ORDER_LEN); 2572 NUMA_ZONELIST_ORDER_LEN);
2573 user_zonelist_order = oldval; 2573 user_zonelist_order = oldval;
2574 } else if (oldval != user_zonelist_order) 2574 } else if (oldval != user_zonelist_order)
2575 build_all_zonelists(); 2575 build_all_zonelists(NULL);
2576 } 2576 }
2577out: 2577out:
2578 mutex_unlock(&zl_order_mutex); 2578 mutex_unlock(&zl_order_mutex);
@@ -2922,9 +2922,10 @@ static void build_zonelist_cache(pg_data_t *pgdat)
2922 */ 2922 */
2923static void setup_pageset(struct per_cpu_pageset *p, unsigned long batch); 2923static void setup_pageset(struct per_cpu_pageset *p, unsigned long batch);
2924static DEFINE_PER_CPU(struct per_cpu_pageset, boot_pageset); 2924static DEFINE_PER_CPU(struct per_cpu_pageset, boot_pageset);
2925static void setup_zone_pageset(struct zone *zone);
2925 2926
2926/* return values int ....just for stop_machine() */ 2927/* return values int ....just for stop_machine() */
2927static int __build_all_zonelists(void *dummy) 2928static __init_refok int __build_all_zonelists(void *data)
2928{ 2929{
2929 int nid; 2930 int nid;
2930 int cpu; 2931 int cpu;
@@ -2939,6 +2940,14 @@ static int __build_all_zonelists(void *dummy)
2939 build_zonelist_cache(pgdat); 2940 build_zonelist_cache(pgdat);
2940 } 2941 }
2941 2942
2943#ifdef CONFIG_MEMORY_HOTPLUG
2944 /* Setup real pagesets for the new zone */
2945 if (data) {
2946 struct zone *zone = data;
2947 setup_zone_pageset(zone);
2948 }
2949#endif
2950
2942 /* 2951 /*
2943 * Initialize the boot_pagesets that are going to be used 2952 * Initialize the boot_pagesets that are going to be used
2944 * for bootstrapping processors. The real pagesets for 2953 * for bootstrapping processors. The real pagesets for
@@ -2958,7 +2967,7 @@ static int __build_all_zonelists(void *dummy)
2958 return 0; 2967 return 0;
2959} 2968}
2960 2969
2961void build_all_zonelists(void) 2970void build_all_zonelists(void *data)
2962{ 2971{
2963 set_zonelist_order(); 2972 set_zonelist_order();
2964 2973
@@ -2969,7 +2978,7 @@ void build_all_zonelists(void)
2969 } else { 2978 } else {
2970 /* we have to stop all cpus to guarantee there is no user 2979 /* we have to stop all cpus to guarantee there is no user
2971 of zonelist */ 2980 of zonelist */
2972 stop_machine(__build_all_zonelists, NULL, NULL); 2981 stop_machine(__build_all_zonelists, data, NULL);
2973 /* cpuset refresh routine should be here */ 2982 /* cpuset refresh routine should be here */
2974 } 2983 }
2975 vm_total_pages = nr_free_pagecache_pages(); 2984 vm_total_pages = nr_free_pagecache_pages();