Re: [PATCH RFC v2 00/18] mm/virtio: skip redundant zeroing of host-zeroed reported pages

Gregory Price
2026-04-21T02:21:24Z

On Mon, Apr 20, 2026 at 08:51:13AM -0400, Michael S. Tsirkin wrote:
>
> When a guest reports free pages to the hypervisor via virtio-balloon's
> free page reporting, the host typically zeros those pages when reclaiming
> their backing memory (e.g., via MADV_DONTNEED on anonymous mappings).
> When the guest later reallocates those pages, the kernel zeros them
> again -- redundantly.
>

It took me a second to really wrap my head around what you were saying
here, but if i'm following correctly:

1) Guest steals a page, reports the free page to the host
2) Host returns that page to the buddy
3) Guest wants the page back -> vmexit, alloc()
a) host gets a page from the buddy via fault path
b) this memory is "user memory" so host zeroes the page
4) Guest repeats step 3, re-zeoring the page

So you're adding a step that does:

1) page_reporting_drain() in guest sets PG_zeroed if host_zeroes_pages=true
2) on allocation, if PG_zeroed is set, don't zero

In theory this seems ok. PG_zeroed being a buddy-only flag is nice.

In practice there are obvious concerns about an explicit flag that would
allow a kernel (in this case the guest) to skip zeroing a page destined
for userland mappings - but i'm also paranoid.

In concept this seems reasonable, in implementation I have concerns
about the pghint_t type being added. Will respond inline in David's
reply thread on that though where you already have notes.

~Gregory