Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

John B. Wyatt IV and committed by
Shuah Khan
2314dca1 08a26a15

+6 -6
+6 -6
tools/power/cpupower/bindings/python/test_raw_pylibcpupower.py
··· 15 15 print(f"cstate count error: return code: {cpu_cstates_count}") 16 16 17 17 """ 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) 19 19 """ 20 20 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}") 25 21 26 22 match cstate_disabled: 27 23 case 0: 28 24 print(f"CPU state disabled") 29 25 case -1: 30 26 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") 31 31 case _: 32 - print(f"Not documented") 32 + print(f"Not documented: {cstate_disabled}") 33 33 34 34 35 35 # Pointer example