Merge tag 'usb-5.10-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
[linux-2.6-microblaze.git] / mm / compaction.c
index 6e0ee56..13cb7a9 100644 (file)
@@ -817,6 +817,10 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
         * delay for some time until fewer pages are isolated
         */
        while (unlikely(too_many_isolated(pgdat))) {
+               /* stop isolation if there are still pages not migrated */
+               if (cc->nr_migratepages)
+                       return 0;
+
                /* async migration should just abort */
                if (cc->mode == MIGRATE_ASYNC)
                        return 0;
@@ -1012,8 +1016,8 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
 
 isolate_success:
                list_add(&page->lru, &cc->migratepages);
-               cc->nr_migratepages++;
-               nr_isolated++;
+               cc->nr_migratepages += compound_nr(page);
+               nr_isolated += compound_nr(page);
 
                /*
                 * Avoid isolating too much unless this block is being
@@ -1021,7 +1025,7 @@ isolate_success:
                 * or a lock is contended. For contention, isolate quickly to
                 * potentially remove one source of contention.
                 */
-               if (cc->nr_migratepages == COMPACT_CLUSTER_MAX &&
+               if (cc->nr_migratepages >= COMPACT_CLUSTER_MAX &&
                    !cc->rescan && !cc->contended) {
                        ++low_pfn;
                        break;
@@ -1132,7 +1136,7 @@ isolate_migratepages_range(struct compact_control *cc, unsigned long start_pfn,
                if (!pfn)
                        break;
 
-               if (cc->nr_migratepages == COMPACT_CLUSTER_MAX)
+               if (cc->nr_migratepages >= COMPACT_CLUSTER_MAX)
                        break;
        }