mm, compaction: terminate async compaction when rescheduling
[platform/adaptation/renesas_rcar/renesas_kernel.git] / mm / compaction.c
index 3c39e5b..4d38c85 100644 (file)
@@ -494,8 +494,13 @@ isolate_migratepages_range(struct zone *zone, struct compact_control *cc,
                        return 0;
        }
 
+       if (cond_resched()) {
+               /* Async terminates prematurely on need_resched() */
+               if (cc->mode == MIGRATE_ASYNC)
+                       return 0;
+       }
+
        /* Time to isolate some pages for migration */
-       cond_resched();
        for (; low_pfn < end_pfn; low_pfn++) {
                /* give a chance to irqs before checking need_resched() */
                if (locked && !(low_pfn % SWAP_CLUSTER_MAX)) {