mm: fix the NULL mapping case in __isolate_lru_page()
authorHugh Dickins <>
Fri, 1 Jun 2018 23:50:50 +0000 (16:50 -0700)
committerLinus Torvalds <>
Sat, 2 Jun 2018 16:33:47 +0000 (09:33 -0700)
George Boole would have noticed a slight error in 4.16 commit
69d763fc6d3a ("mm: pin address_space before dereferencing it while
isolating an LRU page").  Fix it, to match both the comment above it,
and the original behaviour.

Although anonymous pages are not marked PageDirty at first, we have an
old habit of calling SetPageDirty when a page is removed from swap
cache: so there's a category of ex-swap pages that are easily
migratable, but were inadvertently excluded from compaction's async
migration in 4.16.

Fixes: 69d763fc6d3a ("mm: pin address_space before dereferencing it while isolating an LRU page")
Signed-off-by: Hugh Dickins <>
Acked-by: Minchan Kim <>
Acked-by: Mel Gorman <>
Reported-by: Ivan Kalvachev <>
Cc: "Huang, Ying" <>
Cc: Jan Kara <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>

index 9b697323a88c980b1878e0af68f83b57aeb55c55..9270a4370d542bd9d266e7487b3c13b1c7713936 100644 (file)
@@ -1418,7 +1418,7 @@ int __isolate_lru_page(struct page *page, isolate_mode_t mode)
                                return ret;
                        mapping = page_mapping(page);
-                       migrate_dirty = mapping && mapping->a_ops->migratepage;
+                       migrate_dirty = !mapping || mapping->a_ops->migratepage;
                        if (!migrate_dirty)
                                return ret;