Re: [PATCH 18/21] fs/proc/task_mmu: don't clear VM_SOFTDIRTY on hugetlb VMAs
From: Muchun Song
Date: Wed Nov 25 2026 - 21:11:51 EST
> On Nov 26, 2026, at 06:33, David Hildenbrand (Arm) <david@xxxxxxxxxx> wrote:
>
> hugetlb does not support soft-dirty tracking: since commit f96f7a40874d
> ("mm/hugetlb: fix hugetlb not supporting softdirty tracking"),
> vma_wants_writenotify() ignores VM_SOFTDIRTY for hugetlb VMAs, and
> clear_refs never clears the soft-dirty bits of hugetlb entries.
>
> However, clear_refs still clears VM_SOFTDIRTY on hugetlb VMAs. With
> CONFIG_MEM_SOFT_DIRTY, a FOLL_FORCE write to a private hugetlb mapping
> without VM_WRITE can then loop in __get_user_pages() until the task is
> killed, with the mmap_lock held for reading:
>
> __get_user_pages()
> retry:
> follow_page_mask()
> follow_huge_pmd()
> can_follow_write_pmd()
> pmd_needs_soft_dirty_wp() is true
> returns NULL
> faultin_page()
> hugetlb_wp()
> set_huge_ptep_maybe_writable()
> no VM_WRITE: the entry stays as it is
> returns 0
> goto retry
>
> Let's fix it by not clearing VM_SOFTDIRTY on hugetlb VMAs, so we always
> treat hugetlb pages as soft-dirty.
>
> This has low urgency, as the loop can be killed.
>
> Fixes: 052ccfbcc6cd ("mm/hugetlb: support FOLL_FORCE|FOLL_WRITE")
> Cc: <stable@xxxxxxxxxxxxxxx>
> Reported-by: Chris Mason <mason@xxxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Reviewed-by: Muchun Song (ByteDance) <muchun.song@xxxxxxxxx>