psutil icon indicating copy to clipboard operation
psutil copied to clipboard

[Linux] wrong cpu_count(logical=True) in systemd slice/cgroup

Open tudorapo opened this issue 4 years ago • 0 comments

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.

tudorapo avatar Oct 17 '21 21:10 tudorapo