mm/compaction: ignore block suitable after check large free page
authorYisheng Xie <xieyisheng1@huawei.com>
Wed, 3 May 2017 21:53:54 +0000 (14:53 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 3 May 2017 22:52:09 +0000 (15:52 -0700)
By reviewing code, I find that if the migrate target is a large free
page and we ignore suitable, it may splite large target free page into
smaller block which is not good for defrag.  So move the ignore block
suitable after check large free page.

As Vlastimil pointed out in RFC version that this patch is just based on
logical analyses which might be better for future-proofing the function
and it is most likely won't have any visible effect right now, for
direct compaction shouldn't have to be called if there's a
>=pageblock_order page already available.

Link: http://lkml.kernel.org/r/1489490743-5364-1-git-send-email-xieyisheng1@huawei.com
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Hanjun Guo <guohanjun@huawei.com>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/compaction.c

index 81e1eaa2a2cf1bea89767185e9cb9549f2139ca2..09c5282ebdd2812fbb758255194d9063cf5dcf97 100644 (file)
@@ -992,9 +992,6 @@ isolate_migratepages_range(struct compact_control *cc, unsigned long start_pfn,
 static bool suitable_migration_target(struct compact_control *cc,
                                                        struct page *page)
 {
-       if (cc->ignore_block_suitable)
-               return true;
-
        /* If the page is a large free page, then disallow migration */
        if (PageBuddy(page)) {
                /*
@@ -1006,6 +1003,9 @@ static bool suitable_migration_target(struct compact_control *cc,
                        return false;
        }
 
+       if (cc->ignore_block_suitable)
+               return true;
+
        /* If the block is MIGRATE_MOVABLE or MIGRATE_CMA, allow migration */
        if (migrate_async_suitable(get_pageblock_migratetype(page)))
                return true;