mm: dump page when hitting a VM_BUG_ON using VM_BUG_ON_PAGE
[GitHub/exynos8895/android_kernel_samsung_universal8895.git] / mm / migrate.c
index 13bedcc4656b32805c36c5e6b56c55067d2c964b..4b3996eb7f0f8e3b5f46e94edf5ede8d1003f978 100644 (file)
@@ -71,29 +71,13 @@ int migrate_prep_local(void)
        return 0;
 }
 
-/*
- * Add isolated pages on the list back to the LRU under page lock
- * to avoid leaking evictable pages back onto unevictable list.
- */
-void putback_lru_pages(struct list_head *l)
-{
-       struct page *page;
-       struct page *page2;
-
-       list_for_each_entry_safe(page, page2, l, lru) {
-               list_del(&page->lru);
-               dec_zone_page_state(page, NR_ISOLATED_ANON +
-                               page_is_file_cache(page));
-                       putback_lru_page(page);
-       }
-}
-
 /*
  * Put previously isolated pages back onto the appropriate lists
  * from where they were once taken off for compaction/migration.
  *
- * This function shall be used instead of putback_lru_pages(),
- * whenever the isolated pageset has been built by isolate_migratepages_range()
+ * This function shall be used whenever the isolated pageset has been
+ * built from lru, balloon, hugetlbfs page. See isolate_migratepages_range()
+ * and isolate_huge_page().
  */
 void putback_movable_pages(struct list_head *l)
 {
@@ -515,7 +499,7 @@ void migrate_page_copy(struct page *newpage, struct page *page)
        if (PageUptodate(page))
                SetPageUptodate(newpage);
        if (TestClearPageActive(page)) {
-               VM_BUG_ON(PageUnevictable(page));
+               VM_BUG_ON_PAGE(PageUnevictable(page), page);
                SetPageActive(newpage);
        } else if (TestClearPageUnevictable(page))
                SetPageUnevictable(newpage);
@@ -568,14 +552,6 @@ void migrate_page_copy(struct page *newpage, struct page *page)
  *                    Migration functions
  ***********************************************************/
 
-/* Always fail migration. Used for mappings that are not movable */
-int fail_migrate_page(struct address_space *mapping,
-                       struct page *newpage, struct page *page)
-{
-       return -EIO;
-}
-EXPORT_SYMBOL(fail_migrate_page);
-
 /*
  * Common logic to directly migrate a single page suitable for
  * pages that do not use PagePrivate/PagePrivate2.
@@ -895,7 +871,7 @@ static int __unmap_and_move(struct page *page, struct page *newpage,
         * free the metadata, so the page can be freed.
         */
        if (!page->mapping) {
-               VM_BUG_ON(PageAnon(page));
+               VM_BUG_ON_PAGE(PageAnon(page), page);
                if (page_has_private(page)) {
                        try_to_free_buffers(page);
                        goto uncharge;
@@ -1642,7 +1618,7 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page)
 {
        int page_lru;
 
-       VM_BUG_ON(compound_order(page) && !PageTransHuge(page));
+       VM_BUG_ON_PAGE(compound_order(page) && !PageTransHuge(page), page);
 
        /* Avoid migrating to a node that is nearly full */
        if (!migrate_balanced_pgdat(pgdat, 1UL << compound_order(page)))
@@ -1725,7 +1701,12 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma,
        nr_remaining = migrate_pages(&migratepages, alloc_misplaced_dst_page,
                                     node, MIGRATE_ASYNC, MR_NUMA_MISPLACED);
        if (nr_remaining) {
-               putback_lru_pages(&migratepages);
+               if (!list_empty(&migratepages)) {
+                       list_del(&page->lru);
+                       dec_zone_page_state(page, NR_ISOLATED_ANON +
+                                       page_is_file_cache(page));
+                       putback_lru_page(page);
+               }
                isolated = 0;
        } else
                count_vm_numa_event(NUMA_PAGE_MIGRATE);