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

[macOS] cpu_freq() fails on arm64 #2382

Open
giampaolo opened this issue Mar 15, 2024 · 6 comments
Open

[macOS] cpu_freq() fails on arm64 #2382

giampaolo opened this issue Mar 15, 2024 · 6 comments

Comments

@giampaolo
Copy link
Owner

We recently added a macOS build for arm64 and we get a failure:
https://github.com/giampaolo/psutil/actions/runs/8301314525/job/22721158479

2024-03-15T19:24:20.3697330Z ======================================================================
2024-03-15T19:24:20.3697970Z ERROR: psutil.tests.test_misc.TestMisc.test_serialization (name='cpu_freq')
2024-03-15T19:24:20.3698460Z ----------------------------------------------------------------------
2024-03-15T19:24:20.3698790Z Traceback (most recent call last):
2024-03-15T19:24:20.3708960Z   File "/Users/runner/work/psutil/psutil/psutil/tests/test_misc.py", line 292, in test_serialization
2024-03-15T19:24:20.3709580Z     ret = fun()
2024-03-15T19:24:20.3710550Z   File "/private/var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/cibw-run-m728_sh2/cp39-macosx_arm64/venv-test-arm64/lib/python3.9/site-packages/psutil/__init__.py", line 1913, in cpu_freq
2024-03-15T19:24:20.3711420Z     ret = _psplatform.cpu_freq()
2024-03-15T19:24:20.3712370Z   File "/private/var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/cibw-run-m728_sh2/cp39-macosx_arm64/venv-test-arm64/lib/python3.9/site-packages/psutil/_psosx.py", line 182, in cpu_freq
2024-03-15T19:24:20.3713240Z     curr, min_, max_ = cext.cpu_freq()
2024-03-15T19:24:20.3713680Z RuntimeError: 'pmgr' entry was not found in AppleARMIODevice service

Error originates from:

if (entry == 0) {
PyErr_Format(
PyExc_RuntimeError,
"'pmgr' entry was not found in AppleARMIODevice service"
);
goto error;
}
.

Change was introduced in #2222.

@snOm3ad: Any chance you can take a look?

@snOm3ad
Copy link
Contributor

snOm3ad commented Mar 15, 2024

I will check further! Will also look into #2354 at the same time.

@dbwiddis
Copy link
Contributor

I think this is a relic of the VM used by GitHub (and other CI providers) that don't include the pmgr info that on-metal hardware provides.

@snOm3ad
Copy link
Contributor

snOm3ad commented Mar 16, 2024

Yeah what Daniel has pointed out in #2222 (comment) is spot on as to why this is failing.

I just booted a VM to test this and when I tried to use powermetrics it reports the exact same error. I opened the IORegistryExplorer just for fun and indeed the pmgr property is not exposed:

image

@dbwiddis
Copy link
Contributor

I opened the IORegistryExplorer just for fun and indeed the pmgr property is not exposed:

Any way you can explore around and see if the "voltage-states5-sram" or "voltage-states1-sram" or any "voltage-states*-sram" value exists in any key?

@snOm3ad
Copy link
Contributor

snOm3ad commented Mar 17, 2024

Any way you can explore around and see if the "voltage-states5-sram" or "voltage-states1-sram" or any "voltage-states*-sram" value exists in any key?

ioreg -k 'voltage-states5-sram' -r is empty, so it's not looking very promising.

@dbwiddis
Copy link
Contributor

any "voltage-states" at all?

I'm not sure "CPU Frequency" has any meaning for a VM, anyway. And in most cases, CPU Frequency has changed by the time you read the results. I think the appropriate response here is to ignore the error and return either 0 or some sane default.

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

3 participants