[PATCH 0/2] Support for Hyper-V's HvExtCallGetBootZeroedMemory()
Florian Schmidt <[email protected]>
| Newsgroups | gmane.comp.emulators.kvm.devel,gmane.comp.emulators.qemu |
|---|---|
| Message-ID | <[email protected]> |
This patch series implements two new Hyper-V hypercalls. The primary goal is to support "zeroed memory" enlightenment via HvExtCallGetBootZeroedMemory(). To do so, we also need to implement HvExtCallQueryCapabilities(). While HvExtCallQueryCapabilities() uses another bit in EBX on CPUID leaf 0x40000003, it then allows the guest to query for further "extended" hypercalls via the return value of that call. HvExtCallGetBootZeroedMemory() allows a Windows guest to enquire which areas of memory that were provided by the hypervisor are already zeroed out, meaning that there's no need for the guest to do so again. This has obvious performance benefits. To get a rough idea of the performance benefit, looking at a 4-core, 64GB Windows 11 guest, we can see that an otherwise idle guest takes a bit less than 90 seconds to finish zeroing and settle down from the time the qemu process is started. If we look at CPU usage for each vCPU task 90 seconds after starting, we get: 1559 498 1294 343 1451 314 4015 2729 Conversely, after enabling HvExtCallGetBootZeroedMemory(), CPU usage is reduced: 1583 458 1441 361 1279 312 1337 264 These are taken from the respective /proc/<pid>/task/<tid>/stat entries, denoting user and system time per "CPU X/KVM" task, in ticks. We can clearly see which to which vCPU fell the tasks of zeroing. It also has the benefit of not touching all pages at boot. This can be useful if, for example, the VM is started with a balloon target already set to overcommit memory on the host. In this case, we don't risk memory usage spikes on the host if the VM touches all memory before the balloon can catch up. Major changes since RFC v2: * integrated KVM ioctl (under review in parallel) into HvExtCallBootZeroedMemory handler. Florian Schmidt (2): Add HvExtCallQueryCapabilities Add HvExtCallGetBootZeroedMemory docs/system/i386/hyperv.rst | 14 +++ hw/hyperv/hyperv.c | 202 +++++++++++++++++++++++++++++++ include/hw/hyperv/hyperv-proto.h | 12 ++ include/hw/hyperv/hyperv.h | 13 ++ include/system/physmem.h | 8 ++ linux-headers/linux/kvm.h | 15 +++ system/memory.c | 7 +- system/physmem.c | 50 ++++++++ target/i386/cpu.c | 4 + target/i386/cpu.h | 2 + target/i386/kvm/hyperv-proto.h | 6 + target/i386/kvm/hyperv.c | 14 +++ target/i386/kvm/kvm.c | 91 ++++++++++++++ target/i386/kvm/kvm_i386.h | 2 + 14 files changed, 438 insertions(+), 2 deletions(-) -- 2.47.3