diff mbox series

mm: Fix do_swap_page when KSM is not involved

Message ID 20231221221225.1502975-1-willy@infradead.org (mailing list archive)
State New
Headers show
Series mm: Fix do_swap_page when KSM is not involved | expand

Commit Message

Matthew Wilcox Dec. 21, 2023, 10:12 p.m. UTC
If we have a large folio in the swapcache and KSM declines to replace
the folio, we must not recalculate the page.

Suggested-by: David Hildenbrand <david@redhat.com>
Reported-by: kernel test robot <oliver.sang@intel.com>
Closes: https://lore.kernel.org/oe-lkp/202312192319.fa8f5709-oliver.sang@intel.com
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/memory.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/mm/memory.c b/mm/memory.c
index 6ca8a4518844..1e16f1b8b92d 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3952,7 +3952,8 @@  vm_fault_t do_swap_page(struct vm_fault *vmf)
 			folio = swapcache;
 			goto out_page;
 		}
-		page = folio_page(folio, 0);
+		if (folio != swapcache)
+			page = folio_page(folio, 0);
 
 		/*
 		 * If we want to map a page that's in the swapcache writable, we