diff mbox series

[14/15] tools/power turbostat: Ignore pkg_cstate_limit when it is not available

Message ID baac2f4c7f3b21bc3ba296f7aba1eebe6d4a5155.1715628187.git.len.brown@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Len Brown
Headers show
Series tools/power turbostat: version 2024.05.10 | expand

Commit Message

Len Brown May 13, 2024, 7:40 p.m. UTC
From: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>

When running in no-msr mode, the pkg_cstate_limit is not populated, thus
we use perf to determine if given pcstate counter is present on the
platform.

Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 0369df4f1078..b3a5a373ba02 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -7112,9 +7112,7 @@  void cstate_perf_init_(bool soft_c1)
 
 			const bool counter_needed = BIC_IS_ENABLED(cai->bic) ||
 			    (soft_c1 && (cai->flags & CSTATE_COUNTER_FLAG_SOFT_C1_DEPENDENCY));
-			const bool counter_supported =
-			    (platform->supported_cstates & cai->feature_mask) &&
-			    (pkg_cstate_limit >= cai->pkg_cstate_limit);
+			const bool counter_supported = (platform->supported_cstates & cai->feature_mask);
 
 			if (counter_needed && counter_supported) {
 				/* Use perf API for this counter */
@@ -7123,7 +7121,8 @@  void cstate_perf_init_(bool soft_c1)
 					cci->source[cai->rci_index] = CSTATE_SOURCE_PERF;
 
 					/* User MSR for this counter */
-				} else if (!no_msr && cai->msr && probe_msr(cpu, cai->msr) == 0) {
+				} else if (!no_msr && cai->msr && pkg_cstate_limit >= cai->pkg_cstate_limit
+					   && probe_msr(cpu, cai->msr) == 0) {
 					cci->source[cai->rci_index] = CSTATE_SOURCE_MSR;
 					cci->msr[cai->rci_index] = cai->msr;
 				}