linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: move rmap of mTHP upon CoW reuse
@ 2025-09-25  8:54 Dev Jain
  2025-09-25  9:16 ` David Hildenbrand
  2025-09-25  9:31 ` Kiryl Shutsemau
  0 siblings, 2 replies; 8+ messages in thread
From: Dev Jain @ 2025-09-25  8:54 UTC (permalink / raw)
  To: akpm, david
  Cc: lorenzo.stoakes, Liam.Howlett, vbabka, rppt, surenb, mhocko,
	linux-mm, linux-kernel, Dev Jain

At wp-fault time, when we find that a folio is exclusively mapped, we move
folio->mapping to the faulting VMA's anon_vma, so that rmap overhead
reduces. This is currently done for small folios (base pages) and
PMD-mapped THPs. Do this for mTHP too.

Signed-off-by: Dev Jain <dev.jain@arm.com>
---
mm-selftests pass.

 mm/memory.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mm/memory.c b/mm/memory.c
index 7e32eb79ba99..ec04d2cec6b1 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4014,6 +4014,11 @@ static bool __wp_can_reuse_large_anon_folio(struct folio *folio,
 	 * an additional folio reference and never ended up here.
 	 */
 	exclusive = true;
+
+	if (folio_trylock(folio)) {
+		folio_move_anon_rmap(folio, vma);
+		folio_unlock(folio);
+	}
 unlock:
 	folio_unlock_large_mapcount(folio);
 	return exclusive;
-- 
2.30.2



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-09-25 10:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-25  8:54 [PATCH] mm: move rmap of mTHP upon CoW reuse Dev Jain
2025-09-25  9:16 ` David Hildenbrand
2025-09-25 10:33   ` Dev Jain
2025-09-25 10:37     ` David Hildenbrand
2025-09-25 10:50       ` Dev Jain
2025-09-25 10:57         ` David Hildenbrand
2025-09-25  9:31 ` Kiryl Shutsemau
2025-09-25  9:33   ` David Hildenbrand

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