Skip to content

Commit 2314dca

Browse files
John B. Wyatt IVshuahkh
authored andcommitted
pm: cpupower: bindings: Improve disable c_state block
This commit fixes a bad comment, removes an unneeded code block, and catches a few more states that cpuidle_state_disable with the test script. Part of the motivation for this commit was I kept forgetting to use sudo. Signed-off-by: "John B. Wyatt IV" <jwyatt@redhat.com> Signed-off-by: "John B. Wyatt IV" <sageofredondo@gmail.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 08a26a1 commit 2314dca

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tools/power/cpupower/bindings/python/test_raw_pylibcpupower.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@
1515
print(f"cstate count error: return code: {cpu_cstates_count}")
1616

1717
"""
18-
Disable cstate (will fail if the above is 0, ex: a virtual machine)
18+
Disable cstate (will fail if the above returns is under 1, ex: a virtual machine)
1919
"""
2020
cstate_disabled = p.cpuidle_state_disable(0, 0, 1)
21-
if cpu_cstates_count == 0:
22-
print(f"CPU 0 has {cpu_cstates_count} c-states")
23-
else:
24-
print(f"cstate count error: return code: {cpu_cstates_count}")
2521

2622
match cstate_disabled:
2723
case 0:
2824
print(f"CPU state disabled")
2925
case -1:
3026
print(f"Idlestate not available")
27+
case -2:
28+
print(f"Disabling is not supported by the kernel")
29+
case -3:
30+
print(f"No write access to disable/enable C-states: try using sudo")
3131
case _:
32-
print(f"Not documented")
32+
print(f"Not documented: {cstate_disabled}")
3333

3434

3535
# Pointer example

0 commit comments

Comments
 (0)