Skip to content

Make RamDiscardManager work with multiple sources & virtio-mem

Marc-André Lureau kvm qemu-devel qemu-rust 5 versions – Applied

Status from this message: I queued patch 1-11, will send a pull this week. Thanks for all the

Get series with b4
b4 am [email protected] change-id 20260414-rdm5-b6df2366d603

Versions newest first

  1. v5 Latest12 patches 15 repliesApplied
  2. v413 patches 28 repliesSuperseded inferred link
  3. v315 patches 26 repliesSuperseded inferred link
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v214 patches2 repliesSuperseded inferred link
v110 patches9 repliesSuperseded

Changes in v5 from the cover letter

- explain why InterfaceClass in rust binding is not needed after moving RamDiscardSource
- drop extraneous added blank line
- replaced a runtime "if (has_rdm)"" with an assert()
- dropped "RFC: hw/virtio: start virtio-mem guest_memfd regions as shared", in favour of start-private memory approach from "[RFC PATCH 0/6] Support virtio-mem memory hotplug in TDX guests" [1]
- demote "monitor: add 'info ramblock-attributes'" as RFC
- rebased and collected trailers

Patches in v5 Applied

#Subject and filesSizeRepliesApplied
1/12system/memory: split RamDiscardManager into source and managerhw/virtio/virtio-mem.c include/hw/virtio/virtio-mem.h include/system/memory.h +3 more+385 -3691 reply
2/12system/memory: move RamDiscardManager to separate compilation unitMAINTAINERS include/system/memory.h include/system/ram-discard-manager.h +4 more+542 -5011 reply
3/12system/memory: constify section argumentshw/vfio/cpr-legacy.c hw/vfio/listener.c hw/virtio/virtio-mem.c +7 more+35 -353 replies
4/12system/ram-discard-manager: implement replay via is_populated iterationsystem/ram-discard-manager.c+61 -241 reply
5/12virtio-mem: remove replay_populated/replay_discarded implementationhw/virtio/virtio-mem.c+0 -1120 replies
6/12system/ram-discard-manager: drop replay from source interfaceinclude/system/ram-discard-manager.h system/ram-block-attributes.c+10 -1720 replies
7/12system/memory: implement RamDiscardManager multi-source aggregationhw/virtio/virtio-mem.c include/system/memory.h include/system/ram-discard-manager.h +3 more+518 -850 replies
8/12system/physmem: destroy ram block attributes before RCU-deferred reclaimsystem/physmem.c+1 -10 replies
9/12system/memory: add RamDiscardManager reference counting and cleanupsystem/memory.c system/ram-discard-manager.c+13 -30 replies
10/12tests: add unit tests for RamDiscardManager multi-source aggregationMAINTAINERS tests/unit/meson.build tests/unit/test-ram-discard-manager-stubs.c +1 more+1292 -10 replies
11/12system/physmem: make ram_block_discard_range() handle guest_memfdaccel/kvm/kvm-all.c include/system/ramblock.h system/physmem.c +2 more+26 -80 replies
12/12RFC: monitor: add 'info ramblock-attributes' commandhmp-commands-info.hx hw/core/machine-hmp-cmds.c include/monitor/hmp.h +2 more+173 -03 replies

Reviews trailers per patch

11 of 12 patches have a Reviewed-by or Acked-by.

PatchPeter XuDavid HildenbrandCédric Le GoaterXiaoyao LiDr. David Alan GilbertMaciej S. SzmigieroPhilippe Mathieu-Daudé
1/12R-b A-b R-b
2/12R-b A-b R-b
3/12R-b A-b R-b A-b R-b
4/12R-b A-b
5/12R-b A-b
6/12R-b A-b
7/12R-b
8/12R-b
9/12R-b
10/12
11/12R-b R-b
12/12A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 7 reviewers.

Read the v5 thread

Cover letter [PATCH v5 00/12] Make RamDiscardManager work with multiple sources & virtio-mem

Hi,

This is an attempt to fix the incompatibility of virtio-mem with confidential VMs. The solution implements what was discussed earlier with D. Hildenbrand:
https://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/#3502238

The first patches are misc cleanups. Then some code refactoring to have split a manager/source. And finally, the manager learns to deal with multiple sources.

This has been tested together with the Linux kernel series from Zhenzhong Duan [1] for TDX guests.

(help fix https://issues.redhat.com/browse/RHEL-131968)

v5:
- explain why InterfaceClass in rust binding is not needed after moving RamDiscardSource
- drop extraneous added blank line
- replaced a runtime "if (has_rdm)"" with an assert()
- dropped "RFC: hw/virtio: start virtio-mem guest_memfd regions as shared", in favour of start-private memory approach from "[RFC PATCH 0/6] Support virtio-mem memory hotplug in TDX guests" [1]
- demote "monitor: add 'info ramblock-attributes'" as RFC
- rebased and collected trailers

v4:
- added "system/physmem: make ram_block_discard_range() handle guest_memfd"
- added "monitor: add 'info ramblock-attributes' command"
- added "RFC: hw/virtio: start virtio-mem guest_memfd regions as shared"
- skip calling source in notify_populate (it may not have updated its internal state)
- rebased, collected trailer tags

v3: issues found by Cédric
- fix assertion error on shutdown, due to rcu-defer cleanup
- fix API doc warnings

v2:
- drop replay_{populated,discarded} from source, suggested by Peter Xu
- add extra manager cleanup
- add r-b tags for preliminary patches

- Link to v4: https://lore.kernel.org/qemu-devel/[email protected]

[1]: https://lore.kernel.org/lkml/[email protected]/

---
Marc-André Lureau (12):
system/memory: split RamDiscardManager into source and manager system/memory: move RamDiscardManager to separate compilation unit system/memory: constify section arguments system/ram-discard-manager: implement replay via is_populated iteration
virtio-mem: remove replay_populated/replay_discarded implementation system/ram-discard-manager: drop replay from source interface system/memory: implement RamDiscardManager multi-source aggregation system/physmem: destroy ram block attributes before RCU-deferred reclaim system/memory: add RamDiscardManager reference counting and cleanup
tests: add unit tests for RamDiscardManager multi-source aggregation system/physmem: make ram_block_discard_range() handle guest_memfd
RFC: monitor: add 'info ramblock-attributes' command

 MAINTAINERS                                 |    4 +
 qapi/machine.json                           |   56 ++
 include/hw/vfio/vfio-container.h            |    2 +-
 include/hw/vfio/vfio-cpr.h                  |    2 +-
 include/hw/virtio/virtio-mem.h              |    3 -
 include/monitor/hmp.h                       |    1 +
 include/system/memory.h                     |  279 +-----
 include/system/ram-discard-manager.h        |  358 ++++++++
 include/system/ramblock.h                   |    5 +-
 accel/kvm/kvm-all.c                         |    2 +-
 hw/core/machine-hmp-cmds.c                  |   32 +
 hw/vfio/cpr-legacy.c                        |    4 +-
 hw/vfio/listener.c                          |   10 +-
 hw/virtio/virtio-mem.c                      |  259 +-----
 migration/ram.c                             |    6 +-
 system/memory.c                             |   88 +-
 system/memory_mapping.c                     |    4 +-
 system/physmem.c                            |   27 +-
 system/ram-block-attributes.c               |  328 +++----
 system/ram-discard-manager.c                |  612 +++++++++++++
 target/i386/kvm/tdx.c                       |    2 +-
 tests/unit/test-ram-discard-manager-stubs.c |   48 ++
 tests/unit/test-ram-discard-manager.c       | 1235 +++++++++++++++++++++++++++
 hmp-commands-info.hx                        |   13 +
 rust/bindings/system-sys/lib.rs             |    2 +-
 system/meson.build                          |    1 +
 system/trace-events                         |    2 +-
 tests/unit/meson.build                      |    8 +-
 28 files changed, 2569 insertions(+), 824 deletions(-)

---
base-commit: 405c32d2b18a683ba36301351af75125d9afda08
change-id: 20260414-rdm5-b6df2366d603

Best regards,

Signature · 1 line
Marc-André Lureau <[email protected]>