Subject: Re: [PATCH resend v6 15/30] mm: memfd: skip zeroing for zeroed hugetlb pool pages

From: Gregory Price <[email-masked]>
Date: Mon, 11 May 2026 12:39:18 -0400

On Mon, May 11, 2026 at 05:03:08AM -0400, Michael S. Tsirkin wrote:
> gather_surplus_pages() pre-allocates hugetlb pages into the pool
> during mmap.  Pass __GFP_ZERO so these pages are zeroed by the
> buddy allocator, and HPG_zeroed is set by alloc_surplus_hugetlb_folio.
> 
> Add bool *zeroed output to alloc_hugetlb_folio_reserve() so
> callers can check whether the pool page is known-zero.  memfd's
> memfd_alloc_folio() uses this to skip the explicit folio_zero_user()
> when the page is already zero.
> 
> This avoids redundant zeroing for memfd hugetlb pages that were
> pre-allocated into the pool and never mapped to userspace.
> 

Same thing here, seems more like what's actually wanted is to sink the
folio_user_zero stuff into hugetlb.c rather than make memfd.c request
for zeroing - and then have to check again anyway.

~Gregory