Skip to contentSkip to conversation

mm: fix lazyfree BUG_ON check in try_to_unmap_one()

PATCH New [email protected] 1 participant 1 message May 3, 2017

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 22/102 mm: fix lazyfree BUG_ON check in try_to_unmap_one()

From: Minchan Kim <[email protected]>
Subject: mm: fix lazyfree BUG_ON check in try_to_unmap_one()

If a page is swapbacked, it means it should be in swapcache in try_to_unmap_one's path.

If a page is !swapbacked, it mean it shouldn't be in swapcache in try_to_unmap_one's path.

Check both two cases all at once and if it fails, warn and return SWAP_FAIL. Such bug never mean we should shut down the kernel.

[[email protected]: do not use VM_WARN_ON_ONCE as if condition[

---

 mm/rmap.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
mm/rmap.c renamed from mm/rmap.c~mm-fix-lazyfree-bug-on-check-in-try_to_unmap_one +6 -2
diff -puN mm/rmap.c~mm-fix-lazyfree-bug-on-check-in-try_to_unmap_one mm/rmap.c
@@ -1418,8 +1418,12 @@ static int try_to_unmap_one(struct page
 			 * Store the swap location in the pte.
 			 * See handle_pte_fault() ...
 			 */
-			VM_BUG_ON_PAGE(!PageSwapCache(page) && PageSwapBacked(page),
-				page);
+			if (unlikely(PageSwapBacked(page) != PageSwapCache(page))) {
+				WARN_ON_ONCE(1);
+				ret = SWAP_FAIL;
+				page_vma_mapped_walk_done(&pvmw);
+				break;
+			}
 
 			/* MADV_FREE page check */
 			if (!PageSwapBacked(page)) {

_