Re: [RFC PATCH 0/9] kvm: implement atomic memslot updates
From: David Hildenbrand
Date: Thu Sep 29 2022 - 12:01:15 EST
The main cases are:
- for the boot case, splitting and merging existing memslots. QEMU
likes to merge adjacent memory regions into a single memslot, so if
something goes from read-write to read-only it has to be split and vice
versa. I guess a "don't merge this memory region" flag would be the
less hideous way to solve it in userspace.
- however, there is also the case of resizing an existing memslot which
is what David would like to have for virtio-mem. This is not really
fixable because part of the appeal of virtio-mem is to have a single
huge memslot instead of many smaller ones, in order to reduce the
granularity of add/remove (David, correct me if I'm wrong).
Yes, the most important case I am working on in that regard is reducing
the memslot size/overhead when only exposing comparatively little memory
towards a VM using virtio-mem (say, a virtio-mem device that could grow
to 1 TiB, but we initially only expose 1 GiB to the VM).
One approach I prototyped in the past (where my RFC for atomic updates
came into play because I ran into this issue) to achieve that was
dynamically growing (and eventually shrinking) a single memslot on demand.
An alternative [1] uses multiple individual memslots, and exposes them
on demand. There, I have to make sure that QEMU won't merge adjacent
memslots into a bigger one -- because otherwise, we'd again need atomic
memslot updates again, which KVM, vhost-user, ... don't support. But in
the future, I think we want to have that: if there is no fragmentation,
we should only have a single large memslot and all memslot consumers
should be able to cope with atomic updates.
So in any case, I will have good use for atomic memslot updates. Just
like other hypervisors that (will) implement virtio-mem or something
comparable :)
[1] https://lore.kernel.org/all/20211013103330.26869-1-david@xxxxxxxxxx/T/#u
--
Thanks,
David / dhildenb