mm, compaction: remove redundant watermark check in compact_finished()
authorVlastimil Babka <vbabka@suse.cz>
Mon, 8 May 2017 22:54:33 +0000 (15:54 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 9 May 2017 00:15:09 +0000 (17:15 -0700)
When detecting whether compaction has succeeded in forming a high-order
page, __compact_finished() employs a watermark check, followed by an own
search for a suitable page in the freelists.  This is not ideal for two
reasons:

 - The watermark check also searches high-order freelists, but has a
   less strict criteria wrt fallback. It's therefore redundant and waste
   of cycles. This was different in the past when high-order watermark
   check attempted to apply reserves to high-order pages.

 - The watermark check might actually fail due to lack of order-0 pages.
   Compaction can't help with that, so there's no point in continuing
   because of that. It's possible that high-order page still exists and
   it terminates.

This patch therefore removes the watermark check.  This should save some
cycles and terminate compaction sooner in some cases.

Link: http://lkml.kernel.org/r/20170307131545.28577-3-vbabka@suse.cz
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Mel Gorman <mgorman@techsingularity.net>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/compaction.c

index 09c5282ebdd2812fbb758255194d9063cf5dcf97..01b1fb8f6f4778f82c2483b254fe2ee582c2c58f 100644 (file)
@@ -1280,7 +1280,6 @@ static enum compact_result __compact_finished(struct zone *zone, struct compact_
                            const int migratetype)
 {
        unsigned int order;
-       unsigned long watermark;
 
        if (cc->contended || fatal_signal_pending(current))
                return COMPACT_CONTENDED;
@@ -1308,13 +1307,6 @@ static enum compact_result __compact_finished(struct zone *zone, struct compact_
        if (is_via_compact_memory(cc->order))
                return COMPACT_CONTINUE;
 
-       /* Compaction run is not finished if the watermark is not met */
-       watermark = zone->watermark[cc->alloc_flags & ALLOC_WMARK_MASK];
-
-       if (!zone_watermark_ok(zone, cc->order, watermark, cc->classzone_idx,
-                                                       cc->alloc_flags))
-               return COMPACT_CONTINUE;
-
        /* Direct compactor: Is a suitable page free? */
        for (order = cc->order; order < MAX_ORDER; order++) {
                struct free_area *area = &zone->free_area[order];