KVM/qemu selection of CPU threads for VM

Issues related to applications and software problems and general support
Post Reply
roychoar
Posts: 1
Joined: 2021/11/19 13:48:03

KVM/qemu selection of CPU threads for VM

Post by roychoar » 2021/11/19 13:59:30

Hello team:
I am using the libvirt library to define the resources of a VM that runs on top of qemu/KVM.

Basically, I ask this VM to work with 8 virtual CPUs: <vcpu placement='static'>8</vcpu>

As far as I understand, each vCPU in my VM, at runtime, is paired to one of the available "core threads" in my real Intel CPU.

I would have expected that each of my VM´s vCPU were associated to a different physical thread in the server, but after running the "virsh vcpuinfo <domain>" command, I noticed that different vCPUs of my VM share the same server thread, as the following piece of output shows:

[root@localhost ~]# virsh vcpuinfo activelogic
VCPU: 0
CPU: 0
...
...

VCPU: 3
CPU: 0

¿ Is this a normal scenario? I did not know that two different VM vCPUs can share a thread in the underlying hardware.

Any hints will be greatly appreciated
THANKS!!!!

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: KVM/qemu selection of CPU threads for VM

Post by TrevorH » 2021/11/19 14:52:46

Unless you pin the vcpu to a physical cpu then linux is free to run the thread on any physical cpu it thinks is best. Sometimes it makes the best decisions about where to schedule it - for example with yours, it may well have looked at it and figured that since the last thread that got dispatched ran on cpu 0, it might be better to run the next one there too so that the cache is ready primed with the relevant data.

If you want to pin a vcpu to a physical one (or ones) then look at virsh vcpupin.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Post Reply