From: Yushan Wang <wangyushan12@huawei.com>
To: <peterz@infradead.org>, <mingo@redhat.com>, <acme@kernel.org>,
<namhyung@kernel.org>, <mark.rutland@arm.com>,
<alexander.shishkin@linux.intel.com>, <jolsa@kernel.org>,
<irogers@google.com>, <adrian.hunter@intel.com>,
<james.clark@arm.com>, <john.g.garry@oracle.com>,
<will@kernel.org>, <mike.leach@arm.com>,
<linux-perf-users@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>
Cc: <jic23@kernel.org>, <leo.yan@linux.dev>, <robin.murphy@arm.com>,
<linuxarm@huawei.com>, <hejunhao3@huawei.com>,
<prime.zeng@hisilicon.com>, <fanghao11@huawei.com>,
<wangzhou1@hisilicon.com>, <wangyushan12@huawei.com>
Subject: [RFT PATCH v2 6/7] perf-iostat: Make x86 iostat compatible with new iostat framework
Date: Thu, 7 May 2026 14:37:36 +0800 [thread overview]
Message-ID: <20260507063737.3542950-7-wangyushan12@huawei.com> (raw)
In-Reply-To: <20260507063737.3542950-1-wangyushan12@huawei.com>
From: Shiju Jose <shiju.jose@huawei.com>
Change the original x86 iio iostat supporter to be compatible with the
set of iostat frameworks.
The matching function of x86 iio may not be correct.
Signed-off-by: Shiju Jose <shiju.jose@huawei.com>
Co-developed-by: Yushan Wang <wangyushan12@huawei.com>
Signed-off-by: Yushan Wang <wangyushan12@huawei.com>
---
tools/perf/util/iostat.c | 26 +++++++--------
tools/perf/util/x86-iostat.c | 62 ++++++++++++++++++++++++++----------
2 files changed, 59 insertions(+), 29 deletions(-)
diff --git a/tools/perf/util/iostat.c b/tools/perf/util/iostat.c
index 90607d1cf3fa..6c51f4a521af 100644
--- a/tools/perf/util/iostat.c
+++ b/tools/perf/util/iostat.c
@@ -13,7 +13,7 @@ static struct iostat_pmu *iostat_pmu;
enum iostat_mode_t iostat_mode = IOSTAT_NONE;
-__weak int iostat_prepare(struct evlist *evlist, struct perf_stat_config *config)
+int iostat_prepare(struct evlist *evlist, struct perf_stat_config *config)
{
if (!iostat_pmu)
return -1;
@@ -21,7 +21,7 @@ __weak int iostat_prepare(struct evlist *evlist, struct perf_stat_config *config
return iostat_pmu->prepare(evlist, config);
}
-__weak int iostat_parse(const struct option *opt, const char *str, int unset)
+int iostat_parse(const struct option *opt, const char *str, int unset)
{
if (!iostat_pmu)
return -1;
@@ -29,33 +29,33 @@ __weak int iostat_parse(const struct option *opt, const char *str, int unset)
return iostat_pmu->parse(opt, str, unset);
}
-__weak void iostat_list(struct evlist *evlist, struct perf_stat_config *config)
+void iostat_list(struct evlist *evlist, struct perf_stat_config *config)
{
iostat_pmu->list(evlist, config);
}
-__weak void iostat_release(struct evlist *evlist)
+void iostat_release(struct evlist *evlist)
{
iostat_pmu->release(evlist);
}
-__weak void iostat_print_header_prefix(struct perf_stat_config *config)
+void iostat_print_header_prefix(struct perf_stat_config *config)
{
iostat_pmu->print_header_prefix(config);
}
-__weak void iostat_print_metric(struct perf_stat_config *config,
- struct evsel *evsel,
- struct perf_stat_output_ctx *out)
+void iostat_print_metric(struct perf_stat_config *config,
+ struct evsel *evsel,
+ struct perf_stat_output_ctx *out)
{
iostat_pmu->print_metric(config, evsel, out);
}
-__weak void iostat_print_counters(struct evlist *evlist,
- struct perf_stat_config *config,
- struct timespec *ts, char *prefix,
- iostat_print_counter_t print_cnt_cb,
- void *arg)
+void iostat_print_counters(struct evlist *evlist,
+ struct perf_stat_config *config,
+ struct timespec *ts, char *prefix,
+ iostat_print_counter_t print_cnt_cb,
+ void *arg)
{
iostat_pmu->print_counters(evlist, config, ts, prefix,
print_cnt_cb, arg);
diff --git a/tools/perf/util/x86-iostat.c b/tools/perf/util/x86-iostat.c
index f8d4c9718594..778655cbc2a0 100644
--- a/tools/perf/util/x86-iostat.c
+++ b/tools/perf/util/x86-iostat.c
@@ -332,9 +332,9 @@ static int iostat_event_group(struct evlist *evl,
return ret;
}
-static void iostat_prefix(struct evlist *evlist,
- struct perf_stat_config *config,
- char *prefix, struct timespec *ts)
+static void iio_iostat_prefix(struct evlist *evlist,
+ struct perf_stat_config *config,
+ char *prefix, struct timespec *ts)
{
struct iio_root_port *rp = evlist->selected->priv;
@@ -354,7 +354,7 @@ static void iostat_prefix(struct evlist *evlist,
}
}
-int iostat_prepare(struct evlist *evlist, struct perf_stat_config *config)
+static int iio_iostat_prepare(struct evlist *evlist, struct perf_stat_config *config)
{
if (evlist->core.nr_entries > 0) {
pr_warning("The -e and -M options are not supported."
@@ -371,8 +371,8 @@ int iostat_prepare(struct evlist *evlist, struct perf_stat_config *config)
return iostat_event_group(evlist, root_ports);
}
-int iostat_parse(const struct option *opt, const char *str,
- int unset __maybe_unused)
+static int iio_iostat_parse(const struct option *opt, const char *str,
+ int unset __maybe_unused)
{
int ret;
struct perf_stat_config *config = (struct perf_stat_config *)opt->data;
@@ -392,7 +392,7 @@ int iostat_parse(const struct option *opt, const char *str,
return ret;
}
-void iostat_list(struct evlist *evlist, struct perf_stat_config *config)
+static void iio_iostat_list(struct evlist *evlist, struct perf_stat_config *config)
{
struct evsel *evsel;
struct iio_root_port *rp = NULL;
@@ -405,7 +405,7 @@ void iostat_list(struct evlist *evlist, struct perf_stat_config *config)
}
}
-void iostat_release(struct evlist *evlist)
+static void iio_iostat_release(struct evlist *evlist)
{
struct evsel *evsel;
struct iio_root_port *rp = NULL;
@@ -418,7 +418,7 @@ void iostat_release(struct evlist *evlist)
}
}
-void iostat_print_header_prefix(struct perf_stat_config *config)
+static void iio_iostat_print_header_prefix(struct perf_stat_config *config)
{
if (config->csv_output)
fputs("port,", config->output);
@@ -428,8 +428,8 @@ void iostat_print_header_prefix(struct perf_stat_config *config)
fprintf(config->output, " port ");
}
-void iostat_print_metric(struct perf_stat_config *config, struct evsel *evsel,
- struct perf_stat_output_ctx *out)
+static void iio_iostat_print_metric(struct perf_stat_config *config, struct evsel *evsel,
+ struct perf_stat_output_ctx *out)
{
double iostat_value = 0;
u64 prev_count_val = 0;
@@ -452,24 +452,54 @@ void iostat_print_metric(struct perf_stat_config *config, struct evsel *evsel,
iostat_value / (256 * 1024));
}
-void iostat_print_counters(struct evlist *evlist,
- struct perf_stat_config *config, struct timespec *ts,
- char *prefix, iostat_print_counter_t print_cnt_cb, void *arg)
+static void iio_iostat_print_counters(struct evlist *evlist,
+ struct perf_stat_config *config, struct timespec *ts,
+ char *prefix, iostat_print_counter_t print_cnt_cb, void *arg)
{
void *perf_device = NULL;
struct evsel *counter = evlist__first(evlist);
evlist__set_selected(evlist, counter);
- iostat_prefix(evlist, config, prefix, ts);
+ iio_iostat_prefix(evlist, config, prefix, ts);
fprintf(config->output, "%s", prefix);
evlist__for_each_entry(evlist, counter) {
perf_device = evlist->selected->priv;
if (perf_device && perf_device != counter->priv) {
evlist__set_selected(evlist, counter);
- iostat_prefix(evlist, config, prefix, ts);
+ iio_iostat_prefix(evlist, config, prefix, ts);
fprintf(config->output, "\n%s", prefix);
}
print_cnt_cb(config, counter, arg);
}
fputc('\n', config->output);
}
+
+/*
+ * FIXME: pmu name prefix match might not work for x86 iio.
+ */
+static bool iio_iostat_probe(struct iostat_pmu *iostat_pmu)
+{
+ return perf_pmus__scan_matching_wildcard(NULL, iostat_pmu->pmu_name_wildcard);
+}
+
+static struct iostat_pmu x86_iio_iostat_pmu_list[] = {
+ {
+ .pmu_name_wildcard = "uncore_iio*",
+ .match = iio_iostat_probe,
+ .prepare = iio_iostat_prepare,
+ .parse = iio_iostat_parse,
+ .list = iio_iostat_list,
+ .print_header_prefix = iio_iostat_print_header_prefix,
+ .print_metric = iio_iostat_print_metric,
+ .print_counters = iio_iostat_print_counters,
+ .release = iio_iostat_release,
+ },
+};
+
+static void __attribute__((constructor)) x86_iio_iostat_pmu_init(void)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(x86_iio_iostat_pmu_list); i++)
+ register_iostat_pmu(&x86_iio_iostat_pmu_list[i]);
+}
--
2.33.0
next prev parent reply other threads:[~2026-05-07 6:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 6:37 [RFT PATCH v2 0/7] perf tool: Support iostat for multiple platform Yushan Wang
2026-05-07 6:37 ` [RFT PATCH v2 1/7] perf stat: Check color's length instead of the pointer Yushan Wang
2026-05-07 15:33 ` Ian Rogers
2026-05-07 6:37 ` [RFT PATCH v2 2/7] perf stat: Save unnecessary print_metric() call Yushan Wang
2026-05-07 15:30 ` Ian Rogers
2026-05-07 6:37 ` [RFT PATCH v2 3/7] perf-x86: iostat: Move iostat arch-specific implementation to util Yushan Wang
2026-05-07 15:35 ` Ian Rogers
2026-05-08 10:34 ` Yushan Wang
2026-05-07 6:37 ` [RFT PATCH v2 4/7] perf-x86: iostat: Change iostat_prefix() to static Yushan Wang
2026-05-07 15:39 ` Ian Rogers
2026-05-08 10:35 ` Yushan Wang
2026-05-07 6:37 ` [RFT PATCH v2 5/7] perf-iostat: Extend iostat interface to support different iostat PMUs Yushan Wang
2026-05-07 15:47 ` Ian Rogers
2026-05-08 10:36 ` Yushan Wang
2026-05-07 6:37 ` Yushan Wang [this message]
2026-05-07 16:17 ` [RFT PATCH v2 6/7] perf-iostat: Make x86 iostat compatible with new iostat framework Ian Rogers
2026-05-08 10:36 ` Yushan Wang
2026-05-07 6:37 ` [RFT PATCH v2 7/7] perf-iostat: Enable iostat mode for HiSilicon PCIe PMU Yushan Wang
2026-05-07 16:20 ` Ian Rogers
2026-05-08 10:36 ` Yushan Wang
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=20260507063737.3542950-7-wangyushan12@huawei.com \
--to=wangyushan12@huawei.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=fanghao11@huawei.com \
--cc=hejunhao3@huawei.com \
--cc=irogers@google.com \
--cc=james.clark@arm.com \
--cc=jic23@kernel.org \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=leo.yan@linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=mark.rutland@arm.com \
--cc=mike.leach@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=prime.zeng@hisilicon.com \
--cc=robin.murphy@arm.com \
--cc=wangzhou1@hisilicon.com \
--cc=will@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