psutil
psutil copied to clipboard
[Linux] wrong cpu_count(logical=True) in systemd slice/cgroup
Summary
Ubuntu 21.10 64bit psutil version: 5.8.0 Python 3.9.7 type: core?
Description
When using systemd slices to limit the OS to one core the cpu_count call gives the count of threads available in the slice/cgroup. Details:
Slice setup: cat /etc/systemd/system/system.slice /etc/systemd/system/user.slice [Slice] Slice=user.slice AllowedCPUs=2-11 [Slice] Slice=user.slice AllowedCPUs=2-11
Counting cpus in three different ways:
psutil.cpu_count(logical=False) 6 psutil.cpu_count(logical=True) 10 len(psutil.cpu_percent(percpu=True)) 12
This causes problems for at least one application, bpytop.