linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: Fix do_swap_page when KSM is not involved
@ 2023-12-21 22:12 Matthew Wilcox (Oracle)
  0 siblings, 0 replies; only message in thread
From: Matthew Wilcox (Oracle) @ 2023-12-21 22:12 UTC (permalink / raw)
  To: Andrew Morton, linux-mm
  Cc: Matthew Wilcox (Oracle), David Hildenbrand, kernel test robot

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 --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
-- 
2.43.0



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-21 22:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-21 22:12 [PATCH] mm: Fix do_swap_page when KSM is not involved Matthew Wilcox (Oracle)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox