mm, compaction: defer each zone individually instead of preferred zone
[linux-2.6-block.git] / mm / vmscan.c
index 2836b5373b2e7623a1143a98bf3997fa11865731..1a71b8b1ea3490d1f225a2f6ebb48db361825584 100644 (file)
@@ -2315,7 +2315,10 @@ static bool shrink_zone(struct zone *zone, struct scan_control *sc)
        return reclaimable;
 }
 
-/* Returns true if compaction should go ahead for a high-order request */
+/*
+ * Returns true if compaction should go ahead for a high-order request, or
+ * the high-order allocation would succeed without compaction.
+ */
 static inline bool compaction_ready(struct zone *zone, int order)
 {
        unsigned long balance_gap, watermark;
@@ -2339,8 +2342,11 @@ static inline bool compaction_ready(struct zone *zone, int order)
        if (compaction_deferred(zone, order))
                return watermark_ok;
 
-       /* If compaction is not ready to start, keep reclaiming */
-       if (!compaction_suitable(zone, order))
+       /*
+        * If compaction is not ready to start and allocation is not likely
+        * to succeed without it, then keep reclaiming.
+        */
+       if (compaction_suitable(zone, order) == COMPACT_SKIPPED)
                return false;
 
        return watermark_ok;
@@ -2818,7 +2824,7 @@ static bool zone_balanced(struct zone *zone, int order,
                return false;
 
        if (IS_ENABLED(CONFIG_COMPACTION) && order &&
-           !compaction_suitable(zone, order))
+           compaction_suitable(zone, order) == COMPACT_SKIPPED)
                return false;
 
        return true;