Use vma_alloc_folio_hints() and check PGHINT_ZEROED to skip clear_user_highpage() when the page is already zeroed.
On x86, vma_alloc_zeroed_movable_folio is overridden by a macro that uses __GFP_ZERO directly, so this change has no effect there. Signed-off-by: Michael S. Tsirkin <[email protected]> Assisted-by: Claude:claude-opus-4-6 Assisted-by: cursor-agent:GPT-5.4-xhigh --- include/linux/highmem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/highmem.h b/include/linux/highmem.h index af03db851a1d..8bb67772c1cb 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -321,9 +321,11 @@ struct folio *vma_alloc_zeroed_movable_folio(struct vm_area_struct *vma, unsigned long vaddr) { struct folio *folio; + pghint_t hints; - folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, vaddr); - if (folio && user_alloc_needs_zeroing()) + folio = vma_alloc_folio_hints(GFP_HIGHUSER_MOVABLE, 0, vma, vaddr, + &hints); + if (folio && user_alloc_needs_zeroing() && !(hints & PGHINT_ZEROED)) clear_user_highpage(&folio->page, vaddr); return folio; -- MST

