Hi all,
Has anyone encountered an issue where if you’re using systemd’s CPUaffinity that does not get applied if the LXD snap is installed? See below:
# with lxd installed, affinity not honored
ubuntu@test:~$ grep -i affinity /etc/systemd/system.conf
CPUAffinity=0-1
ubuntu@test:~$ sudo taskset -cp 1
pid 1's current affinity list: 0-3
# reset affinity, no luck
ubuntu@test:~$ sudo systemctl daemon-reexec
ubuntu@test:~$ sudo taskset -cp 1
pid 1's current affinity list: 0-3
# reboot no luck
ubuntu@test:~$ sudo reboot
Connection to 192.168.122.188 closed by remote host.
Connection to 192.168.122.188 closed.
alejandro@alejandropc:~$ uvt-kvm ssh test
ssh: connect to host 192.168.122.188 port 22: Connection refused
alejandro@alejandropc:~$ uvt-kvm ssh test
ubuntu@test:~$ sudo taskset -cp 1
pid 1's current affinity list: 0-3
# remove lxd...voilá
ubuntu@test:~$ snap list
Name Version Rev Tracking Publisher Notes
core20 20240111 2182 latest/stable canonical✓ base
lxd 5.0.3-9a1d904 27428 5.0/stable/… canonical✓ -
snapd 2.61.2 21184 latest/stable canonical✓ snapd
ubuntu@test:~$ sudo snap remove lxd
lxd removed
ubuntu@test:~$ grep -i affinity /etc/systemd/system.conf
CPUAffinity=0-1
ubuntu@test:~$ sudo taskset -cp 1
pid 1's current affinity list: 0,1
Details of the test system I used (out-of-the-box Ubuntu Jammy cloud image deployed via uvtool
):
ubuntu@test:~$ uname -r
5.15.0-101-generic
ubuntu@test:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"
In fact, LXD 6.1 seems to have fixed this problem:
ubuntu@test:~$ sudo taskset -cp 1
pid 1's current affinity list: 0,1
ubuntu@test:~$ grep -i affinity /etc/systemd/system.conf
CPUAffinity=0-1
# trying 5.20
ubuntu@test:~$ sudo snap install lxd --channel 5.20/stable
lxd (5.20/stable) 5.20-f3dd836 from Canonical✓ installed
ubuntu@test:~$ sudo taskset -cp 1
pid 1's current affinity list: 0-3
# trying 5.21 LTS
ubuntu@test:~$ sudo snap refresh lxd --channel 5.21/stable
lxd (5.21/stable) 5.21.2-2f4ba6b from Canonical✓ refreshed
ubuntu@test:~$ sudo taskset -cp 1
pid 1's current affinity list: 0-3
# trying 6.1 .... works
ubuntu@test:~$ sudo snap refresh lxd --channel 6.1/stable
lxd (6.1/stable) 6.1-78a3d8f from Canonical✓ refreshed
ubuntu@test:~$ sudo taskset -cp 1
pid 1's current affinity list: 0,1