linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] mm: huge_memory: add folio_mark_accessed() when zapping file THP
@ 2025-04-08 13:16 Baolin Wang
  2025-04-08 15:29 ` Zi Yan
  2025-04-10  8:14 ` Barry Song
  0 siblings, 2 replies; 16+ messages in thread
From: Baolin Wang @ 2025-04-08 13:16 UTC (permalink / raw)
  To: akpm
  Cc: willy, david, 21cnbao, ryan.roberts, ziy, baolin.wang, linux-mm,
	linux-kernel

When investigating performance issues during file folio unmap, I noticed some
behavioral differences in handling non-PMD-sized folios and PMD-sized folios.
For non-PMD-sized file folios, it will call folio_mark_accessed() to mark the
folio as having seen activity, but this is not done for PMD-sized folios.

This might not cause obvious issues, but a potential problem could be that,
it might lead to more frequent refaults of PMD-sized file folios under memory
pressure. Therefore, I am unsure whether the folio_mark_accessed() should be
added for PMD-sized file folios?

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 mm/huge_memory.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 6ac6d468af0d..b3ade7ac5bbf 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2262,6 +2262,10 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
 				zap_deposited_table(tlb->mm, pmd);
 			add_mm_counter(tlb->mm, mm_counter_file(folio),
 				       -HPAGE_PMD_NR);
+
+			if (flush_needed && pmd_young(orig_pmd) &&
+			    likely(vma_has_recency(vma)))
+				folio_mark_accessed(folio);
 		}
 
 		spin_unlock(ptl);
-- 
2.43.5



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

end of thread, other threads:[~2025-04-12  9:03 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-08 13:16 [RFC PATCH] mm: huge_memory: add folio_mark_accessed() when zapping file THP Baolin Wang
2025-04-08 15:29 ` Zi Yan
2025-04-08 16:02   ` Johannes Weiner
2025-04-08 16:12     ` Zi Yan
2025-04-09  0:52       ` Baolin Wang
2025-04-10  8:14 ` Barry Song
2025-04-10  9:05   ` Baolin Wang
2025-04-10 10:29     ` Barry Song
2025-04-10 15:13       ` Zi Yan
2025-04-10 21:56         ` Barry Song
2025-04-11  1:20           ` Baolin Wang
2025-04-11  2:32             ` Barry Song
2025-04-11  8:42             ` David Hildenbrand
2025-04-11 11:51               ` Barry Song
2025-04-11 14:44                 ` Zi Yan
2025-04-12  9:02                   ` Barry Song

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