From: Qinyun Tan <qinyuntan@linux.alibaba.com>
To: "Zhang, Rui" <rui.zhang@intel.com>, "lenb@kernel.org" <lenb@kernel.org>
Cc: "michael.hebenstreit@intel.com" <michael.hebenstreit@intel.com>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"xlpang@linux.alibaba.com" <xlpang@linux.alibaba.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] tools/power turbostat: Fix average format for CPU/core perf counters
Date: Mon, 30 Nov 2026 18:55:16 +0800 [thread overview]
Message-ID: <6b2e7e63-56a0-4bfe-a86c-67cbfd5f83b1@linux.alibaba.com> (raw)
In-Reply-To: <766176a7044fcb1886bf65b3a908c7f0a354fd6a.camel@intel.com>
On 11/27/26 1:53 PM, Zhang, Rui wrote:
> On Tue, 2026-11-24 at 11:27 +0800, Qinyun Tan wrote:
>> 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>
>
> Then what about the PMT counters?
>
> This is an interesting finding. It appears to reveal a broader
> inconsistency in RAW/AVERAGE handling across the regular, perf and PMT
> counter loops in delta_package(), delta_core() and delta_thread().
>
> Len,
> is there any intentional reason for FORMAT_AVERAGE perf or PMT counters
> to undergo subtraction? or we didnt assume they exist?
>
> If no source-specific handling is needed here, could we use a common
> macro for the preserve-versus-subtract operation? That would simplify
> these loops and keep their format handling consistent:
>
> #define UPDATE_COUNTER(ptr, i, member) \
> do { \
> if ((ptr)->format == FORMAT_RAW || \
> (ptr)->format == FORMAT_AVERAGE) \
> old->member[i] = new->member[i]; \
> else \
> old->member[i] = new->member[i] - old->member[i]; \
> } while (0)
>
> The callers would use UPDATE_COUNTER(mp, i, counter),
> UPDATE_COUNTER(pp, i, perf_counter) and UPDATE_COUNTER(ppmt, i,
> pmt_counter), retaining any counter-specific processing around them.
>
Hi Rui, Len,
Thanks for pointing this out. I checked the PMT path: dcd1c379b0f1 added "average" to parse_add_command_pmt(), but the PMT loops in delta_thread(), delta_core() and delta_package() still only preserve FORMAT_RAW.
pmt_read_counter() returns the current field value. This appears inconsistent with the intended meaning of "average", but I may be missing a PMT-specific reason.
Len, should FORMAT_AVERAGE preserve the latest reading for PMT as well? If so, I can extend the fix to cover these paths. We could also consolidate the preserve-versus-subtract logic as Rui suggested.
Thanks,
Qinyun Tan
> thanks,
> rui
>
next prev parent reply other threads:[~2026-11-30 10:55 UTC|newest]
Thread overview: 8+ 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 ` [PATCH 1/3] tools/power turbostat: Fix average format for CPU/core perf counters Qinyun Tan
2026-11-27 5:53 ` Zhang, Rui
2026-11-30 10:55 ` 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-27 5:54 ` Zhang, Rui
2026-11-24 3:27 ` [PATCH 3/3] tools/power turbostat: Fix --cpu summary description Qinyun Tan
2026-11-27 5:55 ` Zhang, Rui
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=6b2e7e63-56a0-4bfe-a86c-67cbfd5f83b1@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=rui.zhang@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