[PATCH 1/3] tools/power turbostat: Fix average format for CPU/core perf counters
From: Qinyun Tan
Date: Mon Nov 23 2026 - 22:27:40 EST
Perf counters added with the average format report interval deltas at
CPU and core scope instead of the latest counter values. Their summary
rows consequently average the deltas rather than the counter values.
delta_thread() and delta_core() only preserve FORMAT_RAW perf counters.
FORMAT_AVERAGE falls through to subtraction before the summary is
calculated.
Preserve FORMAT_AVERAGE values in both perf counter loops, matching the
existing handling in delta_package() and the MSR counter loops.
Fixes: dcd1c379b0f1 ("tools/power turbostat: add format "average" for external attributes")
Signed-off-by: Qinyun Tan <qinyuntan@xxxxxxxxxxxxxxxxx>
---
tools/power/x86/turbostat/turbostat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 123078926131..4e7eba8d8752 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -3956,7 +3956,7 @@ void delta_core(struct core_data *new, struct core_data *old)
}
for (i = 0, pp = sys.perf_cp; pp; i++, pp = pp->next) {
- if (pp->format == FORMAT_RAW)
+ if (pp->format == FORMAT_RAW || pp->format == FORMAT_AVERAGE)
old->perf_counter[i] = new->perf_counter[i];
else
old->perf_counter[i] = new->perf_counter[i] - old->perf_counter[i];
@@ -4079,7 +4079,7 @@ int delta_thread(struct thread_data *new, struct thread_data *old, struct core_d
}
for (i = 0, pp = sys.perf_tp; pp; i++, pp = pp->next) {
- if (pp->format == FORMAT_RAW)
+ if (pp->format == FORMAT_RAW || pp->format == FORMAT_AVERAGE)
old->perf_counter[i] = new->perf_counter[i];
else
old->perf_counter[i] = new->perf_counter[i] - old->perf_counter[i];
--
2.55.0