aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/mmzone.h1
-rw-r--r--kernel/cpu.c5
-rw-r--r--mm/memory_hotplug.c11
-rw-r--r--mm/page_alloc.c15
4 files changed, 22 insertions, 10 deletions
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index a367ed5bb3fe..0fa491326c4a 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -650,6 +650,7 @@ typedef struct pglist_data {
650 650
651#include <linux/memory_hotplug.h> 651#include <linux/memory_hotplug.h>
652 652
653extern struct mutex zonelists_mutex;
653void get_zone_counts(unsigned long *active, unsigned long *inactive, 654void get_zone_counts(unsigned long *active, unsigned long *inactive,
654 unsigned long *free); 655 unsigned long *free);
655void build_all_zonelists(void *data); 656void build_all_zonelists(void *data);
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 3e8b3ba27175..124ad9d6be16 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -357,8 +357,11 @@ int __cpuinit cpu_up(unsigned int cpu)
357 return -ENOMEM; 357 return -ENOMEM;
358 } 358 }
359 359
360 if (pgdat->node_zonelists->_zonerefs->zone == NULL) 360 if (pgdat->node_zonelists->_zonerefs->zone == NULL) {
361 mutex_lock(&zonelists_mutex);
361 build_all_zonelists(NULL); 362 build_all_zonelists(NULL);
363 mutex_unlock(&zonelists_mutex);
364 }
362#endif 365#endif
363 366
364 cpu_maps_update_begin(); 367 cpu_maps_update_begin();
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 089cc97aed3c..a4cfcdc00455 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -389,11 +389,6 @@ 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);
397 392
398 arg.start_pfn = pfn; 393 arg.start_pfn = pfn;
399 arg.nr_pages = nr_pages; 394 arg.nr_pages = nr_pages;
@@ -420,14 +415,14 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
420 * This means the page allocator ignores this zone. 415 * This means the page allocator ignores this zone.
421 * So, zonelist must be updated after online. 416 * So, zonelist must be updated after online.
422 */ 417 */
423 mutex_lock(&zone_pageset_mutex); 418 mutex_lock(&zonelists_mutex);
424 if (!populated_zone(zone)) 419 if (!populated_zone(zone))
425 need_zonelists_rebuild = 1; 420 need_zonelists_rebuild = 1;
426 421
427 ret = walk_system_ram_range(pfn, nr_pages, &onlined_pages, 422 ret = walk_system_ram_range(pfn, nr_pages, &onlined_pages,
428 online_pages_range); 423 online_pages_range);
429 if (ret) { 424 if (ret) {
430 mutex_unlock(&zone_pageset_mutex); 425 mutex_unlock(&zonelists_mutex);
431 printk(KERN_DEBUG "online_pages %lx at %lx failed\n", 426 printk(KERN_DEBUG "online_pages %lx at %lx failed\n",
432 nr_pages, pfn); 427 nr_pages, pfn);
433 memory_notify(MEM_CANCEL_ONLINE, &arg); 428 memory_notify(MEM_CANCEL_ONLINE, &arg);
@@ -441,7 +436,7 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
441 else 436 else
442 zone_pcp_update(zone); 437 zone_pcp_update(zone);
443 438
444 mutex_unlock(&zone_pageset_mutex); 439 mutex_unlock(&zonelists_mutex);
445 setup_per_zone_wmarks(); 440 setup_per_zone_wmarks();
446 calculate_zone_inactive_ratio(zone); 441 calculate_zone_inactive_ratio(zone);
447 if (onlined_pages) { 442 if (onlined_pages) {
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 21c52d2d8624..08b349931ebc 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2571,8 +2571,11 @@ int numa_zonelist_order_handler(ctl_table *table, int write,
2571 strncpy((char*)table->data, saved_string, 2571 strncpy((char*)table->data, saved_string,
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 mutex_lock(&zonelists_mutex);
2575 build_all_zonelists(NULL); 2576 build_all_zonelists(NULL);
2577 mutex_unlock(&zonelists_mutex);
2578 }
2576 } 2579 }
2577out: 2580out:
2578 mutex_unlock(&zl_order_mutex); 2581 mutex_unlock(&zl_order_mutex);
@@ -2924,6 +2927,12 @@ static void setup_pageset(struct per_cpu_pageset *p, unsigned long batch);
2924static DEFINE_PER_CPU(struct per_cpu_pageset, boot_pageset); 2927static DEFINE_PER_CPU(struct per_cpu_pageset, boot_pageset);
2925static void setup_zone_pageset(struct zone *zone); 2928static void setup_zone_pageset(struct zone *zone);
2926 2929
2930/*
2931 * Global mutex to protect against size modification of zonelists
2932 * as well as to serialize pageset setup for the new populated zone.
2933 */
2934DEFINE_MUTEX(zonelists_mutex);
2935
2927/* return values int ....just for stop_machine() */ 2936/* return values int ....just for stop_machine() */
2928static __init_refok int __build_all_zonelists(void *data) 2937static __init_refok int __build_all_zonelists(void *data)
2929{ 2938{
@@ -2967,6 +2976,10 @@ static __init_refok int __build_all_zonelists(void *data)
2967 return 0; 2976 return 0;
2968} 2977}
2969 2978
2979/*
2980 * Called with zonelists_mutex held always
2981 * unless system_state == SYSTEM_BOOTING.
2982 */
2970void build_all_zonelists(void *data) 2983void build_all_zonelists(void *data)
2971{ 2984{
2972 set_zonelist_order(); 2985 set_zonelist_order();