From: Qinyun Tan <qinyuntan@linux.alibaba.com>
To: lenb@kernel.org
Cc: michael.hebenstreit@intel.com, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org, xlpang@linux.alibaba.com,
Qinyun Tan <qinyuntan@linux.alibaba.com>
Subject: [PATCH 1/3] tools/power turbostat: Fix average format for CPU/core perf counters
Date: Tue, 24 Nov 2026 11:27:21 +0800 [thread overview]
Message-ID: <20261124032723.157254-2-qinyuntan@linux.alibaba.com> (raw)
In-Reply-To: <20261124032723.157254-1-qinyuntan@linux.alibaba.com>
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@linux.alibaba.com>
---
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
next prev parent reply other threads:[~2026-11-24 3:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 3:27 [PATCH 0/3] tools/power turbostat: Fix counter formats and CPU selection docs Qinyun Tan
2026-11-24 3:27 ` Qinyun Tan [this message]
2026-11-24 3:27 ` [PATCH 2/3] tools/power turbostat: Restore u32 truncation for raw counters Qinyun Tan
2026-11-24 3:27 ` [PATCH 3/3] tools/power turbostat: Fix --cpu summary description Qinyun Tan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261124032723.157254-2-qinyuntan@linux.alibaba.com \
--to=qinyuntan@linux.alibaba.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=michael.hebenstreit@intel.com \
--cc=xlpang@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®