On Sun Apr 26, 2026 at 5:48 PM EDT, Michael S. Tsirkin wrote: > When a guest reports free pages to the hypervisor via the page reporting > framework (used by virtio-balloon and hv_balloon), the host typically > zeros those pages when reclaiming their backing memory. However, when > those pages are later allocated in the guest, post_alloc_hook() > unconditionally zeros them again if __GFP_ZERO is set. This > double-zeroing is wasteful, especially for large pages. > > Avoid redundant zeroing: > > - Add a host_zeroes_pages flag to page_reporting_dev_info, allowing > drivers to declare that their host zeros reported pages on reclaim. > A static key (page_reporting_host_zeroes) gates the fast path. > > - Add PG_zeroed page flag (sharing PG_private bit) to mark pages > that have been zeroed by the host. Set it on reported pages during > allocation from the buddy in page_del_and_expand(). > > - Thread the zeroed bool through rmqueue -> prep_new_page -> > post_alloc_hook, where it skips redundant zeroing for __GFP_ZERO > allocations. > > No driver sets host_zeroes_pages yet; a follow-up patch to > virtio_balloon is needed to opt in. > > 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/page-flags.h | 9 +++++ > include/linux/page_reporting.h | 3 ++ > mm/compaction.c | 6 ++-- > mm/internal.h | 2 +- > mm/page_alloc.c | 66 +++++++++++++++++++++++----------- > mm/page_reporting.c | 14 +++++++- > mm/page_reporting.h | 12 +++++++ > 7 files changed, 87 insertions(+), 25 deletions(-) > > diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h > index f7a0e4af0c73..eef2499cba8b 100644 > --- a/include/linux/page-flags.h > +++ b/include/linux/page-flags.h > @@ -135,6 +135,8 @@ enum pageflags { > PG_swapcache = PG_owner_priv_1, /* Swap page: swp_entry_t in private */ > /* Some filesystems */ > PG_checked = PG_owner_priv_1, > + /* Page contents are known to be zero */ > + PG_zeroed = PG_private,
+willy, I was discussing with willy and David about removing PG_private and repurposing it to PG_folio to identify folios. IIUC, PG_zeroed is only set for PageBuddy, so it should not be an issue to set it for allocated pages for folio identification. Let me know if I get it wrong. Thanks. -- Best Regards, Yan, Zi

