On Mon, May 04, 2026 at 04:30:17PM +0400, Marc-André Lureau wrote:
> Most callers of ram_block_discard_range() want to discard both the
> shared and guest_memfd backing. Only kvm_convert_memory() intentionally
> discards a single plane during private/shared conversions.
> 
> Rename the current implementation to ram_block_discard_shared_range()
> and make ram_block_discard_range() a composite that also discards
> guest_memfd when present (rb->guest_memfd >= 0). This ensures callers
> like virtio-mem, virtio-balloon, hv-balloon, migration.. reclaim
> private pages on discard.
> 
> Update kvm_convert_memory() to use the plane-specific
> ram_block_discard_shared_range() since it only needs to discard
> the shared backing when converting to private.
> 
> Likewise, after TDVF image copy, use ram_block_discard_shared_range().
> 
> Signed-off-by: Marc-AndrĂ© Lureau <[email protected]>

Reviewed-by: Peter Xu <[email protected]>

-- 
Peter Xu


Reply via email to