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 06/12] tools/arch/x86/pmtctl: Add 'list --summary'
Date: Sun, 22 Nov 2026 11:34:01 -0800 [thread overview]
Message-ID: <0f77cacbead1815624aa72ca6160012fd08010c6.1795374925.git.david.e.box@linux.intel.com> (raw)
In-Reply-To: <cover.1795374925.git.david.e.box@linux.intel.com>
Add the --summary mode to 'list', which shows the GUIDs of the PMT
telemetry devices on the system, each with its platform and description
when its definitions are available, and the devices that have it.
Unlike the metric listing it works without metric definitions, and like
it, it can be restricted with --guid and --device.
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
---
V2 changes:
- Replaces 'list --devices' from v1 13; v1's 'list --guids' is
dropped.
- Works without metric definitions (v1's failed without built-in
ones), is sorted, and honors --guid and --device.
tools/arch/x86/pmtctl/src/cmd_list.c | 40 +++++++++++++++++++++++++++-
tools/arch/x86/pmtctl/src/main.c | 2 +-
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/tools/arch/x86/pmtctl/src/cmd_list.c b/tools/arch/x86/pmtctl/src/cmd_list.c
index cefcb465969a..35a610909558 100644
--- a/tools/arch/x86/pmtctl/src/cmd_list.c
+++ b/tools/arch/x86/pmtctl/src/cmd_list.c
@@ -28,6 +28,9 @@
#define LIST_GROUP_DESC_INDENT 4
#define LIST_METRIC_DESC_INDENT 8
+/* Indent of a device name under its GUID group header */
+#define LIST_DEVICE_INDENT 6
+
/* Width limits of the line under a group header */
#define LIST_SEP_MIN ((size_t)8)
#define LIST_SEP_MAX ((size_t)100)
@@ -36,11 +39,13 @@
enum {
OPT_LIST_GUID = CHAR_MAX + 1,
OPT_LIST_DEVICE,
+ OPT_LIST_SUMMARY,
};
struct list_opts {
bool show_help;
struct pmt_device_filter filter;
+ bool summary;
};
static void list_usage(FILE *out)
@@ -53,7 +58,8 @@ static void list_usage(FILE *out)
"Options:\n"
" -h, --help Show this help.\n"
" --guid <hex> Restrict to devices with this GUID.\n"
- " --device <name> Restrict to one device, e.g. telem3.\n");
+ " --device <name> Restrict to one device, e.g. telem3.\n"
+ " --summary List GUIDs and their devices.\n");
}
static int parse_list_opts(struct list_opts *opts, int argc, char **argv)
@@ -62,6 +68,7 @@ static int parse_list_opts(struct list_opts *opts, int argc, char **argv)
{ "help", no_argument, NULL, 'h' },
{ "guid", required_argument, NULL, OPT_LIST_GUID },
{ "device", required_argument, NULL, OPT_LIST_DEVICE },
+ { "summary", no_argument, NULL, OPT_LIST_SUMMARY },
{}
};
int opt;
@@ -80,6 +87,9 @@ static int parse_list_opts(struct list_opts *opts, int argc, char **argv)
case OPT_LIST_DEVICE:
opts->filter.name = optarg;
break;
+ case OPT_LIST_SUMMARY:
+ opts->summary = true;
+ break;
default:
return -EINVAL;
}
@@ -176,6 +186,29 @@ static void print_guid_group_line(uint32_t guid, const struct pmt_tss_info *info
print_description(info->description, LIST_GROUP_DESC_INDENT, cols);
}
+/* List @devs, which are sorted by GUID as ctx->devices is */
+static void do_list_summary(const struct pmtctl_ctx *ctx, const struct pmt_device **devs,
+ size_t num_devs)
+{
+ size_t cols = output_columns();
+
+ printf("PMT devices on this system:\n\n");
+
+ for (size_t i = 0; i < num_devs; i++) {
+ uint32_t guid = devs[i]->guid;
+
+ if (!i || guid != devs[i - 1]->guid)
+ print_guid_group_line(guid, pmt_tss_db_lookup(&ctx->tss, guid), cols);
+
+ print_chars(' ', LIST_DEVICE_INDENT);
+ printf("%s\n", devs[i]->name);
+
+ /* A blank line ends each GUID group */
+ if (i + 1 == num_devs || devs[i + 1]->guid != guid)
+ printf("\n");
+ }
+}
+
/*
* Underline a group header up to where its longest metric name would end at
* the description indent, within LIST_SEP_MIN and LIST_SEP_MAX columns
@@ -274,6 +307,11 @@ int cmd_list(int argc, char **argv, const struct pmt_global_opts *gopts)
return PMTCTL_EXIT_USER;
}
+ if (opts.summary) {
+ do_list_summary(&ctx, devs, num_devs);
+ return PMTCTL_EXIT_OK;
+ }
+
if (!ctx.tss.num_tss_info) {
if (gopts->json_path)
log_err("no metric definitions in %s", gopts->json_path);
diff --git a/tools/arch/x86/pmtctl/src/main.c b/tools/arch/x86/pmtctl/src/main.c
index d4a7ae464cb8..081c33aeb649 100644
--- a/tools/arch/x86/pmtctl/src/main.c
+++ b/tools/arch/x86/pmtctl/src/main.c
@@ -27,7 +27,7 @@ static void print_usage(FILE *out)
" If omitted, " PMTCTL_DEFS_DIR " is used if it exists.\n"
"\n"
"Commands:\n"
- " list List available PMT metrics\n"
+ " list List available PMT devices and metrics\n"
"\n"
"Run 'pmtctl <command> --help' for command-specific options.\n");
}
--
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 ` David E. Box [this message]
2026-11-22 19:34 ` [PATCH v2 07/12] tools/arch/x86/pmtctl: Add 'stat' command David E. Box
2026-11-22 19:34 ` [PATCH v2 08/12] tools/arch/x86/pmtctl: Add 'stat --hex' David E. Box
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=0f77cacbead1815624aa72ca6160012fd08010c6.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®