Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[linux] cpu_frequency() min,max from wrong processor on with systems with more than 9 processors #2023

Closed
johanhogberg opened this issue Nov 25, 2021 · 1 comment

Comments

@johanhogberg
Copy link

johanhogberg commented Nov 25, 2021

Summary

  • OS: Linux
  • Architecture: x86/64
  • Psutil version: 5.8.0
  • Python version: 3.7.4
  • Type: core

Description

I don't have a system with different min/max frequencies on the processors to show the problem, so I don't actually have a visible bug.
But looking at the code in psutils/_pslinux.py for cpu_freq() and doing the similar iteration on a server with 88 processors:

>> paths = sorted(glob.glob("/sys/devices/system/cpu/cpufreq/policy[0-9]*") or glob.glob("/sys/devices/system/cpu/cpu[0-9]*/cpufreq"))
>>> for i, p in enumerate(paths): print(i, p)
... 
0 /sys/devices/system/cpu/cpufreq/policy0
1 /sys/devices/system/cpu/cpufreq/policy1
2 /sys/devices/system/cpu/cpufreq/policy10
3 /sys/devices/system/cpu/cpufreq/policy11
4 /sys/devices/system/cpu/cpufreq/policy12
5 /sys/devices/system/cpu/cpufreq/policy13
6 /sys/devices/system/cpu/cpufreq/policy14
7 /sys/devices/system/cpu/cpufreq/policy15
8 /sys/devices/system/cpu/cpufreq/policy16
9 /sys/devices/system/cpu/cpufreq/policy17
10 /sys/devices/system/cpu/cpufreq/policy18
11 /sys/devices/system/cpu/cpufreq/policy19
12 /sys/devices/system/cpu/cpufreq/policy2
13 /sys/devices/system/cpu/cpufreq/policy20

The alphabetic sorting of the files looses correct cpu-order with more than 9 CPUs.
This means that [min, max] for cpu2 will be taken from cpu10, etc.

@giampaolo
Copy link
Owner

Interesting. I fixed this in a1ae994.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants