From: "David E. Box" <david.e.box@linux.intel.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Hans de Goede" <hansg@kernel.org>
Cc: "David E. Box" <david.e.box@linux.intel.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 08/12] tools/arch/x86/pmtctl: Add 'stat --hex'
Date: Sun, 22 Nov 2026 11:34:03 -0800 [thread overview]
Message-ID: <fa7f0b5492820de13d0816a1dbed23b2e7c7738f.1795374925.git.david.e.box@linux.intel.com> (raw)
In-Reply-To: <cover.1795374925.git.david.e.box@linux.intel.com>
Add --hex to 'stat' to print the sampled values in hexadecimal, which
is easier to read for fields that hold flags, IDs or packed data.
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
---
V2 changes:
- Split out of v1 14; no change in behavior.
tools/arch/x86/pmtctl/src/cmd_stat.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/tools/arch/x86/pmtctl/src/cmd_stat.c b/tools/arch/x86/pmtctl/src/cmd_stat.c
index 11a2ab1fa341..8377c2d1d194 100644
--- a/tools/arch/x86/pmtctl/src/cmd_stat.c
+++ b/tools/arch/x86/pmtctl/src/cmd_stat.c
@@ -50,6 +50,7 @@ enum {
OPT_STAT_DEVICE,
OPT_STAT_NO_HEADER,
OPT_STAT_VERTICAL,
+ OPT_STAT_HEX,
};
/* A value to sample on each device */
@@ -67,6 +68,7 @@ struct stat_opts {
uint32_t count; /* number of samples, 0 until interrupted */
bool no_header;
bool vertical;
+ bool hex;
};
/* The value of one request on one device */
@@ -127,6 +129,7 @@ static void stat_usage_full(FILE *out)
" -i, --interval <ms> Sampling interval (default 1000 ms).\n"
" -c, --count <N> Number of samples (default infinite).\n"
" --no-header Don't print the header.\n"
+ " --hex Output values in hex.\n"
" --vertical One line per value per sample: sample time_ms device\n"
" metric value. Required for more than one value.\n"
"\n"
@@ -204,6 +207,7 @@ static int stat_parse_options(struct stat_opts *opts, int argc, char **argv)
{ "count", required_argument, NULL, 'c' },
{ "no-header", no_argument, NULL, OPT_STAT_NO_HEADER },
{ "vertical", no_argument, NULL, OPT_STAT_VERTICAL },
+ { "hex", no_argument, NULL, OPT_STAT_HEX },
{}
};
int opt;
@@ -244,6 +248,9 @@ static int stat_parse_options(struct stat_opts *opts, int argc, char **argv)
case OPT_STAT_VERTICAL:
opts->vertical = true;
break;
+ case OPT_STAT_HEX:
+ opts->hex = true;
+ break;
default:
return -EINVAL;
}
@@ -419,7 +426,7 @@ static void print_column(const char *s, size_t width, bool right)
print_chars(' ', pad);
}
-static const char *format_value(const struct stat_cell *cell, char *buf, size_t len)
+static const char *format_value(const struct stat_cell *cell, bool hex, char *buf, size_t len)
{
if (!cell->present)
return STAT_VAL_ABSENT;
@@ -427,6 +434,11 @@ static const char *format_value(const struct stat_cell *cell, char *buf, size_t
if (!cell->valid)
return STAT_VAL_FAILED;
+ if (hex) {
+ snprintf(buf, len, "0x%" PRIx64, cell->value);
+ return buf;
+ }
+
snprintf(buf, len, "%" PRIu64, cell->value);
return buf;
@@ -505,7 +517,8 @@ static void print_sample(const struct stat_run *run, uint64_t sample, uint64_t t
for (size_t r = 0; r < run->opts.num_requests; r++) {
const char *value;
- value = format_value(&row->cells[r], value_buf, sizeof(value_buf));
+ value = format_value(&row->cells[r], run->opts.hex, value_buf,
+ sizeof(value_buf));
print_line_start(run, sample_buf, time_buf, row->dev->name);
if (run->opts.vertical) {
--
2.53.0
next prev parent reply other threads:[~2026-11-22 19:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 19:33 [PATCH v2 00/12] tools/arch/x86/pmtctl: Add Intel PMT command-line tool David E. Box
2026-11-22 19:33 ` [PATCH v2 01/12] tools/arch/x86/pmtctl: Add pmtctl skeleton David E. Box
2026-11-22 19:33 ` [PATCH v2 02/12] tools/arch/x86/pmtctl: Add PMT telemetry device discovery David E. Box
2026-11-22 19:33 ` [PATCH v2 03/12] tools/arch/x86/pmtctl: Add pmtxml2json conversion tool David E. Box
2026-11-22 19:33 ` [PATCH v2 04/12] tools/arch/x86/pmtctl: Add JSON metric definition loading David E. Box
2026-11-22 19:34 ` [PATCH v2 05/12] tools/arch/x86/pmtctl: Add 'list' command David E. Box
2026-11-22 19:34 ` [PATCH v2 06/12] tools/arch/x86/pmtctl: Add 'list --summary' David E. Box
2026-11-22 19:34 ` [PATCH v2 07/12] tools/arch/x86/pmtctl: Add 'stat' command David E. Box
2026-11-22 19:34 ` David E. Box [this message]
2026-11-22 19:34 ` [PATCH v2 09/12] tools/arch/x86/pmtctl: Add 'stat --raw' David E. Box
2026-11-22 19:34 ` [PATCH v2 10/12] tools/arch/x86/pmtctl: Add README David E. Box
2026-11-22 19:34 ` [PATCH v2 11/12] tools/arch/x86/pmtctl: Add man page David E. Box
2026-11-22 19:34 ` [PATCH v2 12/12] tools/arch/x86/pmtctl: Add MAINTAINERS entry David E. Box
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=fa7f0b5492820de13d0816a1dbed23b2e7c7738f.1795374925.git.david.e.box@linux.intel.com \
--to=david.e.box@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@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
all inboxes | Powered by JetHome®