]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
pm: cpupower: bindings: Improve disable c_state block
authorJohn B. Wyatt IV <jwyatt@redhat.com>
Mon, 30 Sep 2024 23:21:54 +0000 (19:21 -0400)
committerShuah Khan <skhan@linuxfoundation.org>
Wed, 2 Oct 2024 20:50:17 +0000 (14:50 -0600)
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>
tools/power/cpupower/bindings/python/test_raw_pylibcpupower.py

index 3d6f62b9556adf6388468a5c4da385c4eea8ecf2..bb2b26db8b1079817dbf1f85b7c149a455013448 100755 (executable)
@@ -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