I would like to ask, if it is possible to reserve cores just for particular VM's and prevent others to use them. Let me explain closer:
I'd like to have 2 virtual machines to be pinned to cores 0-7 and 16-23 and I want to prevent these cores to be used by system (kernel isolcpus, rcu_nocbs and systemd AllowedCPUs) and other VM's. I also don't care on what cores others VM's will be running, except they should not use cores 0-7 and 16-23. Also I don't want to pin them to any specific cores explicitly. I just want them to use any cores from 8-15 and 24-31.
Is there way how to achieve that?
Just to add.
I have 2 VM's with GPU passthrough pinned to "reserved" cores. I want to have these cores reserved just for these two VMs. I want to prevent kernel, systemd, other processes and also kvm-qemu to use these reserved cores (in case of qemu except those two gaming VMs of course). It seems that isolcpus rcu_nocbs and systemd AllowedCPUs works correctly, but libvirt (or qemu or both) just ignores these settings. Qemu correctly runs those two virtuals on (libvirt configured) pinned CPUs but any other machine which is not pinned explicitly can run on any core, even its isolated to kernel and not allowed for systemd.
1 Answer
Set "CPUAffinity" in /etc/systemd/system.conf to select which CPUs general host OS processes are allowed to use by default - ie the inverse of CPUs you want to reserve for dedicated VM usage. The kernel 'isolcpus' setting should not be used except if configuring KVM Real-Time, because it also turns of scheduling entirely on the CPUs, which is prevents non-VCPU QEMU threads from being balanced.
With systemd setting present VMs will launch on the non-reserved cores by default. You can then use CPU pinning config in libvirt for the two VMs you want to use the reserved cores.
2