Re: [PATCH RFC 3/9] mm: add __GFP_PREZEROED flag and folio_test_clear_prezeroed()

Michael S. Tsirkin
2026-04-13T22:06:22Z

On Mon, Apr 13, 2026 at 11:05:40AM +0200, David Hildenbrand (Arm) wrote:

...

> (2) Use a dedicated allocation interface for user pages in the buddy.
>
> I hate the whole user_alloc_needs_zeroing()+folio_zero_user() handling.
>
> It shouldn't exist. We should just be passing GFP_ZERO and let the buddy handle
> all that.
>
>
> For example, vma_alloc_folio() already gets passed the address in.
>
> Pass the address from vma_alloc_folio_noprof()->folio_alloc_noprof(), and let
> folio_alloc_noprof() use a buddy interface that can handle it.
>
> Imagine if we had a alloc_user_pages_noprof() that consumes an address. It could just
> do what folio_zero_user() does, and only if really required.
>
> The whole user_alloc_needs_zeroing() could go away and you could just handle the
> pre-zeroed optimization internally.

I looked at this a bit, and I think the issue is that the buddy
allocator doesn't do the arch-specific cache handling.
So allocating it is a fundamentally different thing from GFP_ZERO which
is "zero a kernel address range".

So I don't get how you want to do it.

>
> --
> Cheers,
>
> David