From: "Zhang, Rui" <rui.zhang@intel.com>
To: "linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"lenb@kernel.org" <lenb@kernel.org>
Cc: "Brown, Len" <len.brown@intel.com>
Subject: Re: [PATCH 2/2] tools/power turbostat: verify arguments to params --show and --hide
Date: Wed, 11 Jun 2025 02:02:29 +0000 [thread overview]
Message-ID: <51d8569871c88bbeb449268b74157c099245fa43.camel@intel.com> (raw)
In-Reply-To: <c07ce1369b8972c60993b86bfacaa77ceee3af3a.1749593891.git.len.brown@intel.com>
On Tue, 2025-06-10 at 18:18 -0400, Len Brown wrote:
> From: Len Brown <len.brown@intel.com>
>
> $ sudo turbostat --quiet --show junk
> turbostat: Counter 'junk' can not be added.
>
> Previously, invalid argumetns to --show and --hide were silently
> ignored
s/argumetns/arguments
otherwise, the patch LGTM.
Acked-by: Zhang Rui <rui.zhang@intel.com>
-rui
>
> Signed-off-by: Len Brown <len.brown@intel.com>
> ---
> tools/power/x86/turbostat/turbostat.c | 33 +++++++++++++++++++++++++--
> 1 file changed, 31 insertions(+), 2 deletions(-)
>
> diff --git a/tools/power/x86/turbostat/turbostat.c
> b/tools/power/x86/turbostat/turbostat.c
> index 33a54a9e0781..4056b7e26a0f 100644
> --- a/tools/power/x86/turbostat/turbostat.c
> +++ b/tools/power/x86/turbostat/turbostat.c
> @@ -2310,6 +2310,8 @@ char *deferred_add_names[MAX_DEFERRED];
> char *deferred_skip_names[MAX_DEFERRED];
> int deferred_add_index;
> int deferred_skip_index;
> +unsigned int deferred_add_consumed;
> +unsigned int deferred_skip_consumed;
>
> /*
> * HIDE_LIST - hide this list of counters, show the rest [default]
> @@ -10512,8 +10514,10 @@ int is_deferred_add(char *name)
> int i;
>
> for (i = 0; i < deferred_add_index; ++i)
> - if (!strcmp(name, deferred_add_names[i]))
> + if (!strcmp(name, deferred_add_names[i])) {
> + deferred_add_consumed |= (1 << i);
> return 1;
> + }
> return 0;
> }
>
> @@ -10522,11 +10526,34 @@ int is_deferred_skip(char *name)
> int i;
>
> for (i = 0; i < deferred_skip_index; ++i)
> - if (!strcmp(name, deferred_skip_names[i]))
> + if (!strcmp(name, deferred_skip_names[i])) {
> + deferred_skip_consumed |= (1 << i);
> return 1;
> + }
> return 0;
> }
>
> +void verify_deferred_consumed(void)
> +{
> + int i;
> + int fail = 0;
> +
> + for (i = 0; i < deferred_add_index; ++i) {
> + if (!(deferred_add_consumed & (1 << i))) {
> + warnx("Counter '%s' can not be added.",
> deferred_add_names[i]);
> + fail++;
> + }
> + }
> + for (i = 0; i < deferred_skip_index; ++i) {
> + if (!(deferred_skip_consumed & (1 << i))) {
> + warnx("Counter '%s' can not be skipped.",
> deferred_skip_names[i]);
> + fail++;
> + }
> + }
> + if (fail)
> + exit(-EINVAL);
> +}
> +
> void probe_cpuidle_residency(void)
> {
> char path[64];
> @@ -10885,6 +10912,8 @@ int main(int argc, char **argv)
> probe_cpuidle_residency();
> probe_cpuidle_counts();
>
> + verify_deferred_consumed();
> +
> if (!getuid())
> set_rlimit();
>
prev parent reply other threads:[~2025-06-11 2:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 22:18 [PATCH 1/2] tools/power turbostat: regression fix: --show C1E% Len Brown
2025-06-10 22:18 ` [PATCH 2/2] tools/power turbostat: verify arguments to params --show and --hide Len Brown
2025-06-11 2:02 ` Zhang, Rui [this message]
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=51d8569871c88bbeb449268b74157c099245fa43.camel@intel.com \
--to=rui.zhang@intel.com \
--cc=len.brown@intel.com \
--cc=lenb@kernel.org \
--cc=linux-pm@vger.kernel.org \
/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