diff options
author | David Rientjes <rientjes@google.com> | 2014-08-06 19:07:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-06 21:01:21 -0400 |
commit | 8fe780484d2674eec27e12bb29c07d3e98a7ad21 (patch) | |
tree | b7cefa9ab0a94bd3582b6c98ca0b3e0909a119c2 /mm | |
parent | e972a070e2d3296cd2e2cc2fd0561ce89a1d5ebf (diff) |
mm, thp: restructure thp avoidance of light synchronous migration
__GFP_NO_KSWAPD, once the way to determine if an allocation was for thp
or not, has gained more users. Their use is not necessarily wrong, they
are trying to do a memory allocation that can easily fail without
disturbing kswapd, so the bit has gained additional usecases.
This restructures the check to determine whether MIGRATE_SYNC_LIGHT
should be used for memory compaction in the page allocator. Rather than
testing solely for __GFP_NO_KSWAPD, test for all bits that must be set
for thp allocations.
This also moves the check to be done only after the page allocator is
aborted for deferred or contended memory compaction since setting
migration_mode for this case is pointless.
Signed-off-by: David Rientjes <rientjes@google.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rik van Riel <riel@redhat.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/page_alloc.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 578236089ec1..18cee0d4c8a2 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -2639,14 +2639,6 @@ rebalance: | |||
2639 | goto got_pg; | 2639 | goto got_pg; |
2640 | 2640 | ||
2641 | /* | 2641 | /* |
2642 | * It can become very expensive to allocate transparent hugepages at | ||
2643 | * fault, so use asynchronous memory compaction for THP unless it is | ||
2644 | * khugepaged trying to collapse. | ||
2645 | */ | ||
2646 | if (!(gfp_mask & __GFP_NO_KSWAPD) || (current->flags & PF_KTHREAD)) | ||
2647 | migration_mode = MIGRATE_SYNC_LIGHT; | ||
2648 | |||
2649 | /* | ||
2650 | * If compaction is deferred for high-order allocations, it is because | 2642 | * If compaction is deferred for high-order allocations, it is because |
2651 | * sync compaction recently failed. In this is the case and the caller | 2643 | * sync compaction recently failed. In this is the case and the caller |
2652 | * requested a movable allocation that does not heavily disrupt the | 2644 | * requested a movable allocation that does not heavily disrupt the |
@@ -2656,6 +2648,15 @@ rebalance: | |||
2656 | (gfp_mask & __GFP_NO_KSWAPD)) | 2648 | (gfp_mask & __GFP_NO_KSWAPD)) |
2657 | goto nopage; | 2649 | goto nopage; |
2658 | 2650 | ||
2651 | /* | ||
2652 | * It can become very expensive to allocate transparent hugepages at | ||
2653 | * fault, so use asynchronous memory compaction for THP unless it is | ||
2654 | * khugepaged trying to collapse. | ||
2655 | */ | ||
2656 | if ((gfp_mask & GFP_TRANSHUGE) != GFP_TRANSHUGE || | ||
2657 | (current->flags & PF_KTHREAD)) | ||
2658 | migration_mode = MIGRATE_SYNC_LIGHT; | ||
2659 | |||
2659 | /* Try direct reclaim and then allocating */ | 2660 | /* Try direct reclaim and then allocating */ |
2660 | page = __alloc_pages_direct_reclaim(gfp_mask, order, | 2661 | page = __alloc_pages_direct_reclaim(gfp_mask, order, |
2661 | zonelist, high_zoneidx, | 2662 | zonelist, high_zoneidx, |