]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - mm/compaction.c
mm/compaction: enhance compaction finish condition
[karo-tx-linux.git] / mm / compaction.c
index 8c0d9459b54a02042dd2caf9489566188d9ea908..a18201a8124e5d0443e8231f8600cb3e2976d55c 100644 (file)
@@ -1174,13 +1174,24 @@ static int __compact_finished(struct zone *zone, struct compact_control *cc,
        /* Direct compactor: Is a suitable page free? */
        for (order = cc->order; order < MAX_ORDER; order++) {
                struct free_area *area = &zone->free_area[order];
+               bool can_steal;
 
                /* Job done if page is free of the right migratetype */
                if (!list_empty(&area->free_list[migratetype]))
                        return COMPACT_PARTIAL;
 
-               /* Job done if allocation would set block type */
-               if (order >= pageblock_order && area->nr_free)
+#ifdef CONFIG_CMA
+               /* MIGRATE_MOVABLE can fallback on MIGRATE_CMA */
+               if (migratetype == MIGRATE_MOVABLE &&
+                       !list_empty(&area->free_list[MIGRATE_CMA]))
+                       return COMPACT_PARTIAL;
+#endif
+               /*
+                * Job done if allocation would steal freepages from
+                * other migratetype buddy lists.
+                */
+               if (find_suitable_fallback(area, order, migratetype,
+                                               true, &can_steal) != -1)
                        return COMPACT_PARTIAL;
        }