]> xenbits.xensource.com Git - libvirt.git/commit
qemu: Substract isolcpus from all online affinity
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 22 Apr 2024 09:55:46 +0000 (11:55 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 6 May 2024 13:38:58 +0000 (15:38 +0200)
commitda95bcb6b2d9b04958e0f2603202801dd29debb8
tree8da0e61c84ebd25e779d4ffa7623fc7bbb87dbf0
parent3c948ef6990d49907d5789d3ae5942ffbe170a93
qemu: Substract isolcpus from all online affinity

When starting a domain and there's no vCPU/emulator pinning set,
we query the list of all online physical CPUs and set affinity of
the child process (which eventually becomes QEMU) to that list.
We can't assume libvirtd itself had affinity to all online CPUs
and since affinity of the child process is inherited, we should
fix it afterwards. But that's not necessarily correct. Users
might isolate some physical CPUs and we should avoid touching
them unless explicitly told so (i.e. vCPU/emulator pinning told
us so).

Therefore, when attempting to set affinity to all online CPUs
subtract the isolated ones.

Before this commit:

  root@localhost:~# cat /sys/devices/system/cpu/isolated
  19,21,23
  root@virtlab414:~# taskset -cp $(pgrep qemu)
  pid 14835's current affinity list: 0-23

After:

  root@virtlab414:~# taskset -cp $(pgrep qemu)
  pid 17153's current affinity list: 0-18,20,22

Resolves: https://issues.redhat.com/browse/RHEL-33082
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_process.c