Skip to content

Commit

Permalink
Linux: skip offline cpu cores in cpu_freq (#2376)
Browse files Browse the repository at this point in the history
Signed-off-by: shadeyg56 <[email protected]>
  • Loading branch information
shadeyg56 authored Feb 26, 2024
1 parent da0b7c6 commit 4cf56e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -821,3 +821,7 @@ I: 2222
N: Ryan Carsten Schmidt
W: https://github.com/ryandesign
I: 2361

N: Shade Gladden
W: https://github.com/shadeyg56
I: 2376
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
**Bug fixes**

- 2360_, [macOS]: can't compile on macOS < 10.13. (patch by Ryan Schmidt)
- 2254_, [Linux]: offline cpus raise NotImplementedError in cpu_freq() (patch by Shade Gladden)

5.9.8
=====
Expand Down
7 changes: 7 additions & 0 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,13 @@ def cpu_freq():
# https://github.com/giampaolo/psutil/issues/1071
curr = bcat(pjoin(path, "cpuinfo_cur_freq"), fallback=None)
if curr is None:
online_path = (
"/sys/devices/system/cpu/cpu{}/online".format(i)
)
# if cpu core is offline, set to all zeroes
if cat(online_path, fallback=None) == "0\n":
ret.append(_common.scpufreq(0.0, 0.0, 0.0))
continue
msg = "can't find current frequency file"
raise NotImplementedError(msg)
curr = int(curr) / 1000
Expand Down

0 comments on commit 4cf56e0

Please sign in to comment.