Skip to content

hw/arm/virt: Support for virtio-mem-pci

Gavin Shan qemu-arm qemu-devel 4 versions – Applied

Status from this message: Applied to target-arm.next, thanks.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest2 patches 1 replyApplied
  2. v32 patches 4 repliesSuperseded
  3. v22 patches 6 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v11 patch4 repliesSuperseded

Changes in v4 from the cover letter

* Improved comments in virt_virtio_md_pci_pre_plug() (Peter)

Patches in v4 Applied

#Subject and filesSizeRepliesApplied
1/2virtio-mem: Correct default THP size for ARM64hw/virtio/virtio-mem.c+20 -120 replies
2/2hw/arm/virt: Support for virtio-mem-pcihw/arm/Kconfig hw/arm/virt.c hw/virtio/virtio-mem.c+74 -10 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchJonathan CameronDavid Hildenbrand
1/2R-b R-b
2/2R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/2] hw/arm/virt: Support for virtio-mem-pci

This series supports virtio-mem-pci device, by simply following the implementation on x86. The exception is the block size is 512MB on ARM64 instead of 128MB on x86, compatible with the memory section size in linux guest.

The work was done by David Hildenbrand and then Jonathan Cameron. I'm taking the patch and putting more efforts, which is all about testing to me at current stage.

Testing
=======
The upstream linux kernel (v5.16.rc3) is used on host/guest during the testing. The guest kernel includes changes to enable virtio-mem driver, which is simply to enable CONFIG_VIRTIO_MEM on ARM64.

Mutiple combinations like page sizes on host/guest, memory backend device etc are covered in the testing. Besides, migration is also tested. The following command lines are used for VM or virtio-mem-pci device hot-add. It's notable that virtio-mem-pci device hot-remove isn't supported, similar to what we have on x86.

host.pgsize guest.pgsize backend hot-add hot-remove migration
---------------------------------------------------------------------

   4KB         4KB           normal     ok       ok          ok
                             THP        ok       ok          ok
                             hugeTLB    ok       ok          ok
   4KB         64KB          normal     ok       ok          ok
                             THP        ok       ok          ok
                             hugeTLB    ok       ok          ok
  64KB         4KB           normal     ok       ok          ok
                             THP        ok       ok          ok
                             hugeTLB    ok       ok          ok
  64KB         64KB          normal     ok       ok          ok
                             THP        ok       ok          ok
                             hugeTLB    ok       ok          ok

The command lines are used for VM. When hugeTLBfs is used, all memory backend objects are popuated on /dev/hugepages-2048kB or /dev/hugepages-524288kB, depending on the host page sizes.

  /home/gavin/sandbox/qemu.main/build/qemu-system-aarch64                       \
  -accel kvm -machine virt,gic-version=host                                     \
  -cpu host -smp 4,sockets=2,cores=2,threads=1                                  \
  -m 1024M,slots=16,maxmem=64G                                                  \
  -object memory-backend-ram,id=mem0,size=512M                                  \
  -object memory-backend-ram,id=mem1,size=512M                                  \
  -numa node,nodeid=0,cpus=0-1,memdev=mem0                                      \
  -numa node,nodeid=1,cpus=2-3,memdev=mem1                                      \
     :
  -kernel /home/gavin/sandbox/linux.guest/arch/arm64/boot/Image                 \
  -initrd /home/gavin/sandbox/images/rootfs.cpio.xz                             \
  -append earlycon=pl011,mmio,0x9000000                                         \
  -device pcie-root-port,bus=pcie.0,chassis=1,id=pcie.1                         \
  -device pcie-root-port,bus=pcie.0,chassis=2,id=pcie.2                         \
  -device pcie-root-port,bus=pcie.0,chassis=3,id=pcie.3                         \
  -object memory-backend-ram,id=vmem0,size=512M                                 \

-device virtio-mem-pci,id=vm0,bus=pcie.1,memdev=vmem0,node=0,requested-size=0 \
-object memory-backend-ram,id=vmem1,size=512M \
-device virtio-mem-pci,id=vm1,bus=pcie.2,memdev=vmem1,node=1,requested-size=0

Command lines used for memory hot-add and hot-remove:

(qemu) qom-set vm1 requested-size 512M
(qemu) qom-set vm1 requested-size 0
(qemu) qom-set vm1 requested-size 512M

Command lines used for virtio-mem-pci device hot-add:

(qemu) object_add memory-backend-ram,id=hp-mem1,size=512M (qemu) device_add virtio-mem-pci,id=hp-vm1,bus=pcie.3,memdev=hp-mem1,node=1 (qemu) qom-set hp-vm1 requested-size 512M
(qemu) qom-set hp-vm1 requested-size 0
(qemu) qom-set hp-vm1 requested-size 512M

Changelog
=========
v4:
* Improved comments in virt_virtio_md_pci_pre_plug() (Peter)
v3:

  * Reshuffle patches                                                   (David)
  * Suggested code refactoring for virtio_mem_default_thp_size()        (David)
  * Pick r-b from Jonathan and David                                    (Gavin)
v2:
  * Include David/Jonathan as co-developers in the commit log           (David)
  * Decrease VIRTIO_MEM_USABLE_EXTENT to 512MB on ARM64 in PATCH[1/2]   (David)
  * PATCH[2/2] is added to correct the THP sizes on ARM64               (David)

Gavin Shan (2):
virtio-mem: Correct default THP size for ARM64
hw/arm/virt: Support for virtio-mem-pci

 hw/arm/Kconfig         |  1 +
 hw/arm/virt.c          | 70 ++++++++++++++++++++++++++++++++++++++++++
 hw/virtio/virtio-mem.c | 36 ++++++++++++++--------
 3 files changed, 94 insertions(+), 13 deletions(-)
Signature · 1 line
2.23.0