diff options
author | Jiri Kosina <jkosina@suse.cz> | 2011-04-26 04:22:15 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2011-04-26 04:22:59 -0400 |
commit | 07f9479a40cc778bc1462ada11f95b01360ae4ff (patch) | |
tree | 0676cf38df3844004bb3ebfd99dfa67a4a8998f5 /mm/page_alloc.c | |
parent | 9d5e6bdb3013acfb311ab407eeca0b6a6a3dedbf (diff) | |
parent | cd2e49e90f1cae7726c9a2c54488d881d7f1cd1c (diff) |
Merge branch 'master' into for-next
Fast-forwarded to current state of Linus' tree as there are patches to be
applied for files that didn't exist on the old branch.
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r-- | mm/page_alloc.c | 95 |
1 files changed, 81 insertions, 14 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 48c9737ad49a..df9fc3385fb2 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -53,6 +53,7 @@ | |||
53 | #include <linux/compaction.h> | 53 | #include <linux/compaction.h> |
54 | #include <trace/events/kmem.h> | 54 | #include <trace/events/kmem.h> |
55 | #include <linux/ftrace_event.h> | 55 | #include <linux/ftrace_event.h> |
56 | #include <linux/memcontrol.h> | ||
56 | 57 | ||
57 | #include <asm/tlbflush.h> | 58 | #include <asm/tlbflush.h> |
58 | #include <asm/div64.h> | 59 | #include <asm/div64.h> |
@@ -565,7 +566,8 @@ static inline int free_pages_check(struct page *page) | |||
565 | if (unlikely(page_mapcount(page) | | 566 | if (unlikely(page_mapcount(page) | |
566 | (page->mapping != NULL) | | 567 | (page->mapping != NULL) | |
567 | (atomic_read(&page->_count) != 0) | | 568 | (atomic_read(&page->_count) != 0) | |
568 | (page->flags & PAGE_FLAGS_CHECK_AT_FREE))) { | 569 | (page->flags & PAGE_FLAGS_CHECK_AT_FREE) | |
570 | (mem_cgroup_bad_page_check(page)))) { | ||
569 | bad_page(page); | 571 | bad_page(page); |
570 | return 1; | 572 | return 1; |
571 | } | 573 | } |
@@ -614,6 +616,10 @@ static void free_pcppages_bulk(struct zone *zone, int count, | |||
614 | list = &pcp->lists[migratetype]; | 616 | list = &pcp->lists[migratetype]; |
615 | } while (list_empty(list)); | 617 | } while (list_empty(list)); |
616 | 618 | ||
619 | /* This is the only non-empty list. Free them all. */ | ||
620 | if (batch_free == MIGRATE_PCPTYPES) | ||
621 | batch_free = to_free; | ||
622 | |||
617 | do { | 623 | do { |
618 | page = list_entry(list->prev, struct page, lru); | 624 | page = list_entry(list->prev, struct page, lru); |
619 | /* must delete as __free_one_page list manipulates */ | 625 | /* must delete as __free_one_page list manipulates */ |
@@ -750,7 +756,8 @@ static inline int check_new_page(struct page *page) | |||
750 | if (unlikely(page_mapcount(page) | | 756 | if (unlikely(page_mapcount(page) | |
751 | (page->mapping != NULL) | | 757 | (page->mapping != NULL) | |
752 | (atomic_read(&page->_count) != 0) | | 758 | (atomic_read(&page->_count) != 0) | |
753 | (page->flags & PAGE_FLAGS_CHECK_AT_PREP))) { | 759 | (page->flags & PAGE_FLAGS_CHECK_AT_PREP) | |
760 | (mem_cgroup_bad_page_check(page)))) { | ||
754 | bad_page(page); | 761 | bad_page(page); |
755 | return 1; | 762 | return 1; |
756 | } | 763 | } |
@@ -863,9 +870,8 @@ static int move_freepages(struct zone *zone, | |||
863 | } | 870 | } |
864 | 871 | ||
865 | order = page_order(page); | 872 | order = page_order(page); |
866 | list_del(&page->lru); | 873 | list_move(&page->lru, |
867 | list_add(&page->lru, | 874 | &zone->free_area[order].free_list[migratetype]); |
868 | &zone->free_area[order].free_list[migratetype]); | ||
869 | page += 1 << order; | 875 | page += 1 << order; |
870 | pages_moved += 1 << order; | 876 | pages_moved += 1 << order; |
871 | } | 877 | } |
@@ -936,7 +942,7 @@ __rmqueue_fallback(struct zone *zone, int order, int start_migratetype) | |||
936 | * If breaking a large block of pages, move all free | 942 | * If breaking a large block of pages, move all free |
937 | * pages to the preferred allocation list. If falling | 943 | * pages to the preferred allocation list. If falling |
938 | * back for a reclaimable kernel allocation, be more | 944 | * back for a reclaimable kernel allocation, be more |
939 | * agressive about taking ownership of free pages | 945 | * aggressive about taking ownership of free pages |
940 | */ | 946 | */ |
941 | if (unlikely(current_order >= (pageblock_order >> 1)) || | 947 | if (unlikely(current_order >= (pageblock_order >> 1)) || |
942 | start_migratetype == MIGRATE_RECLAIMABLE || | 948 | start_migratetype == MIGRATE_RECLAIMABLE || |
@@ -1333,7 +1339,7 @@ again: | |||
1333 | } | 1339 | } |
1334 | 1340 | ||
1335 | __count_zone_vm_events(PGALLOC, zone, 1 << order); | 1341 | __count_zone_vm_events(PGALLOC, zone, 1 << order); |
1336 | zone_statistics(preferred_zone, zone); | 1342 | zone_statistics(preferred_zone, zone, gfp_flags); |
1337 | local_irq_restore(flags); | 1343 | local_irq_restore(flags); |
1338 | 1344 | ||
1339 | VM_BUG_ON(bad_range(zone, page)); | 1345 | VM_BUG_ON(bad_range(zone, page)); |
@@ -1714,6 +1720,20 @@ try_next_zone: | |||
1714 | return page; | 1720 | return page; |
1715 | } | 1721 | } |
1716 | 1722 | ||
1723 | /* | ||
1724 | * Large machines with many possible nodes should not always dump per-node | ||
1725 | * meminfo in irq context. | ||
1726 | */ | ||
1727 | static inline bool should_suppress_show_mem(void) | ||
1728 | { | ||
1729 | bool ret = false; | ||
1730 | |||
1731 | #if NODES_SHIFT > 8 | ||
1732 | ret = in_interrupt(); | ||
1733 | #endif | ||
1734 | return ret; | ||
1735 | } | ||
1736 | |||
1717 | static inline int | 1737 | static inline int |
1718 | should_alloc_retry(gfp_t gfp_mask, unsigned int order, | 1738 | should_alloc_retry(gfp_t gfp_mask, unsigned int order, |
1719 | unsigned long pages_reclaimed) | 1739 | unsigned long pages_reclaimed) |
@@ -2085,7 +2105,7 @@ rebalance: | |||
2085 | sync_migration); | 2105 | sync_migration); |
2086 | if (page) | 2106 | if (page) |
2087 | goto got_pg; | 2107 | goto got_pg; |
2088 | sync_migration = true; | 2108 | sync_migration = !(gfp_mask & __GFP_NO_KSWAPD); |
2089 | 2109 | ||
2090 | /* Try direct reclaim and then allocating */ | 2110 | /* Try direct reclaim and then allocating */ |
2091 | page = __alloc_pages_direct_reclaim(gfp_mask, order, | 2111 | page = __alloc_pages_direct_reclaim(gfp_mask, order, |
@@ -2157,11 +2177,25 @@ rebalance: | |||
2157 | 2177 | ||
2158 | nopage: | 2178 | nopage: |
2159 | if (!(gfp_mask & __GFP_NOWARN) && printk_ratelimit()) { | 2179 | if (!(gfp_mask & __GFP_NOWARN) && printk_ratelimit()) { |
2160 | printk(KERN_WARNING "%s: page allocation failure." | 2180 | unsigned int filter = SHOW_MEM_FILTER_NODES; |
2161 | " order:%d, mode:0x%x\n", | 2181 | |
2182 | /* | ||
2183 | * This documents exceptions given to allocations in certain | ||
2184 | * contexts that are allowed to allocate outside current's set | ||
2185 | * of allowed nodes. | ||
2186 | */ | ||
2187 | if (!(gfp_mask & __GFP_NOMEMALLOC)) | ||
2188 | if (test_thread_flag(TIF_MEMDIE) || | ||
2189 | (current->flags & (PF_MEMALLOC | PF_EXITING))) | ||
2190 | filter &= ~SHOW_MEM_FILTER_NODES; | ||
2191 | if (in_interrupt() || !wait) | ||
2192 | filter &= ~SHOW_MEM_FILTER_NODES; | ||
2193 | |||
2194 | pr_warning("%s: page allocation failure. order:%d, mode:0x%x\n", | ||
2162 | current->comm, order, gfp_mask); | 2195 | current->comm, order, gfp_mask); |
2163 | dump_stack(); | 2196 | dump_stack(); |
2164 | show_mem(); | 2197 | if (!should_suppress_show_mem()) |
2198 | show_mem(filter); | ||
2165 | } | 2199 | } |
2166 | return page; | 2200 | return page; |
2167 | got_pg: | 2201 | got_pg: |
@@ -2411,19 +2445,42 @@ void si_meminfo_node(struct sysinfo *val, int nid) | |||
2411 | } | 2445 | } |
2412 | #endif | 2446 | #endif |
2413 | 2447 | ||
2448 | /* | ||
2449 | * Determine whether the zone's node should be displayed or not, depending on | ||
2450 | * whether SHOW_MEM_FILTER_NODES was passed to __show_free_areas(). | ||
2451 | */ | ||
2452 | static bool skip_free_areas_zone(unsigned int flags, const struct zone *zone) | ||
2453 | { | ||
2454 | bool ret = false; | ||
2455 | |||
2456 | if (!(flags & SHOW_MEM_FILTER_NODES)) | ||
2457 | goto out; | ||
2458 | |||
2459 | get_mems_allowed(); | ||
2460 | ret = !node_isset(zone->zone_pgdat->node_id, | ||
2461 | cpuset_current_mems_allowed); | ||
2462 | put_mems_allowed(); | ||
2463 | out: | ||
2464 | return ret; | ||
2465 | } | ||
2466 | |||
2414 | #define K(x) ((x) << (PAGE_SHIFT-10)) | 2467 | #define K(x) ((x) << (PAGE_SHIFT-10)) |
2415 | 2468 | ||
2416 | /* | 2469 | /* |
2417 | * Show free area list (used inside shift_scroll-lock stuff) | 2470 | * Show free area list (used inside shift_scroll-lock stuff) |
2418 | * We also calculate the percentage fragmentation. We do this by counting the | 2471 | * We also calculate the percentage fragmentation. We do this by counting the |
2419 | * memory on each free list with the exception of the first item on the list. | 2472 | * memory on each free list with the exception of the first item on the list. |
2473 | * Suppresses nodes that are not allowed by current's cpuset if | ||
2474 | * SHOW_MEM_FILTER_NODES is passed. | ||
2420 | */ | 2475 | */ |
2421 | void show_free_areas(void) | 2476 | void __show_free_areas(unsigned int filter) |
2422 | { | 2477 | { |
2423 | int cpu; | 2478 | int cpu; |
2424 | struct zone *zone; | 2479 | struct zone *zone; |
2425 | 2480 | ||
2426 | for_each_populated_zone(zone) { | 2481 | for_each_populated_zone(zone) { |
2482 | if (skip_free_areas_zone(filter, zone)) | ||
2483 | continue; | ||
2427 | show_node(zone); | 2484 | show_node(zone); |
2428 | printk("%s per-cpu:\n", zone->name); | 2485 | printk("%s per-cpu:\n", zone->name); |
2429 | 2486 | ||
@@ -2465,6 +2522,8 @@ void show_free_areas(void) | |||
2465 | for_each_populated_zone(zone) { | 2522 | for_each_populated_zone(zone) { |
2466 | int i; | 2523 | int i; |
2467 | 2524 | ||
2525 | if (skip_free_areas_zone(filter, zone)) | ||
2526 | continue; | ||
2468 | show_node(zone); | 2527 | show_node(zone); |
2469 | printk("%s" | 2528 | printk("%s" |
2470 | " free:%lukB" | 2529 | " free:%lukB" |
@@ -2532,6 +2591,8 @@ void show_free_areas(void) | |||
2532 | for_each_populated_zone(zone) { | 2591 | for_each_populated_zone(zone) { |
2533 | unsigned long nr[MAX_ORDER], flags, order, total = 0; | 2592 | unsigned long nr[MAX_ORDER], flags, order, total = 0; |
2534 | 2593 | ||
2594 | if (skip_free_areas_zone(filter, zone)) | ||
2595 | continue; | ||
2535 | show_node(zone); | 2596 | show_node(zone); |
2536 | printk("%s: ", zone->name); | 2597 | printk("%s: ", zone->name); |
2537 | 2598 | ||
@@ -2551,6 +2612,11 @@ void show_free_areas(void) | |||
2551 | show_swap_cache_info(); | 2612 | show_swap_cache_info(); |
2552 | } | 2613 | } |
2553 | 2614 | ||
2615 | void show_free_areas(void) | ||
2616 | { | ||
2617 | __show_free_areas(0); | ||
2618 | } | ||
2619 | |||
2554 | static void zoneref_set_zone(struct zone *zone, struct zoneref *zoneref) | 2620 | static void zoneref_set_zone(struct zone *zone, struct zoneref *zoneref) |
2555 | { | 2621 | { |
2556 | zoneref->zone = zone; | 2622 | zoneref->zone = zone; |
@@ -3110,7 +3176,7 @@ static __init_refok int __build_all_zonelists(void *data) | |||
3110 | * Called with zonelists_mutex held always | 3176 | * Called with zonelists_mutex held always |
3111 | * unless system_state == SYSTEM_BOOTING. | 3177 | * unless system_state == SYSTEM_BOOTING. |
3112 | */ | 3178 | */ |
3113 | void build_all_zonelists(void *data) | 3179 | void __ref build_all_zonelists(void *data) |
3114 | { | 3180 | { |
3115 | set_zonelist_order(); | 3181 | set_zonelist_order(); |
3116 | 3182 | ||
@@ -3860,7 +3926,7 @@ static void __init find_usable_zone_for_movable(void) | |||
3860 | 3926 | ||
3861 | /* | 3927 | /* |
3862 | * The zone ranges provided by the architecture do not include ZONE_MOVABLE | 3928 | * The zone ranges provided by the architecture do not include ZONE_MOVABLE |
3863 | * because it is sized independant of architecture. Unlike the other zones, | 3929 | * because it is sized independent of architecture. Unlike the other zones, |
3864 | * the starting point for ZONE_MOVABLE is not fixed. It may be different | 3930 | * the starting point for ZONE_MOVABLE is not fixed. It may be different |
3865 | * in each node depending on the size of each node and how evenly kernelcore | 3931 | * in each node depending on the size of each node and how evenly kernelcore |
3866 | * is distributed. This helper function adjusts the zone ranges | 3932 | * is distributed. This helper function adjusts the zone ranges |
@@ -5621,4 +5687,5 @@ void dump_page(struct page *page) | |||
5621 | page, atomic_read(&page->_count), page_mapcount(page), | 5687 | page, atomic_read(&page->_count), page_mapcount(page), |
5622 | page->mapping, page->index); | 5688 | page->mapping, page->index); |
5623 | dump_page_flags(page->flags); | 5689 | dump_page_flags(page->flags); |
5690 | mem_cgroup_print_bad_page(page); | ||
5624 | } | 5691 | } |