From: Kairui Song The behavior of updating the folio's access info isn't consistent for huge mapping splitting or ordinary unmapping. The page table's young flag has to be translated into folio's access info. Right now it only checks and sets the folio's referenced flag, which isn't enough since folio flag updates on access have their own rules. Ordinary unmapping (zapping) calls folio_mark_accessed(), but only for a VMA with recency: vma_has_recency() is false for VM_SEQ_READ, VM_RAND_READ and FMODE_NOREUSE areas, where an access carries no recency info by definition, so a split must not promote such a folio either. So use folio_mark_accessed_vma() here too, like the zapping paths. Keep accounting the young PTE as a cache access, sticking to the current behavior. Tested-by: Zhao Zhenzhuo Reviewed-by: Kunwu Chan Tested-by: Andrew Morton Reviewed-by: Zi Yan Tested-by: Wang Lian (ByteDance) Tested-by: Tianyi Chen Signed-off-by: Kairui Song --- mm/huge_memory.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 7c535d3bc501..fc4ae1efed17 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3112,8 +3112,8 @@ static void __split_huge_pud_locked(struct vm_area_struct *vma, pud_t *pud, if (!folio_test_dirty(folio) && pud_dirty(old_pud)) folio_mark_dirty(folio); - if (!folio_test_referenced(folio) && pud_young(old_pud)) - folio_set_referenced(folio); + if (pud_young(old_pud)) + folio_mark_accessed_vma(folio, vma); folio_remove_rmap_pud(folio, page, vma); add_mm_counter(vma->vm_mm, mm_counter_file(folio), -HPAGE_PUD_NR); @@ -3235,8 +3235,8 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, folio = page_folio(page); if (!folio_test_dirty(folio) && pmd_dirty(old_pmd)) folio_mark_dirty(folio); - if (!folio_test_referenced(folio) && pmd_young(old_pmd)) - folio_set_referenced(folio); + if (pmd_young(old_pmd)) + folio_mark_accessed_vma(folio, vma); folio_remove_rmap_pmd(folio, page, vma); add_mm_counter(mm, mm_counter_file(folio), -HPAGE_PMD_NR); folio_put(folio); -- 2.56.1