Public bug reported:

When systemd’s CPUaffinity is used in Ubuntu 22.04 it does not get
applied if the LXD snap version <6.1 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@pc:~$ uvt-kvm ssh test
ssh: connect to host 192.168.122.188 port 22: Connection refused
alejandro@pc:~$ 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"

LXD from 6.1/stable 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

** Affects: lxd (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2086870

Title:
  Systemd’s CPU affinity not honored when LXD snap is installed in
  Ubuntu 22.04

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/lxd/+bug/2086870/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to