WIP: update tizen_qemu_defconfig
[platform/kernel/linux-starfive.git] / mm / compaction.c
index c51f7f5..8238e83 100644 (file)
@@ -985,28 +985,28 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
                }
 
                /*
+                * Be careful not to clear PageLRU until after we're
+                * sure the page is not being freed elsewhere -- the
+                * page release code relies on it.
+                */
+               if (unlikely(!get_page_unless_zero(page)))
+                       goto isolate_fail;
+
+               /*
                 * Migration will fail if an anonymous page is pinned in memory,
                 * so avoid taking lru_lock and isolating it unnecessarily in an
                 * admittedly racy check.
                 */
                mapping = page_mapping(page);
-               if (!mapping && page_count(page) > page_mapcount(page))
-                       goto isolate_fail;
+               if (!mapping && (page_count(page) - 1) > total_mapcount(page))
+                       goto isolate_fail_put;
 
                /*
                 * Only allow to migrate anonymous pages in GFP_NOFS context
                 * because those do not depend on fs locks.
                 */
                if (!(cc->gfp_mask & __GFP_FS) && mapping)
-                       goto isolate_fail;
-
-               /*
-                * Be careful not to clear PageLRU until after we're
-                * sure the page is not being freed elsewhere -- the
-                * page release code relies on it.
-                */
-               if (unlikely(!get_page_unless_zero(page)))
-                       goto isolate_fail;
+                       goto isolate_fail_put;
 
                /* Only take pages on LRU: a check now makes later tests safe */
                if (!PageLRU(page))
@@ -1344,7 +1344,7 @@ move_freelist_tail(struct list_head *freelist, struct page *freepage)
 }
 
 static void
-fast_isolate_around(struct compact_control *cc, unsigned long pfn, unsigned long nr_isolated)
+fast_isolate_around(struct compact_control *cc, unsigned long pfn)
 {
        unsigned long start_pfn, end_pfn;
        struct page *page;
@@ -1365,21 +1365,13 @@ fast_isolate_around(struct compact_control *cc, unsigned long pfn, unsigned long
        if (!page)
                return;
 
-       /* Scan before */
-       if (start_pfn != pfn) {
-               isolate_freepages_block(cc, &start_pfn, pfn, &cc->freepages, 1, false);
-               if (cc->nr_freepages >= cc->nr_migratepages)
-                       return;
-       }
-
-       /* Scan after */
-       start_pfn = pfn + nr_isolated;
-       if (start_pfn < end_pfn)
-               isolate_freepages_block(cc, &start_pfn, end_pfn, &cc->freepages, 1, false);
+       isolate_freepages_block(cc, &start_pfn, end_pfn, &cc->freepages, 1, false);
 
        /* Skip this pageblock in the future as it's full or nearly full */
        if (cc->nr_freepages < cc->nr_migratepages)
                set_pageblock_skip(page);
+
+       return;
 }
 
 /* Search orders in round-robin fashion */
@@ -1556,7 +1548,7 @@ fast_isolate_freepages(struct compact_control *cc)
                return cc->free_pfn;
 
        low_pfn = page_to_pfn(page);
-       fast_isolate_around(cc, low_pfn, nr_isolated);
+       fast_isolate_around(cc, low_pfn);
        return low_pfn;
 }
 
@@ -1847,6 +1839,7 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc)
                                        pfn = cc->zone->zone_start_pfn;
                                cc->fast_search_fail = 0;
                                found_block = true;
+                               set_pageblock_skip(freepage);
                                break;
                        }
                }