pm: cpupower: bindings: improve test script
John B. Wyatt IV
maintainercover pm: cpupower: bindings: improve test script
Improve test_raw_pylibcpupower.py with some cleanup and catching more states. This includes confirming states have been disabled and a notice to use sudo.
John B. Wyatt IV (2):
pm: cpupower: bindings: Improve disable c_state block
pm: cpupower: bindings: Add test to confirm cpu state is disabled
.../bindings/python/test_raw_pylibcpupower.py | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-)
Signature · 1 line
2.46.2
John B. Wyatt IV
maintainerPATCH 1/2 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.
--- .../bindings/python/test_raw_pylibcpupower.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/power/cpupower/bindings/python/test_raw_pylibcpupower.py +6 -6
@@ -15,21 +15,21 @@ else: print(f"cstate count error: return code: {cpu_cstates_count}") """ -Disable cstate (will fail if the above is 0, ex: a virtual machine) +Disable cstate (will fail if the above returns is under 1, ex: a virtual machine) """ cstate_disabled = p.cpuidle_state_disable(0, 0, 1) -if cpu_cstates_count == 0: - print(f"CPU 0 has {cpu_cstates_count} c-states") -else: - print(f"cstate count error: return code: {cpu_cstates_count}") match cstate_disabled: case 0: print(f"CPU state disabled") case -1: print(f"Idlestate not available") + case -2: + print(f"Disabling is not supported by the kernel") + case -3: + print(f"No write access to disable/enable C-states: try using sudo") case _: - print(f"Not documented") + print(f"Not documented: {cstate_disabled}") # Pointer example
Signature · 1 line
2.46.2
John B. Wyatt IV
maintainerPATCH 2/2 pm: cpupower: bindings: Add test to confirm cpu state is disabled
In reply to John B. Wyatt IVAdd a simple test to confirm and print out the cpu state.
--- .../bindings/python/test_raw_pylibcpupower.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
tools/power/cpupower/bindings/python/test_raw_pylibcpupower.py +16 -0
@@ -31,6 +31,22 @@ match cstate_disabled: case _: print(f"Not documented: {cstate_disabled}") +""" +Test cstate is disabled +""" +is_cstate_disabled = p.cpuidle_is_state_disabled(0, 0) + +match is_cstate_disabled: + case 1: + print(f"CPU is disabled") + case 0: + print(f"CPU is enabled") + case -1: + print(f"Idlestate not available") + case -2: + print(f"Disabling is not supported by kernel") + case _: + print(f"Not documented: {is_cstate_disabled}") # Pointer example
Signature · 1 line
2.46.2
Shuah Khan
maintainerQuoted 11 lines · John B. Wyatt IV
Improve
test_raw_pylibcpupower.pywith some cleanup and catching more states. This includes confirming states have been disabled and a notice to use sudo.John B. Wyatt IV (2):
pm: cpupower: bindings: Improve disablec_stateblock
pm: cpupower: bindings: Add test to confirm cpu state is disabled.../bindings/python/test_raw_pylibcpupower.py | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-)
Applied these two patches to
https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux.git/log/?h=cpupower
They will be included in my next pull request to PM maintainer.
thanks,
-- Shuah