mbox series

[RFC,0/2] vmrd: dynamic guest VM memory resizing daemon

Message ID cover.1690836010.git.quic_sudaraja@quicinc.com
Headers show
Series vmrd: dynamic guest VM memory resizing daemon | expand

Message

Sudarshan Rajagopalan Aug. 1, 2023, 8:47 p.m. UTC
VM Memory Resizing Daemon (vmrd)

Initial idea of dynamic memory resizing for guest VMs was discussed here
in this thread below as a RFC.
https://lore.kernel.org/linux-arm-kernel/1bf30145-22a5-cc46-e583-25053460b105@redhat.com/T/

Posting the source-code for this userspace daemon written in native C++ as RFC
on such an approach for resizing the VM. We will be merging this into Github or
CodeLinaro after gathering all the review comments. The userspace daemon
registers to Linux kernel's PSI mechanism and it should work on any systems
running Linux with CONFIG_PSI enabled.

This daemon adds memory to guest VM when demand for memory increases,
and tracks for memory pressure going down as the usecase ends and frees
memory to release memory back to host proactively. virtio-mem is used
as interface for adding/removing memory in the guest VM.
More details on the detail and implementation in patch commit text and
RFC discuss thread mentioned above.

PATCH 2 shows the vendor specific implementation by Qualcomm on the memory
plugin interfaces for adding/removing memory to VM by using modified virtio-mem
driver, which uses mem-buf driver for communication between the VMs.
More details on PATCH 2.
This vendor specific implementation is shown just as a reference and different
user/vendor can have their own implementation.

We also intend to make these memory plugin interfaces generic so that we have an
upstream-friendly mechanism for lending memory from the host to guest VMs.
This is still on the works and wanted to seek upstream community's inputs on how
we can achieve this. This way, vmrd can run on any guest running Linux with
CONFIG_PSI and virtio-mem enabled which will be agnostic to the underlying 
Hypervisor.

Qualcomm has been using this daemon into its guest VMs for memory resizing.
This has been currently tested with Gunyah Hypervisor and not on any other
Hypervisor. Currently, the guest VM memory is resized by expanding Movable zone
only, since virtio-mem uses memory hotplug and Movable zone guarantees memory
blocks to be isolated and offlined. Next incremental patches of this feature
will be shared soon where both Normal and Movable zone can be resized, thereby
increasing headroom for both DMA (unmovable) and userspace (movable) memory.

Sudarshan Rajagopalan (2):
  vmrd: dynamic guest VM memory resizing daemon
  vmrd: add implementation of memory plugin interfaces

 Makefile.am |   14 +
 vmrd.cpp    | 1259 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 1273 insertions(+)
 create mode 100644 Makefile.am
 create mode 100644 vmrd.cpp