The patch titled Subject: mm: use alloc_flags to record if kswapd can wake has been added to the -mm tree. Its filename is mm-use-alloc_flags-to-record-if-kswapd-can-wake.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-use-alloc_flags-to-record-if-kswapd-can-wake.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-use-alloc_flags-to-record-if-kswapd-can-wake.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> Subject: mm: use alloc_flags to record if kswapd can wake This is a preparation patch that copies the GFP flag __GFP_KSWAPD_RECLAIM into alloc_flags. This is a preparation patch only that avoids having to pass gfp_mask through a long callchain in a future patch. Note that the setting in the fast path happens in alloc_flags_nofragment() and it may be claimed that this has nothing to do with ALLOC_NO_FRAGMENT. That's true in this patch but is not true later so it's done now for easier review to show where the flag needs to be recorded. No functional change. Link: http://lkml.kernel.org/r/20181123114528.28802-4-mgorman@xxxxxxxxxxxxxxxxxxx Signed-off-by: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> Cc: Andrea Arcangeli <aarcange@xxxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Cc: Zi Yan <zi.yan@xxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- --- a/mm/internal.h~mm-use-alloc_flags-to-record-if-kswapd-can-wake +++ a/mm/internal.h @@ -499,6 +499,7 @@ unsigned long reclaim_clean_pages_from_l #else #define ALLOC_NOFRAGMENT 0x0 #endif +#define ALLOC_KSWAPD 0x200 /* allow waking of kswapd */ enum ttu_flags; struct tlbflush_unmap_batch; --- a/mm/page_alloc.c~mm-use-alloc_flags-to-record-if-kswapd-can-wake +++ a/mm/page_alloc.c @@ -3402,10 +3402,15 @@ static bool zone_allows_reclaim(struct z * fragmentation between the Normal and DMA32 zones. */ static inline unsigned int -alloc_flags_nofragment(struct zone *zone) +alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask) { + unsigned int alloc_flags = 0; + + if (gfp_mask & __GFP_KSWAPD_RECLAIM) + alloc_flags |= ALLOC_KSWAPD; + if (zone_idx(zone) != ZONE_NORMAL) - return 0; + goto out; /* * If ZONE_DMA32 exists, assume it is the one after ZONE_NORMAL and @@ -3414,13 +3419,14 @@ alloc_flags_nofragment(struct zone *zone */ BUILD_BUG_ON(ZONE_NORMAL - ZONE_DMA32 != 1); if (nr_online_nodes > 1 && !populated_zone(--zone)) - return 0; + goto out; - return ALLOC_NOFRAGMENT; +out: + return alloc_flags; } #else static inline unsigned int -alloc_flags_nofragment(struct zone *zone) +alloc_flags_nofragment(struct zone *zone, gfp_t gfp_mask) { return 0; } @@ -4063,6 +4069,9 @@ gfp_to_alloc_flags(gfp_t gfp_mask) } else if (unlikely(rt_task(current)) && !in_interrupt()) alloc_flags |= ALLOC_HARDER; + if (gfp_mask & __GFP_KSWAPD_RECLAIM) + alloc_flags |= ALLOC_KSWAPD; + #ifdef CONFIG_CMA if (gfpflags_to_migratetype(gfp_mask) == MIGRATE_MOVABLE) alloc_flags |= ALLOC_CMA; @@ -4294,7 +4303,7 @@ retry_cpuset: if (!ac->preferred_zoneref->zone) goto nopage; - if (gfp_mask & __GFP_KSWAPD_RECLAIM) + if (alloc_flags & ALLOC_KSWAPD) wake_all_kswapds(order, gfp_mask, ac); /* @@ -4352,7 +4361,7 @@ retry_cpuset: retry: /* Ensure kswapd doesn't accidentally go to sleep as long as we loop */ - if (gfp_mask & __GFP_KSWAPD_RECLAIM) + if (alloc_flags & ALLOC_KSWAPD) wake_all_kswapds(order, gfp_mask, ac); reserve_flags = __gfp_pfmemalloc_flags(gfp_mask); @@ -4575,7 +4584,7 @@ __alloc_pages_nodemask(gfp_t gfp_mask, u * Forbid the first pass from falling back to types that fragment * memory until all local zones are considered. */ - alloc_flags |= alloc_flags_nofragment(ac.preferred_zoneref->zone); + alloc_flags |= alloc_flags_nofragment(ac.preferred_zoneref->zone, gfp_mask); /* First allocation attempt */ page = get_page_from_freelist(alloc_mask, order, alloc_flags, &ac); _ Patches currently in -mm which might be from mgorman@xxxxxxxxxxxxxxxxxxx are mm-page_alloc-spread-allocations-across-zones-before-introducing-fragmentation.patch mm-move-zone-watermark-accesses-behind-an-accessor.patch mm-use-alloc_flags-to-record-if-kswapd-can-wake.patch mm-reclaim-small-amounts-of-memory-when-an-external-fragmentation-event-occurs.patch mm-stall-movable-allocations-until-kswapd-progresses-during-serious-external-fragmentation-event.patch