qemu/stubs
David Hildenbrand a2335113ae memory-device,vhost: Support automatic decision on the number of memslots
We want to support memory devices that can automatically decide how many
memslots they will use. In the worst case, they have to use a single
memslot.

The target use cases are virtio-mem and the hyper-v balloon.

Let's calculate a reasonable limit such a memory device may use, and
instruct the device to make a decision based on that limit. Use a simple
heuristic that considers:
* A memslot soft-limit for all memory devices of 256; also, to not
  consume too many memslots -- which could harm performance.
* Actually still free and unreserved memslots
* The percentage of the remaining device memory region that memory device
  will occupy.

Further, while we properly check before plugging a memory device whether
there still is are free memslots, we have other memslot consumers (such as
boot memory, PCI BARs) that don't perform any checks and might dynamically
consume memslots without any prior reservation. So we might succeed in
plugging a memory device, but once we dynamically map a PCI BAR we would
be in trouble. Doing accounting / reservation / checks for all such
users is problematic (e.g., sometimes we might temporarily split boot
memory into two memslots, triggered by the BIOS).

We use the historic magic memslot number of 509 as orientation to when
supporting 256 memory devices -> memslots (leaving 253 for boot memory and
other devices) has been proven to work reliable. We'll fallback to
suggesting a single memslot if we don't have at least 509 total memslots.

Plugging vhost devices with less than 509 memslots available while we
have memory devices plugged that consume multiple memslots due to
automatic decisions can be problematic. Most configurations might just fail
due to "limit < used + reserved", however, it can also happen that these
memory devices would suddenly consume memslots that would actually be
required by other memslot consumers (boot, PCI BARs) later. Note that this
has always been sketchy with vhost devices that support only a small number
of memslots; but we don't want to make it any worse.So let's keep it simple
and simply reject plugging such vhost devices in such a configuration.

Eventually, all vhost devices that want to be fully compatible with such
memory devices should support a decent number of memslots (>= 509).

Message-ID: <20230926185738.277351-13-david@redhat.com>
Reviewed-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
2023-10-12 14:15:22 +02:00
..
bdrv-next-monitor-owned.c
blk-commit-all.c
blk-exp-close-all.c
blockdev-close-all-bdrv-states.c
change-state-handler.c
cmos.c
colo-compare.c configure: add --disable-colo-proxy option 2023-05-18 18:40:50 +02:00
colo.c stubs/colo.c: spelling 2023-08-07 13:52:59 +03:00
cpu-get-clock.c
cpu-synchronize-state.c
cpus-get-virtual-clock.c
dump.c
error-printf.c Move error_printf_unless_qmp() with monitor unit 2022-04-21 17:09:09 +04:00
fdset.c
fw_cfg.c
gdbstub.c gdbstub: Introduce GDBFeature structure 2023-10-11 08:46:33 +01:00
get-vm-name.c include: move qemu_get_vm_name() to sysemu.h 2022-04-06 14:31:43 +02:00
graph-lock.c async: Register/unregister aiocontext in graph lock list 2022-12-15 16:07:43 +01:00
icount.c replay: notify vCPU when BH is scheduled 2022-06-06 09:26:53 +02:00
io_uring.c
iothread-lock-block.c main-loop.h: introduce qemu_in_main_thread() 2022-03-04 18:18:15 +01:00
iothread-lock.c
is-daemonized.c
isa-bus.c
linux-aio.c
memory_device.c memory-device,vhost: Support automatic decision on the number of memslots 2023-10-12 14:15:22 +02:00
meson.build stubs: Rename qmp_memory_device.c to memory_device.c 2023-10-12 14:15:22 +02:00
migr-blocker.c
module-opts.c
monitor-core.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
monitor.c
pci-bus.c
physmem.c stubs: add qemu_ram_block_from_host() and qemu_ram_get_fd() 2022-10-26 14:56:42 -04:00
qdev.c qapi qdev qom: Elide redundant has_FOO in generated C 2022-12-14 20:05:07 +01:00
qemu-timer-notify-cb.c
qmp-command-available.c
qmp-quit.c
qtest.c
ram-block.c
ramfb.c
replay-tools.c chardev: src buffer const for write functions 2022-09-29 14:38:05 +04:00
replay.c replay: Extract core API to 'exec/replay-core.h' 2023-02-27 22:29:01 +01:00
runstate-check.c
semihost-all.c stubs: split semihosting_get_target from system only stubs 2023-03-07 20:44:09 +00:00
semihost.c * util/log: re-allow switching away from stderr log file 2023-10-09 10:11:18 -04:00
sysbus.c
target-get-monitor-def.c
target-monitor-defs.c
trace-control.c trace: remove code that depends on setting vcpu 2023-06-01 11:05:05 -04:00
usb-dev-stub.c
uuid.c
vfio-user-obj.c vfio-user: handle device interrupts 2022-06-15 16:43:42 +01:00
virtio-md-pci.c pc: Factor out (un)plug handling of virtio-md-pci devices 2023-07-12 09:27:27 +02:00
vm-stop.c
vmstate.c
win32-kbd-hook.c
xen-hw-stub.c include/hw/xen/xen: Rename xen_piix3_set_irq() to xen_intx_set_irq() 2023-06-07 15:07:10 +01:00