diff options
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r-- | mm/page_alloc.c | 357 |
1 files changed, 129 insertions, 228 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 18cee0d4c8a2..736d8e1b6381 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -53,8 +53,6 @@ | |||
53 | #include <linux/kmemleak.h> | 53 | #include <linux/kmemleak.h> |
54 | #include <linux/compaction.h> | 54 | #include <linux/compaction.h> |
55 | #include <trace/events/kmem.h> | 55 | #include <trace/events/kmem.h> |
56 | #include <linux/ftrace_event.h> | ||
57 | #include <linux/memcontrol.h> | ||
58 | #include <linux/prefetch.h> | 56 | #include <linux/prefetch.h> |
59 | #include <linux/mm_inline.h> | 57 | #include <linux/mm_inline.h> |
60 | #include <linux/migrate.h> | 58 | #include <linux/migrate.h> |
@@ -85,6 +83,7 @@ EXPORT_PER_CPU_SYMBOL(numa_node); | |||
85 | */ | 83 | */ |
86 | DEFINE_PER_CPU(int, _numa_mem_); /* Kernel "local memory" node */ | 84 | DEFINE_PER_CPU(int, _numa_mem_); /* Kernel "local memory" node */ |
87 | EXPORT_PER_CPU_SYMBOL(_numa_mem_); | 85 | EXPORT_PER_CPU_SYMBOL(_numa_mem_); |
86 | int _node_numa_mem_[MAX_NUMNODES]; | ||
88 | #endif | 87 | #endif |
89 | 88 | ||
90 | /* | 89 | /* |
@@ -1014,7 +1013,7 @@ int move_freepages(struct zone *zone, | |||
1014 | * Remove at a later date when no bug reports exist related to | 1013 | * Remove at a later date when no bug reports exist related to |
1015 | * grouping pages by mobility | 1014 | * grouping pages by mobility |
1016 | */ | 1015 | */ |
1017 | BUG_ON(page_zone(start_page) != page_zone(end_page)); | 1016 | VM_BUG_ON(page_zone(start_page) != page_zone(end_page)); |
1018 | #endif | 1017 | #endif |
1019 | 1018 | ||
1020 | for (page = start_page; page <= end_page;) { | 1019 | for (page = start_page; page <= end_page;) { |
@@ -1612,9 +1611,9 @@ again: | |||
1612 | } | 1611 | } |
1613 | 1612 | ||
1614 | __mod_zone_page_state(zone, NR_ALLOC_BATCH, -(1 << order)); | 1613 | __mod_zone_page_state(zone, NR_ALLOC_BATCH, -(1 << order)); |
1615 | if (zone_page_state(zone, NR_ALLOC_BATCH) == 0 && | 1614 | if (atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH]) <= 0 && |
1616 | !zone_is_fair_depleted(zone)) | 1615 | !test_bit(ZONE_FAIR_DEPLETED, &zone->flags)) |
1617 | zone_set_flag(zone, ZONE_FAIR_DEPLETED); | 1616 | set_bit(ZONE_FAIR_DEPLETED, &zone->flags); |
1618 | 1617 | ||
1619 | __count_zone_vm_events(PGALLOC, zone, 1 << order); | 1618 | __count_zone_vm_events(PGALLOC, zone, 1 << order); |
1620 | zone_statistics(preferred_zone, zone, gfp_flags); | 1619 | zone_statistics(preferred_zone, zone, gfp_flags); |
@@ -1934,7 +1933,7 @@ static void reset_alloc_batches(struct zone *preferred_zone) | |||
1934 | mod_zone_page_state(zone, NR_ALLOC_BATCH, | 1933 | mod_zone_page_state(zone, NR_ALLOC_BATCH, |
1935 | high_wmark_pages(zone) - low_wmark_pages(zone) - | 1934 | high_wmark_pages(zone) - low_wmark_pages(zone) - |
1936 | atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH])); | 1935 | atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH])); |
1937 | zone_clear_flag(zone, ZONE_FAIR_DEPLETED); | 1936 | clear_bit(ZONE_FAIR_DEPLETED, &zone->flags); |
1938 | } while (zone++ != preferred_zone); | 1937 | } while (zone++ != preferred_zone); |
1939 | } | 1938 | } |
1940 | 1939 | ||
@@ -1985,7 +1984,7 @@ zonelist_scan: | |||
1985 | if (alloc_flags & ALLOC_FAIR) { | 1984 | if (alloc_flags & ALLOC_FAIR) { |
1986 | if (!zone_local(preferred_zone, zone)) | 1985 | if (!zone_local(preferred_zone, zone)) |
1987 | break; | 1986 | break; |
1988 | if (zone_is_fair_depleted(zone)) { | 1987 | if (test_bit(ZONE_FAIR_DEPLETED, &zone->flags)) { |
1989 | nr_fair_skipped++; | 1988 | nr_fair_skipped++; |
1990 | continue; | 1989 | continue; |
1991 | } | 1990 | } |
@@ -2296,58 +2295,72 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, | |||
2296 | struct zonelist *zonelist, enum zone_type high_zoneidx, | 2295 | struct zonelist *zonelist, enum zone_type high_zoneidx, |
2297 | nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone, | 2296 | nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone, |
2298 | int classzone_idx, int migratetype, enum migrate_mode mode, | 2297 | int classzone_idx, int migratetype, enum migrate_mode mode, |
2299 | bool *contended_compaction, bool *deferred_compaction, | 2298 | int *contended_compaction, bool *deferred_compaction) |
2300 | unsigned long *did_some_progress) | ||
2301 | { | 2299 | { |
2302 | if (!order) | 2300 | struct zone *last_compact_zone = NULL; |
2303 | return NULL; | 2301 | unsigned long compact_result; |
2302 | struct page *page; | ||
2304 | 2303 | ||
2305 | if (compaction_deferred(preferred_zone, order)) { | 2304 | if (!order) |
2306 | *deferred_compaction = true; | ||
2307 | return NULL; | 2305 | return NULL; |
2308 | } | ||
2309 | 2306 | ||
2310 | current->flags |= PF_MEMALLOC; | 2307 | current->flags |= PF_MEMALLOC; |
2311 | *did_some_progress = try_to_compact_pages(zonelist, order, gfp_mask, | 2308 | compact_result = try_to_compact_pages(zonelist, order, gfp_mask, |
2312 | nodemask, mode, | 2309 | nodemask, mode, |
2313 | contended_compaction); | 2310 | contended_compaction, |
2311 | &last_compact_zone); | ||
2314 | current->flags &= ~PF_MEMALLOC; | 2312 | current->flags &= ~PF_MEMALLOC; |
2315 | 2313 | ||
2316 | if (*did_some_progress != COMPACT_SKIPPED) { | 2314 | switch (compact_result) { |
2317 | struct page *page; | 2315 | case COMPACT_DEFERRED: |
2316 | *deferred_compaction = true; | ||
2317 | /* fall-through */ | ||
2318 | case COMPACT_SKIPPED: | ||
2319 | return NULL; | ||
2320 | default: | ||
2321 | break; | ||
2322 | } | ||
2318 | 2323 | ||
2319 | /* Page migration frees to the PCP lists but we want merging */ | 2324 | /* |
2320 | drain_pages(get_cpu()); | 2325 | * At least in one zone compaction wasn't deferred or skipped, so let's |
2321 | put_cpu(); | 2326 | * count a compaction stall |
2327 | */ | ||
2328 | count_vm_event(COMPACTSTALL); | ||
2322 | 2329 | ||
2323 | page = get_page_from_freelist(gfp_mask, nodemask, | 2330 | /* Page migration frees to the PCP lists but we want merging */ |
2324 | order, zonelist, high_zoneidx, | 2331 | drain_pages(get_cpu()); |
2325 | alloc_flags & ~ALLOC_NO_WATERMARKS, | 2332 | put_cpu(); |
2326 | preferred_zone, classzone_idx, migratetype); | ||
2327 | if (page) { | ||
2328 | preferred_zone->compact_blockskip_flush = false; | ||
2329 | compaction_defer_reset(preferred_zone, order, true); | ||
2330 | count_vm_event(COMPACTSUCCESS); | ||
2331 | return page; | ||
2332 | } | ||
2333 | 2333 | ||
2334 | /* | 2334 | page = get_page_from_freelist(gfp_mask, nodemask, |
2335 | * It's bad if compaction run occurs and fails. | 2335 | order, zonelist, high_zoneidx, |
2336 | * The most likely reason is that pages exist, | 2336 | alloc_flags & ~ALLOC_NO_WATERMARKS, |
2337 | * but not enough to satisfy watermarks. | 2337 | preferred_zone, classzone_idx, migratetype); |
2338 | */ | ||
2339 | count_vm_event(COMPACTFAIL); | ||
2340 | 2338 | ||
2341 | /* | 2339 | if (page) { |
2342 | * As async compaction considers a subset of pageblocks, only | 2340 | struct zone *zone = page_zone(page); |
2343 | * defer if the failure was a sync compaction failure. | ||
2344 | */ | ||
2345 | if (mode != MIGRATE_ASYNC) | ||
2346 | defer_compaction(preferred_zone, order); | ||
2347 | 2341 | ||
2348 | cond_resched(); | 2342 | zone->compact_blockskip_flush = false; |
2343 | compaction_defer_reset(zone, order, true); | ||
2344 | count_vm_event(COMPACTSUCCESS); | ||
2345 | return page; | ||
2349 | } | 2346 | } |
2350 | 2347 | ||
2348 | /* | ||
2349 | * last_compact_zone is where try_to_compact_pages thought allocation | ||
2350 | * should succeed, so it did not defer compaction. But here we know | ||
2351 | * that it didn't succeed, so we do the defer. | ||
2352 | */ | ||
2353 | if (last_compact_zone && mode != MIGRATE_ASYNC) | ||
2354 | defer_compaction(last_compact_zone, order); | ||
2355 | |||
2356 | /* | ||
2357 | * It's bad if compaction run occurs and fails. The most likely reason | ||
2358 | * is that pages exist, but not enough to satisfy watermarks. | ||
2359 | */ | ||
2360 | count_vm_event(COMPACTFAIL); | ||
2361 | |||
2362 | cond_resched(); | ||
2363 | |||
2351 | return NULL; | 2364 | return NULL; |
2352 | } | 2365 | } |
2353 | #else | 2366 | #else |
@@ -2355,9 +2368,8 @@ static inline struct page * | |||
2355 | __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, | 2368 | __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, |
2356 | struct zonelist *zonelist, enum zone_type high_zoneidx, | 2369 | struct zonelist *zonelist, enum zone_type high_zoneidx, |
2357 | nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone, | 2370 | nodemask_t *nodemask, int alloc_flags, struct zone *preferred_zone, |
2358 | int classzone_idx, int migratetype, | 2371 | int classzone_idx, int migratetype, enum migrate_mode mode, |
2359 | enum migrate_mode mode, bool *contended_compaction, | 2372 | int *contended_compaction, bool *deferred_compaction) |
2360 | bool *deferred_compaction, unsigned long *did_some_progress) | ||
2361 | { | 2373 | { |
2362 | return NULL; | 2374 | return NULL; |
2363 | } | 2375 | } |
@@ -2457,12 +2469,14 @@ __alloc_pages_high_priority(gfp_t gfp_mask, unsigned int order, | |||
2457 | static void wake_all_kswapds(unsigned int order, | 2469 | static void wake_all_kswapds(unsigned int order, |
2458 | struct zonelist *zonelist, | 2470 | struct zonelist *zonelist, |
2459 | enum zone_type high_zoneidx, | 2471 | enum zone_type high_zoneidx, |
2460 | struct zone *preferred_zone) | 2472 | struct zone *preferred_zone, |
2473 | nodemask_t *nodemask) | ||
2461 | { | 2474 | { |
2462 | struct zoneref *z; | 2475 | struct zoneref *z; |
2463 | struct zone *zone; | 2476 | struct zone *zone; |
2464 | 2477 | ||
2465 | for_each_zone_zonelist(zone, z, zonelist, high_zoneidx) | 2478 | for_each_zone_zonelist_nodemask(zone, z, zonelist, |
2479 | high_zoneidx, nodemask) | ||
2466 | wakeup_kswapd(zone, order, zone_idx(preferred_zone)); | 2480 | wakeup_kswapd(zone, order, zone_idx(preferred_zone)); |
2467 | } | 2481 | } |
2468 | 2482 | ||
@@ -2509,7 +2523,7 @@ gfp_to_alloc_flags(gfp_t gfp_mask) | |||
2509 | alloc_flags |= ALLOC_NO_WATERMARKS; | 2523 | alloc_flags |= ALLOC_NO_WATERMARKS; |
2510 | } | 2524 | } |
2511 | #ifdef CONFIG_CMA | 2525 | #ifdef CONFIG_CMA |
2512 | if (allocflags_to_migratetype(gfp_mask) == MIGRATE_MOVABLE) | 2526 | if (gfpflags_to_migratetype(gfp_mask) == MIGRATE_MOVABLE) |
2513 | alloc_flags |= ALLOC_CMA; | 2527 | alloc_flags |= ALLOC_CMA; |
2514 | #endif | 2528 | #endif |
2515 | return alloc_flags; | 2529 | return alloc_flags; |
@@ -2533,7 +2547,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, | |||
2533 | unsigned long did_some_progress; | 2547 | unsigned long did_some_progress; |
2534 | enum migrate_mode migration_mode = MIGRATE_ASYNC; | 2548 | enum migrate_mode migration_mode = MIGRATE_ASYNC; |
2535 | bool deferred_compaction = false; | 2549 | bool deferred_compaction = false; |
2536 | bool contended_compaction = false; | 2550 | int contended_compaction = COMPACT_CONTENDED_NONE; |
2537 | 2551 | ||
2538 | /* | 2552 | /* |
2539 | * In the slowpath, we sanity check order to avoid ever trying to | 2553 | * In the slowpath, we sanity check order to avoid ever trying to |
@@ -2560,7 +2574,8 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, | |||
2560 | 2574 | ||
2561 | restart: | 2575 | restart: |
2562 | if (!(gfp_mask & __GFP_NO_KSWAPD)) | 2576 | if (!(gfp_mask & __GFP_NO_KSWAPD)) |
2563 | wake_all_kswapds(order, zonelist, high_zoneidx, preferred_zone); | 2577 | wake_all_kswapds(order, zonelist, high_zoneidx, |
2578 | preferred_zone, nodemask); | ||
2564 | 2579 | ||
2565 | /* | 2580 | /* |
2566 | * OK, we're below the kswapd watermark and have kicked background | 2581 | * OK, we're below the kswapd watermark and have kicked background |
@@ -2633,20 +2648,40 @@ rebalance: | |||
2633 | preferred_zone, | 2648 | preferred_zone, |
2634 | classzone_idx, migratetype, | 2649 | classzone_idx, migratetype, |
2635 | migration_mode, &contended_compaction, | 2650 | migration_mode, &contended_compaction, |
2636 | &deferred_compaction, | 2651 | &deferred_compaction); |
2637 | &did_some_progress); | ||
2638 | if (page) | 2652 | if (page) |
2639 | goto got_pg; | 2653 | goto got_pg; |
2640 | 2654 | ||
2641 | /* | 2655 | /* Checks for THP-specific high-order allocations */ |
2642 | * If compaction is deferred for high-order allocations, it is because | 2656 | if ((gfp_mask & GFP_TRANSHUGE) == GFP_TRANSHUGE) { |
2643 | * sync compaction recently failed. In this is the case and the caller | 2657 | /* |
2644 | * requested a movable allocation that does not heavily disrupt the | 2658 | * If compaction is deferred for high-order allocations, it is |
2645 | * system then fail the allocation instead of entering direct reclaim. | 2659 | * because sync compaction recently failed. If this is the case |
2646 | */ | 2660 | * and the caller requested a THP allocation, we do not want |
2647 | if ((deferred_compaction || contended_compaction) && | 2661 | * to heavily disrupt the system, so we fail the allocation |
2648 | (gfp_mask & __GFP_NO_KSWAPD)) | 2662 | * instead of entering direct reclaim. |
2649 | goto nopage; | 2663 | */ |
2664 | if (deferred_compaction) | ||
2665 | goto nopage; | ||
2666 | |||
2667 | /* | ||
2668 | * In all zones where compaction was attempted (and not | ||
2669 | * deferred or skipped), lock contention has been detected. | ||
2670 | * For THP allocation we do not want to disrupt the others | ||
2671 | * so we fallback to base pages instead. | ||
2672 | */ | ||
2673 | if (contended_compaction == COMPACT_CONTENDED_LOCK) | ||
2674 | goto nopage; | ||
2675 | |||
2676 | /* | ||
2677 | * If compaction was aborted due to need_resched(), we do not | ||
2678 | * want to further increase allocation latency, unless it is | ||
2679 | * khugepaged trying to collapse. | ||
2680 | */ | ||
2681 | if (contended_compaction == COMPACT_CONTENDED_SCHED | ||
2682 | && !(current->flags & PF_KTHREAD)) | ||
2683 | goto nopage; | ||
2684 | } | ||
2650 | 2685 | ||
2651 | /* | 2686 | /* |
2652 | * It can become very expensive to allocate transparent hugepages at | 2687 | * It can become very expensive to allocate transparent hugepages at |
@@ -2726,8 +2761,7 @@ rebalance: | |||
2726 | preferred_zone, | 2761 | preferred_zone, |
2727 | classzone_idx, migratetype, | 2762 | classzone_idx, migratetype, |
2728 | migration_mode, &contended_compaction, | 2763 | migration_mode, &contended_compaction, |
2729 | &deferred_compaction, | 2764 | &deferred_compaction); |
2730 | &did_some_progress); | ||
2731 | if (page) | 2765 | if (page) |
2732 | goto got_pg; | 2766 | goto got_pg; |
2733 | } | 2767 | } |
@@ -2753,7 +2787,7 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, | |||
2753 | struct zone *preferred_zone; | 2787 | struct zone *preferred_zone; |
2754 | struct zoneref *preferred_zoneref; | 2788 | struct zoneref *preferred_zoneref; |
2755 | struct page *page = NULL; | 2789 | struct page *page = NULL; |
2756 | int migratetype = allocflags_to_migratetype(gfp_mask); | 2790 | int migratetype = gfpflags_to_migratetype(gfp_mask); |
2757 | unsigned int cpuset_mems_cookie; | 2791 | unsigned int cpuset_mems_cookie; |
2758 | int alloc_flags = ALLOC_WMARK_LOW|ALLOC_CPUSET|ALLOC_FAIR; | 2792 | int alloc_flags = ALLOC_WMARK_LOW|ALLOC_CPUSET|ALLOC_FAIR; |
2759 | int classzone_idx; | 2793 | int classzone_idx; |
@@ -2775,6 +2809,9 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, | |||
2775 | if (unlikely(!zonelist->_zonerefs->zone)) | 2809 | if (unlikely(!zonelist->_zonerefs->zone)) |
2776 | return NULL; | 2810 | return NULL; |
2777 | 2811 | ||
2812 | if (IS_ENABLED(CONFIG_CMA) && migratetype == MIGRATE_MOVABLE) | ||
2813 | alloc_flags |= ALLOC_CMA; | ||
2814 | |||
2778 | retry_cpuset: | 2815 | retry_cpuset: |
2779 | cpuset_mems_cookie = read_mems_allowed_begin(); | 2816 | cpuset_mems_cookie = read_mems_allowed_begin(); |
2780 | 2817 | ||
@@ -2786,10 +2823,6 @@ retry_cpuset: | |||
2786 | goto out; | 2823 | goto out; |
2787 | classzone_idx = zonelist_zone_idx(preferred_zoneref); | 2824 | classzone_idx = zonelist_zone_idx(preferred_zoneref); |
2788 | 2825 | ||
2789 | #ifdef CONFIG_CMA | ||
2790 | if (allocflags_to_migratetype(gfp_mask) == MIGRATE_MOVABLE) | ||
2791 | alloc_flags |= ALLOC_CMA; | ||
2792 | #endif | ||
2793 | /* First allocation attempt */ | 2826 | /* First allocation attempt */ |
2794 | page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, nodemask, order, | 2827 | page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, nodemask, order, |
2795 | zonelist, high_zoneidx, alloc_flags, | 2828 | zonelist, high_zoneidx, alloc_flags, |
@@ -3579,68 +3612,30 @@ static void build_zonelists_in_zone_order(pg_data_t *pgdat, int nr_nodes) | |||
3579 | zonelist->_zonerefs[pos].zone_idx = 0; | 3612 | zonelist->_zonerefs[pos].zone_idx = 0; |
3580 | } | 3613 | } |
3581 | 3614 | ||
3615 | #if defined(CONFIG_64BIT) | ||
3616 | /* | ||
3617 | * Devices that require DMA32/DMA are relatively rare and do not justify a | ||
3618 | * penalty to every machine in case the specialised case applies. Default | ||
3619 | * to Node-ordering on 64-bit NUMA machines | ||
3620 | */ | ||
3621 | static int default_zonelist_order(void) | ||
3622 | { | ||
3623 | return ZONELIST_ORDER_NODE; | ||
3624 | } | ||
3625 | #else | ||
3626 | /* | ||
3627 | * On 32-bit, the Normal zone needs to be preserved for allocations accessible | ||
3628 | * by the kernel. If processes running on node 0 deplete the low memory zone | ||
3629 | * then reclaim will occur more frequency increasing stalls and potentially | ||
3630 | * be easier to OOM if a large percentage of the zone is under writeback or | ||
3631 | * dirty. The problem is significantly worse if CONFIG_HIGHPTE is not set. | ||
3632 | * Hence, default to zone ordering on 32-bit. | ||
3633 | */ | ||
3582 | static int default_zonelist_order(void) | 3634 | static int default_zonelist_order(void) |
3583 | { | 3635 | { |
3584 | int nid, zone_type; | ||
3585 | unsigned long low_kmem_size, total_size; | ||
3586 | struct zone *z; | ||
3587 | int average_size; | ||
3588 | /* | ||
3589 | * ZONE_DMA and ZONE_DMA32 can be very small area in the system. | ||
3590 | * If they are really small and used heavily, the system can fall | ||
3591 | * into OOM very easily. | ||
3592 | * This function detect ZONE_DMA/DMA32 size and configures zone order. | ||
3593 | */ | ||
3594 | /* Is there ZONE_NORMAL ? (ex. ppc has only DMA zone..) */ | ||
3595 | low_kmem_size = 0; | ||
3596 | total_size = 0; | ||
3597 | for_each_online_node(nid) { | ||
3598 | for (zone_type = 0; zone_type < MAX_NR_ZONES; zone_type++) { | ||
3599 | z = &NODE_DATA(nid)->node_zones[zone_type]; | ||
3600 | if (populated_zone(z)) { | ||
3601 | if (zone_type < ZONE_NORMAL) | ||
3602 | low_kmem_size += z->managed_pages; | ||
3603 | total_size += z->managed_pages; | ||
3604 | } else if (zone_type == ZONE_NORMAL) { | ||
3605 | /* | ||
3606 | * If any node has only lowmem, then node order | ||
3607 | * is preferred to allow kernel allocations | ||
3608 | * locally; otherwise, they can easily infringe | ||
3609 | * on other nodes when there is an abundance of | ||
3610 | * lowmem available to allocate from. | ||
3611 | */ | ||
3612 | return ZONELIST_ORDER_NODE; | ||
3613 | } | ||
3614 | } | ||
3615 | } | ||
3616 | if (!low_kmem_size || /* there are no DMA area. */ | ||
3617 | low_kmem_size > total_size/2) /* DMA/DMA32 is big. */ | ||
3618 | return ZONELIST_ORDER_NODE; | ||
3619 | /* | ||
3620 | * look into each node's config. | ||
3621 | * If there is a node whose DMA/DMA32 memory is very big area on | ||
3622 | * local memory, NODE_ORDER may be suitable. | ||
3623 | */ | ||
3624 | average_size = total_size / | ||
3625 | (nodes_weight(node_states[N_MEMORY]) + 1); | ||
3626 | for_each_online_node(nid) { | ||
3627 | low_kmem_size = 0; | ||
3628 | total_size = 0; | ||
3629 | for (zone_type = 0; zone_type < MAX_NR_ZONES; zone_type++) { | ||
3630 | z = &NODE_DATA(nid)->node_zones[zone_type]; | ||
3631 | if (populated_zone(z)) { | ||
3632 | if (zone_type < ZONE_NORMAL) | ||
3633 | low_kmem_size += z->present_pages; | ||
3634 | total_size += z->present_pages; | ||
3635 | } | ||
3636 | } | ||
3637 | if (low_kmem_size && | ||
3638 | total_size > average_size && /* ignore small node */ | ||
3639 | low_kmem_size > total_size * 70/100) | ||
3640 | return ZONELIST_ORDER_NODE; | ||
3641 | } | ||
3642 | return ZONELIST_ORDER_ZONE; | 3636 | return ZONELIST_ORDER_ZONE; |
3643 | } | 3637 | } |
3638 | #endif /* CONFIG_64BIT */ | ||
3644 | 3639 | ||
3645 | static void set_zonelist_order(void) | 3640 | static void set_zonelist_order(void) |
3646 | { | 3641 | { |
@@ -4976,6 +4971,8 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size, | |||
4976 | pgdat->node_start_pfn = node_start_pfn; | 4971 | pgdat->node_start_pfn = node_start_pfn; |
4977 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP | 4972 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP |
4978 | get_pfn_range_for_nid(nid, &start_pfn, &end_pfn); | 4973 | get_pfn_range_for_nid(nid, &start_pfn, &end_pfn); |
4974 | printk(KERN_INFO "Initmem setup node %d [mem %#010Lx-%#010Lx]\n", nid, | ||
4975 | (u64) start_pfn << PAGE_SHIFT, (u64) (end_pfn << PAGE_SHIFT) - 1); | ||
4979 | #endif | 4976 | #endif |
4980 | calculate_node_totalpages(pgdat, start_pfn, end_pfn, | 4977 | calculate_node_totalpages(pgdat, start_pfn, end_pfn, |
4981 | zones_size, zholes_size); | 4978 | zones_size, zholes_size); |
@@ -5701,9 +5698,8 @@ static void __setup_per_zone_wmarks(void) | |||
5701 | zone->watermark[WMARK_HIGH] = min_wmark_pages(zone) + (tmp >> 1); | 5698 | zone->watermark[WMARK_HIGH] = min_wmark_pages(zone) + (tmp >> 1); |
5702 | 5699 | ||
5703 | __mod_zone_page_state(zone, NR_ALLOC_BATCH, | 5700 | __mod_zone_page_state(zone, NR_ALLOC_BATCH, |
5704 | high_wmark_pages(zone) - | 5701 | high_wmark_pages(zone) - low_wmark_pages(zone) - |
5705 | low_wmark_pages(zone) - | 5702 | atomic_long_read(&zone->vm_stat[NR_ALLOC_BATCH])); |
5706 | zone_page_state(zone, NR_ALLOC_BATCH)); | ||
5707 | 5703 | ||
5708 | setup_zone_migrate_reserve(zone); | 5704 | setup_zone_migrate_reserve(zone); |
5709 | spin_unlock_irqrestore(&zone->lock, flags); | 5705 | spin_unlock_irqrestore(&zone->lock, flags); |
@@ -6278,8 +6274,7 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, | |||
6278 | 6274 | ||
6279 | if (list_empty(&cc->migratepages)) { | 6275 | if (list_empty(&cc->migratepages)) { |
6280 | cc->nr_migratepages = 0; | 6276 | cc->nr_migratepages = 0; |
6281 | pfn = isolate_migratepages_range(cc->zone, cc, | 6277 | pfn = isolate_migratepages_range(cc, pfn, end); |
6282 | pfn, end, true); | ||
6283 | if (!pfn) { | 6278 | if (!pfn) { |
6284 | ret = -EINTR; | 6279 | ret = -EINTR; |
6285 | break; | 6280 | break; |
@@ -6555,97 +6550,3 @@ bool is_free_buddy_page(struct page *page) | |||
6555 | return order < MAX_ORDER; | 6550 | return order < MAX_ORDER; |
6556 | } | 6551 | } |
6557 | #endif | 6552 | #endif |
6558 | |||
6559 | static const struct trace_print_flags pageflag_names[] = { | ||
6560 | {1UL << PG_locked, "locked" }, | ||
6561 | {1UL << PG_error, "error" }, | ||
6562 | {1UL << PG_referenced, "referenced" }, | ||
6563 | {1UL << PG_uptodate, "uptodate" }, | ||
6564 | {1UL << PG_dirty, "dirty" }, | ||
6565 | {1UL << PG_lru, "lru" }, | ||
6566 | {1UL << PG_active, "active" }, | ||
6567 | {1UL << PG_slab, "slab" }, | ||
6568 | {1UL << PG_owner_priv_1, "owner_priv_1" }, | ||
6569 | {1UL << PG_arch_1, "arch_1" }, | ||
6570 | {1UL << PG_reserved, "reserved" }, | ||
6571 | {1UL << PG_private, "private" }, | ||
6572 | {1UL << PG_private_2, "private_2" }, | ||
6573 | {1UL << PG_writeback, "writeback" }, | ||
6574 | #ifdef CONFIG_PAGEFLAGS_EXTENDED | ||
6575 | {1UL << PG_head, "head" }, | ||
6576 | {1UL << PG_tail, "tail" }, | ||
6577 | #else | ||
6578 | {1UL << PG_compound, "compound" }, | ||
6579 | #endif | ||
6580 | {1UL << PG_swapcache, "swapcache" }, | ||
6581 | {1UL << PG_mappedtodisk, "mappedtodisk" }, | ||
6582 | {1UL << PG_reclaim, "reclaim" }, | ||
6583 | {1UL << PG_swapbacked, "swapbacked" }, | ||
6584 | {1UL << PG_unevictable, "unevictable" }, | ||
6585 | #ifdef CONFIG_MMU | ||
6586 | {1UL << PG_mlocked, "mlocked" }, | ||
6587 | #endif | ||
6588 | #ifdef CONFIG_ARCH_USES_PG_UNCACHED | ||
6589 | {1UL << PG_uncached, "uncached" }, | ||
6590 | #endif | ||
6591 | #ifdef CONFIG_MEMORY_FAILURE | ||
6592 | {1UL << PG_hwpoison, "hwpoison" }, | ||
6593 | #endif | ||
6594 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
6595 | {1UL << PG_compound_lock, "compound_lock" }, | ||
6596 | #endif | ||
6597 | }; | ||
6598 | |||
6599 | static void dump_page_flags(unsigned long flags) | ||
6600 | { | ||
6601 | const char *delim = ""; | ||
6602 | unsigned long mask; | ||
6603 | int i; | ||
6604 | |||
6605 | BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS); | ||
6606 | |||
6607 | printk(KERN_ALERT "page flags: %#lx(", flags); | ||
6608 | |||
6609 | /* remove zone id */ | ||
6610 | flags &= (1UL << NR_PAGEFLAGS) - 1; | ||
6611 | |||
6612 | for (i = 0; i < ARRAY_SIZE(pageflag_names) && flags; i++) { | ||
6613 | |||
6614 | mask = pageflag_names[i].mask; | ||
6615 | if ((flags & mask) != mask) | ||
6616 | continue; | ||
6617 | |||
6618 | flags &= ~mask; | ||
6619 | printk("%s%s", delim, pageflag_names[i].name); | ||
6620 | delim = "|"; | ||
6621 | } | ||
6622 | |||
6623 | /* check for left over flags */ | ||
6624 | if (flags) | ||
6625 | printk("%s%#lx", delim, flags); | ||
6626 | |||
6627 | printk(")\n"); | ||
6628 | } | ||
6629 | |||
6630 | void dump_page_badflags(struct page *page, const char *reason, | ||
6631 | unsigned long badflags) | ||
6632 | { | ||
6633 | printk(KERN_ALERT | ||
6634 | "page:%p count:%d mapcount:%d mapping:%p index:%#lx\n", | ||
6635 | page, atomic_read(&page->_count), page_mapcount(page), | ||
6636 | page->mapping, page->index); | ||
6637 | dump_page_flags(page->flags); | ||
6638 | if (reason) | ||
6639 | pr_alert("page dumped because: %s\n", reason); | ||
6640 | if (page->flags & badflags) { | ||
6641 | pr_alert("bad because of flags:\n"); | ||
6642 | dump_page_flags(page->flags & badflags); | ||
6643 | } | ||
6644 | mem_cgroup_print_bad_page(page); | ||
6645 | } | ||
6646 | |||
6647 | void dump_page(struct page *page, const char *reason) | ||
6648 | { | ||
6649 | dump_page_badflags(page, reason, 0); | ||
6650 | } | ||
6651 | EXPORT_SYMBOL(dump_page); | ||