From: John Garry <john.g.garry@oracle.com>
To: Ian Rogers <irogers@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
Ravi Bangoria <ravi.bangoria@amd.com>,
Kajol Jain <kjain@linux.ibm.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] perf pmus: Don't print duplicate PMU suffix in list by default
Date: Fri, 11 Aug 2023 16:53:56 +0100 [thread overview]
Message-ID: <be3193b2-2c0c-6e67-e7a9-d04d63a18059@oracle.com> (raw)
In-Reply-To: <20230810214952.2934029-4-irogers@google.com>
On 10/08/2023 22:49, Ian Rogers wrote:
> Duplicate PMUs are no longer printed by default but the suffix of the
> first is printed. When duplicate PMUs are being skipped avoid printing
> the suffix.
>
> Before:
> ```
> $ perf list
> ...
> uncore_imc_free_running_0/data_read/ [Kernel PMU event]
> uncore_imc_free_running_0/data_total/ [Kernel PMU event]
> uncore_imc_free_running_0/data_write/ [Kernel PMU event]
> ```
>
> After:
> ```
> $ perf list
> ...
> uncore_imc_free_running/data_read/ [Kernel PMU event]
> uncore_imc_free_running/data_total/ [Kernel PMU event]
> uncore_imc_free_running/data_write/ [Kernel PMU event]
> ...
> $ perf list -v
> uncore_imc_free_running_0/data_read/ [Kernel PMU event]
> uncore_imc_free_running_0/data_total/ [Kernel PMU event]
> uncore_imc_free_running_0/data_write/ [Kernel PMU event]
> uncore_imc_free_running_1/data_read/ [Kernel PMU event]
> uncore_imc_free_running_1/data_total/ [Kernel PMU event]
> uncore_imc_free_running_1/data_write/ [Kernel PMU event]
> ...
> ```
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/util/pmus.c | 20 ++++++++++++++------
> 1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/util/pmus.c b/tools/perf/util/pmus.c
> index 5073843aca19..b0ecb2e5bdcc 100644
> --- a/tools/perf/util/pmus.c
> +++ b/tools/perf/util/pmus.c
> @@ -440,10 +440,13 @@ static int sub_non_neg(int a, int b)
> }
>
> static char *format_alias(char *buf, int len, const struct perf_pmu *pmu,
> - const struct perf_pmu_alias *alias)
> + const struct perf_pmu_alias *alias, bool skip_duplicate_pmus)
> {
> struct parse_events_term *term;
> - int used = snprintf(buf, len, "%s/%s", pmu->name, alias->name);
> + int pmu_name_len = skip_duplicate_pmus
> + ? pmu_name_len_no_suffix(pmu->name, /*num=*/NULL)
> + : (int)strlen(pmu->name);
> + int used = snprintf(buf, len, "%.*s/%s", pmu_name_len, pmu->name, alias->name);
>
> list_for_each_entry(term, &alias->terms, list) {
> if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR)
> @@ -473,9 +476,10 @@ void perf_pmus__print_pmu_events(const struct print_callbacks *print_cb, void *p
> int printed = 0;
> int len, j;
> struct sevent *aliases;
> + bool skip_duplicate_pmus = print_cb->skip_duplicate_pmus(print_state);
nit: that code could have been in the previous patch
> struct perf_pmu *(*scan_fn)(struct perf_pmu *);
>
> - if (print_cb->skip_duplicate_pmus(print_state))
> + if (skip_duplicate_pmus)
> scan_fn = perf_pmus__scan_skip_duplicates;
> else
> scan_fn = perf_pmus__scan;
> @@ -518,6 +522,7 @@ void perf_pmus__print_pmu_events(const struct print_callbacks *print_cb, void *p
> *desc = NULL, *long_desc = NULL,
> *encoding_desc = NULL, *topic = NULL,
> *pmu_name = NULL;
> + int pmu_name_len;
> bool deprecated = false;
> size_t buf_used;
>
> @@ -528,7 +533,8 @@ void perf_pmus__print_pmu_events(const struct print_callbacks *print_cb, void *p
> if (!aliases[j].event) {
> /* A selectable event. */
> pmu_name = aliases[j].pmu->name;
> - buf_used = snprintf(buf, sizeof(buf), "%s//", pmu_name) + 1;
> + pmu_name_len = pmu_name_len_no_suffix(pmu_name, /*num=*/NULL);
> + buf_used = snprintf(buf, sizeof(buf), "%.*s//", pmu_name_len, pmu_name) + 1;
> name = buf;
> } else {
> if (aliases[j].event->desc) {
> @@ -536,7 +542,7 @@ void perf_pmus__print_pmu_events(const struct print_callbacks *print_cb, void *p
> buf_used = 0;
> } else {
> name = format_alias(buf, sizeof(buf), aliases[j].pmu,
> - aliases[j].event);
> + aliases[j].event, skip_duplicate_pmus);
> if (aliases[j].is_cpu) {
> alias = name;
> name = aliases[j].event->name;
> @@ -554,8 +560,10 @@ void perf_pmus__print_pmu_events(const struct print_callbacks *print_cb, void *p
> long_desc = aliases[j].event->long_desc;
> topic = aliases[j].event->topic;
> encoding_desc = buf + buf_used;
> + pmu_name_len = pmu_name_len_no_suffix(pmu_name, /*num=*/NULL);
> buf_used += snprintf(buf + buf_used, sizeof(buf) - buf_used,
> - "%s/%s/", pmu_name, aliases[j].event->str) + 1;
> + "%.*s/%s/", pmu_name_len, pmu_name,
> + aliases[j].event->str) + 1;
> deprecated = aliases[j].event->deprecated;
> }
> print_cb->print_event(print_state,
prev parent reply other threads:[~2023-08-11 15:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 21:49 [PATCH v2 0/3] perf list: Remove duplicate PMUs Ian Rogers
2023-08-10 21:49 ` [PATCH v2 1/3] perf pmus: Sort pmus by name then suffix Ian Rogers
2023-08-11 13:56 ` Arnaldo Carvalho de Melo
2023-08-11 15:19 ` Ian Rogers
2023-08-11 15:46 ` Arnaldo Carvalho de Melo
2023-08-11 13:59 ` John Garry
2023-08-11 15:15 ` Ian Rogers
2023-08-10 21:49 ` [PATCH v2 2/3] perf pmus: Add scan that ignores duplicates, use for perf list Ian Rogers
2023-08-11 15:51 ` John Garry
2023-08-14 15:57 ` Ian Rogers
2023-08-14 16:09 ` Ian Rogers
2023-08-15 8:56 ` John Garry
2023-08-10 21:49 ` [PATCH v2 3/3] perf pmus: Don't print duplicate PMU suffix in list by default Ian Rogers
2023-08-11 15:53 ` John Garry [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=be3193b2-2c0c-6e67-e7a9-d04d63a18059@oracle.com \
--to=john.g.garry@oracle.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=kjain@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=ravi.bangoria@amd.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
all inboxes | Powered by JetHome®