mm/page_alloc.c: fix never set ALLOC_NOFRAGMENT flag [Linux 5.1]

mm/page_alloc.c: fix never set ALLOC_NOFRAGMENT flag [Linux 5.1]

This Linux kernel change "mm/page_alloc.c: fix never set ALLOC_NOFRAGMENT flag" is included in the Linux 5.1 release. This change is authored by Andrey Ryabinin <aryabinin [at] virtuozzo.com> on Thu Apr 25 22:24:01 2019 -0700. The commit for this change in Linux stable tree is 8118b82 (patch).

mm/page_alloc.c: fix never set ALLOC_NOFRAGMENT flag

Commit 0a79cdad5eb2 ("mm: use alloc_flags to record if kswapd can wake")
removed setting of the ALLOC_NOFRAGMENT flag.  Bring it back.

The runtime effect is that ALLOC_NOFRAGMENT behaviour is restored so
that allocations are spread across local zones to avoid fragmentation
due to mixing pageblocks as long as possible.

Link: http://lkml.kernel.org/r/[email protected]
Fixes: 0a79cdad5eb2 ("mm: use alloc_flags to record if kswapd can wake")
Signed-off-by: Andrey Ryabinin <[email protected]>
Acked-by: Mel Gorman <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>

There are 6 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 mm/page_alloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9992ca7..c02cff1 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3436,7 +3436,7 @@ static bool zone_allows_reclaim(struct zone *local_zone, struct zone *zone)
        return alloc_flags;

    if (zone_idx(zone) != ZONE_NORMAL)
-       goto out;
+       return alloc_flags;

    /*
     * If ZONE_DMA32 exists, assume it is the one after ZONE_NORMAL and
@@ -3445,9 +3445,9 @@ static bool zone_allows_reclaim(struct zone *local_zone, struct zone *zone)
     */
    BUILD_BUG_ON(ZONE_NORMAL - ZONE_DMA32 != 1);
    if (nr_online_nodes > 1 && !populated_zone(--zone))
-       goto out;
+       return alloc_flags;

-out:
+   alloc_flags |= ALLOC_NOFRAGMENT;
 #endif /* CONFIG_ZONE_DMA32 */
    return alloc_flags;
 }

Leave a Reply

Your email address will not be published. Required fields are marked *