On Tue, Apr 21, 2026 at 12:58:11PM +0200, David Hildenbrand (Arm) wrote: > On 4/20/26 14:50, Michael S. Tsirkin wrote: > > 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; > > > For others reading along, the variant on your other branch: > > diff --git a/include/linux/highmem.h b/include/linux/highmem.h > index af03db851a1d9..ffa683f64f1d1 100644 > --- a/include/linux/highmem.h > +++ b/include/linux/highmem.h > @@ -320,13 +320,8 @@ static inline > struct folio *vma_alloc_zeroed_movable_folio(struct vm_area_struct *vma, > unsigned long vaddr) > { > - struct folio *folio; > - > - folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, vaddr); > - if (folio && user_alloc_needs_zeroing()) > - clear_user_highpage(&folio->page, vaddr); > - > - return folio; > + return vma_alloc_folio(GFP_HIGHUSER_MOVABLE | __GFP_ZERO, > + 0, vma, vaddr); > } > #endif > > Looks like an extremely clean interface.
OK, sure. I will post that one as v3. Let me just add a changelog in the cover letter, and see what to do about balloon. > -- > Cheers, > > David

