Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Medium] mm: hardware A/D bits discarded for PUD folios in
  zap_huge_pud() [1]
--

commit a6bb79712598f2da7fdcc94c9b1b5f8b9aad8851
Author: Konstantin Khorenko <[email protected]>

mm/huge_memory: use folio_dup_file_rmap_pud() in copy_huge_pud()

This commit adds folio_dup_file_rmap_pud() to duplicate file rmap mapcounts
at the PUD level and uses it in copy_huge_pud() instead of
folio_add_file_rmap_pud().

> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index d0e19d9e6b651..13caf81cb51af 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -2100,7 +2100,7 @@ int copy_huge_pud(struct vm_area_struct *dst_vma, 
> struct vm_area_struct *src_vma
>                * TODO: once we support anonymous pages, use
>                * folio_try_dup_anon_rmap_*() and split if duplicating fails.
>                */
> -             folio_add_file_rmap_pud(folio, page, dst_vma);
> +             folio_dup_file_rmap_pud(folio, page, dst_vma);
>               add_mm_counter(dst_mm, mm_counter_file(folio), HPAGE_PUD_NR);
>       }

[Severity: Medium]
This problem wasn't introduced by this patch, but does zap_huge_pud()
discard hardware accessed and dirty bits on the PUD folio [1]?

mm/huge_memory.c:zap_huge_pud() {
        ...
        orig_pud = pudp_huge_get_and_clear_full(vma, addr, pud, tlb->fullmm);
        ...
        } else {
                ...
                page = pud_page(orig_pud);
                folio = page_folio(page);
                folio_remove_rmap_pud(folio, page, vma);
                add_mm_counter(tlb->mm, mm_counter_file(folio), -HPAGE_PUD_NR);
        ...
}

Unlike zap_huge_pmd(), which checks the cleared entry and calls
folio_mark_accessed() and folio_mark_dirty(), zap_huge_pud() removes the
PUD rmap without propagating the young and dirty bits from orig_pud to the
folio.  When unmapping a refcounted Device DAX PUD mapping, those hardware
A/D bits are lost, leaving the folio with stale access and dirty state.

[1] https://sashiko.dev/#/bug/linux-d2fca843-ce3d-48bf-9ef3-bf87872ea6ec

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/20261106-khorenko-vstor-151183-copy_huge_pud-dup-rmap-v1-1-cf8ee4faf...@virtuozzo.com?part=1

Reply via email to