aboutsummaryrefslogtreecommitdiffstats
path: root/mm/page_alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r--mm/page_alloc.c131
1 files changed, 11 insertions, 120 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2b3bf6767d54..8fd42aa7c4bd 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4224,7 +4224,7 @@ static void show_migration_types(unsigned char type)
4224 } 4224 }
4225 4225
4226 *p = '\0'; 4226 *p = '\0';
4227 printk("(%s) ", tmp); 4227 printk(KERN_CONT "(%s) ", tmp);
4228} 4228}
4229 4229
4230/* 4230/*
@@ -4335,7 +4335,8 @@ void show_free_areas(unsigned int filter)
4335 free_pcp += per_cpu_ptr(zone->pageset, cpu)->pcp.count; 4335 free_pcp += per_cpu_ptr(zone->pageset, cpu)->pcp.count;
4336 4336
4337 show_node(zone); 4337 show_node(zone);
4338 printk("%s" 4338 printk(KERN_CONT
4339 "%s"
4339 " free:%lukB" 4340 " free:%lukB"
4340 " min:%lukB" 4341 " min:%lukB"
4341 " low:%lukB" 4342 " low:%lukB"
@@ -4382,8 +4383,8 @@ void show_free_areas(unsigned int filter)
4382 K(zone_page_state(zone, NR_FREE_CMA_PAGES))); 4383 K(zone_page_state(zone, NR_FREE_CMA_PAGES)));
4383 printk("lowmem_reserve[]:"); 4384 printk("lowmem_reserve[]:");
4384 for (i = 0; i < MAX_NR_ZONES; i++) 4385 for (i = 0; i < MAX_NR_ZONES; i++)
4385 printk(" %ld", zone->lowmem_reserve[i]); 4386 printk(KERN_CONT " %ld", zone->lowmem_reserve[i]);
4386 printk("\n"); 4387 printk(KERN_CONT "\n");
4387 } 4388 }
4388 4389
4389 for_each_populated_zone(zone) { 4390 for_each_populated_zone(zone) {
@@ -4394,7 +4395,7 @@ void show_free_areas(unsigned int filter)
4394 if (skip_free_areas_node(filter, zone_to_nid(zone))) 4395 if (skip_free_areas_node(filter, zone_to_nid(zone)))
4395 continue; 4396 continue;
4396 show_node(zone); 4397 show_node(zone);
4397 printk("%s: ", zone->name); 4398 printk(KERN_CONT "%s: ", zone->name);
4398 4399
4399 spin_lock_irqsave(&zone->lock, flags); 4400 spin_lock_irqsave(&zone->lock, flags);
4400 for (order = 0; order < MAX_ORDER; order++) { 4401 for (order = 0; order < MAX_ORDER; order++) {
@@ -4412,11 +4413,12 @@ void show_free_areas(unsigned int filter)
4412 } 4413 }
4413 spin_unlock_irqrestore(&zone->lock, flags); 4414 spin_unlock_irqrestore(&zone->lock, flags);
4414 for (order = 0; order < MAX_ORDER; order++) { 4415 for (order = 0; order < MAX_ORDER; order++) {
4415 printk("%lu*%lukB ", nr[order], K(1UL) << order); 4416 printk(KERN_CONT "%lu*%lukB ",
4417 nr[order], K(1UL) << order);
4416 if (nr[order]) 4418 if (nr[order])
4417 show_migration_types(types[order]); 4419 show_migration_types(types[order]);
4418 } 4420 }
4419 printk("= %lukB\n", K(total)); 4421 printk(KERN_CONT "= %lukB\n", K(total));
4420 } 4422 }
4421 4423
4422 hugetlb_show_meminfo(); 4424 hugetlb_show_meminfo();
@@ -4977,72 +4979,6 @@ void __ref build_all_zonelists(pg_data_t *pgdat, struct zone *zone)
4977} 4979}
4978 4980
4979/* 4981/*
4980 * Helper functions to size the waitqueue hash table.
4981 * Essentially these want to choose hash table sizes sufficiently
4982 * large so that collisions trying to wait on pages are rare.
4983 * But in fact, the number of active page waitqueues on typical
4984 * systems is ridiculously low, less than 200. So this is even
4985 * conservative, even though it seems large.
4986 *
4987 * The constant PAGES_PER_WAITQUEUE specifies the ratio of pages to
4988 * waitqueues, i.e. the size of the waitq table given the number of pages.
4989 */
4990#define PAGES_PER_WAITQUEUE 256
4991
4992#ifndef CONFIG_MEMORY_HOTPLUG
4993static inline unsigned long wait_table_hash_nr_entries(unsigned long pages)
4994{
4995 unsigned long size = 1;
4996
4997 pages /= PAGES_PER_WAITQUEUE;
4998
4999 while (size < pages)
5000 size <<= 1;
5001
5002 /*
5003 * Once we have dozens or even hundreds of threads sleeping
5004 * on IO we've got bigger problems than wait queue collision.
5005 * Limit the size of the wait table to a reasonable size.
5006 */
5007 size = min(size, 4096UL);
5008
5009 return max(size, 4UL);
5010}
5011#else
5012/*
5013 * A zone's size might be changed by hot-add, so it is not possible to determine
5014 * a suitable size for its wait_table. So we use the maximum size now.
5015 *
5016 * The max wait table size = 4096 x sizeof(wait_queue_head_t). ie:
5017 *
5018 * i386 (preemption config) : 4096 x 16 = 64Kbyte.
5019 * ia64, x86-64 (no preemption): 4096 x 20 = 80Kbyte.
5020 * ia64, x86-64 (preemption) : 4096 x 24 = 96Kbyte.
5021 *
5022 * The maximum entries are prepared when a zone's memory is (512K + 256) pages
5023 * or more by the traditional way. (See above). It equals:
5024 *
5025 * i386, x86-64, powerpc(4K page size) : = ( 2G + 1M)byte.
5026 * ia64(16K page size) : = ( 8G + 4M)byte.
5027 * powerpc (64K page size) : = (32G +16M)byte.
5028 */
5029static inline unsigned long wait_table_hash_nr_entries(unsigned long pages)
5030{
5031 return 4096UL;
5032}
5033#endif
5034
5035/*
5036 * This is an integer logarithm so that shifts can be used later
5037 * to extract the more random high bits from the multiplicative
5038 * hash function before the remainder is taken.
5039 */
5040static inline unsigned long wait_table_bits(unsigned long size)
5041{
5042 return ffz(~size);
5043}
5044
5045/*
5046 * Initially all pages are reserved - free ones are freed 4982 * Initially all pages are reserved - free ones are freed
5047 * up by free_all_bootmem() once the early boot process is 4983 * up by free_all_bootmem() once the early boot process is
5048 * done. Non-atomic initialization, single-pass. 4984 * done. Non-atomic initialization, single-pass.
@@ -5304,49 +5240,6 @@ void __init setup_per_cpu_pageset(void)
5304 alloc_percpu(struct per_cpu_nodestat); 5240 alloc_percpu(struct per_cpu_nodestat);
5305} 5241}
5306 5242
5307static noinline __ref
5308int zone_wait_table_init(struct zone *zone, unsigned long zone_size_pages)
5309{
5310 int i;
5311 size_t alloc_size;
5312
5313 /*
5314 * The per-page waitqueue mechanism uses hashed waitqueues
5315 * per zone.
5316 */
5317 zone->wait_table_hash_nr_entries =
5318 wait_table_hash_nr_entries(zone_size_pages);
5319 zone->wait_table_bits =
5320 wait_table_bits(zone->wait_table_hash_nr_entries);
5321 alloc_size = zone->wait_table_hash_nr_entries
5322 * sizeof(wait_queue_head_t);
5323
5324 if (!slab_is_available()) {
5325 zone->wait_table = (wait_queue_head_t *)
5326 memblock_virt_alloc_node_nopanic(
5327 alloc_size, zone->zone_pgdat->node_id);
5328 } else {
5329 /*
5330 * This case means that a zone whose size was 0 gets new memory
5331 * via memory hot-add.
5332 * But it may be the case that a new node was hot-added. In
5333 * this case vmalloc() will not be able to use this new node's
5334 * memory - this wait_table must be initialized to use this new
5335 * node itself as well.
5336 * To use this new node's memory, further consideration will be
5337 * necessary.
5338 */
5339 zone->wait_table = vmalloc(alloc_size);
5340 }
5341 if (!zone->wait_table)
5342 return -ENOMEM;
5343
5344 for (i = 0; i < zone->wait_table_hash_nr_entries; ++i)
5345 init_waitqueue_head(zone->wait_table + i);
5346
5347 return 0;
5348}
5349
5350static __meminit void zone_pcp_init(struct zone *zone) 5243static __meminit void zone_pcp_init(struct zone *zone)
5351{ 5244{
5352 /* 5245 /*
@@ -5367,10 +5260,7 @@ int __meminit init_currently_empty_zone(struct zone *zone,
5367 unsigned long size) 5260 unsigned long size)
5368{ 5261{
5369 struct pglist_data *pgdat = zone->zone_pgdat; 5262 struct pglist_data *pgdat = zone->zone_pgdat;
5370 int ret; 5263
5371 ret = zone_wait_table_init(zone, size);
5372 if (ret)
5373 return ret;
5374 pgdat->nr_zones = zone_idx(zone) + 1; 5264 pgdat->nr_zones = zone_idx(zone) + 1;
5375 5265
5376 zone->zone_start_pfn = zone_start_pfn; 5266 zone->zone_start_pfn = zone_start_pfn;
@@ -5382,6 +5272,7 @@ int __meminit init_currently_empty_zone(struct zone *zone,
5382 zone_start_pfn, (zone_start_pfn + size)); 5272 zone_start_pfn, (zone_start_pfn + size));
5383 5273
5384 zone_init_free_lists(zone); 5274 zone_init_free_lists(zone);
5275 zone->initialized = 1;
5385 5276
5386 return 0; 5277 return 0;
5387} 5278}