On 6/8/26 10:40, Michael S. Tsirkin wrote:
> When a balloon page marked PageZeroed is freed during migration,
> use put_page_zeroed() to propagate the zeroed hint to the buddy
> allocator. Previously the hint was silently lost via plain put_page().
> 
> No page has PageZeroed set yet; the next patch
> (VIRTIO_BALLOON_F_DEVICE_INIT_ON_INFLATE) will set it on
> pages the host has zeroed during inflate.
> Note: during balloon migration, the migration core holds an
> extra reference, so put_page_zeroed() will not be the final
> put. The zeroed hint is lost in that case, which is
> acceptable: it is a best-effort optimization.
> 
> Signed-off-by: Michael S. Tsirkin <[email protected]>
> Assisted-by: Claude:claude-opus-4-6
> ---
>  mm/balloon.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/balloon.c b/mm/balloon.c
> index 96a8f1e20bc6..6c9dd8ab0c5d 100644
> --- a/mm/balloon.c
> +++ b/mm/balloon.c
> @@ -324,7 +324,15 @@ static int balloon_page_migrate(struct page *newpage, 
> struct page *page,
>       balloon_page_finalize(page);
>       spin_unlock_irqrestore(&balloon_pages_lock, flags);
>  
> -     put_page(page);
> +     if (PageZeroed(page)) {
> +             /* Atomic to serialize with memory_failure's
> +              * TestSetPageHWPoison; not under zone->lock here.
> +              */
> +             ClearPageZeroed(page);
> +             put_page_zeroed(page);
> +     } else {
> +             put_page(page);
> +     }
>  
>       return 0;
>  }

I think I raised previously that this is best done later.

This patch set is currently trying to do too many things, and is on the larger
side. I think we should try to reduce it to the bare minimum and get some
agreement between maintainers on the core design.

-- 
Cheers,

David

Reply via email to