Skip to content

Fix QEMU crash during memory hotplug with vhost=on

Igor Mammedov qemu-devel 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest7 patches 16 repliesIn review
  2. v3 RFC8 patches 22 repliesSuperseded
  3. v2 RFC6 patches 18 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v1 RFC2 patches9 repliesSuperseded

Changes in v4 from the cover letter

* drop patch extending memory_region_subregion_add() with error argument
* and add memory_region_add_subregion_to_hva() API instead
* add madvise(DONTNEED) when returning range to HVA container

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7memory: get rid of memory_region_destructor_ram_from_ptr()exec.c include/exec/ram_addr.h memory.c+1 -260 replies
2/7memory: introduce MemoryRegion container with reserved HVA rangeexec.c include/exec/cpu-common.h include/exec/memory.h +1 more+143 -20 replies
3/7pc: reserve hotpluggable memory range with memory_region_init_hva_range()hw/i386/pc.c hw/mem/pc-dimm.c+3 -30 replies
4/7pc: fix QEMU crashing when more than ~50 memory hotpluggedhw/virtio/vhost.c include/hw/virtio/vhost.h+45 -39 replies
5/7exec: make sure that RAMBlock descriptor won't be leakedexec.c+5 -50 replies
6/7exec: add qemu_ram_unmap_hva() API for unmapping memory from HVA areaexec.c include/exec/cpu-common.h+13 -00 replies
7/7memory: add support for deleting HVA mapped MemoryRegionhw/mem/pc-dimm.c include/exec/memory.h memory.c+65 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [Qemu-devel] [PATCH v4 0/7] Fix QEMU crash during memory hotplug with vhost=on

Changelog:
v3->v4:
* drop patch extending memory_region_subregion_add() with error argument
* and add memory_region_add_subregion_to_hva() API instead
* add madvise(DONTNEED) when returning range to HVA container
v2->v3:
* fixed(work-arouned) unmapping issues,
now memory subsytem keeps track of HVA mapped regions and doesn't allow to map a new region
at address where previos has benn mapped until previous region is gone
* fixed offset calculations in memory_region_find_hva_range()

     in 2/8

* redone MemorySection folding into HVA range for VHOST, now compacted memory map is temporary and passed only to vhost backend and doesn't touch original memory map used by QEMU
v1->v2:
* take into account Paolo's review comments
* do not overload ram_addr
* ifdef linux specific code
* reseve HVA using API from exec.c instead of calling mmap() dircely from memory.c
* support unmapping of HVA remapped region

When more than ~50 pc-dimm devices are hotplugged with vhost enabled, QEMU will assert in vhost vhost_commit() due to backend refusing to accept too many memory ranges.

Series introduces Reserved HVA MemoryRegion container where to all hotplugged memory is remapped and passes the single container range to vhost instead of multiple memory ranges for each hotlugged pc-dimm device.

It's an alternative approach to increasing backend supported memory regions limit.

Tested it a bit more, so now
- migration from current master to patched version seems to work
- memory is returned to host after device_del+object_del sequence, but I can't bet if cgroups won't charge it.

git branch for testing:
https://github.com/imammedo/qemu/commits/vhost_one_hp_range_v4

Igor Mammedov (7):
memory: get rid of memory_region_destructor_ram_from_ptr()
memory: introduce MemoryRegion container with reserved HVA range
pc: reserve hotpluggable memory range with
memory_region_init_hva_range()
pc: fix QEMU crashing when more than ~50 memory hotplugged
exec: make sure that RAMBlock descriptor won't be leaked
exec: add qemu_ram_unmap_hva() API for unmapping memory from HVA area
memory: add support for deleting HVA mapped MemoryRegion

 exec.c                    |  71 +++++++++++++++++++----------
 hw/i386/pc.c              |   4 +-
 hw/mem/pc-dimm.c          |   6 ++-
 hw/virtio/vhost.c         |  47 ++++++++++++++++++--
 include/exec/cpu-common.h |   3 ++
 include/exec/memory.h     |  67 +++++++++++++++++++++++++++-
 include/exec/ram_addr.h   |   1 -
 include/hw/virtio/vhost.h |   1 +
 memory.c                  | 111 +++++++++++++++++++++++++++++++++++++++++++---
 9 files changed, 272 insertions(+), 39 deletions(-)
Signature · 1 line
1.8.3.1