From: Namhyung Kim <namhyung@kernel.org>
To: Ian Rogers <irogers@google.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Kan Liang <kan.liang@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 1/2] perf stat: Use field separator in the metric header
Date: Mon, 24 Feb 2025 12:18:23 -0800 [thread overview]
Message-ID: <Z7zUDxho5vLa_2fF@google.com> (raw)
In-Reply-To: <CAP-5=fVmybd=WTKS3kvsF+VU_Lrke9hEvNyBtunAHBw-6ViZig@mail.gmail.com>
On Mon, Feb 24, 2025 at 10:50:24AM -0800, Ian Rogers wrote:
> On Thu, Jun 27, 2024 at 3:24 PM Namhyung Kim <namhyung@kernel.org> wrote:
> >
> > Hi Ian,
> >
> > On Thu, Jun 27, 2024 at 1:48 PM Ian Rogers <irogers@google.com> wrote:
> > >
> > > On Thu, Jun 27, 2024 at 1:03 PM Namhyung Kim <namhyung@kernel.org> wrote:
> > > >
> > > > It didn't use the passed field separator (using -x option) when it
> > > > prints the metric headers and always put "," between the fields.
> > > >
> > > > Before:
> > > > $ sudo ./perf stat -a -x : --per-core -M tma_core_bound --metric-only true
> > > > core,cpus,% tma_core_bound: <<<--- here: "core,cpus," but ":" expected
> > > > S0-D0-C0:2:10.5:
> > > > S0-D0-C1:2:14.8:
> > > > S0-D0-C2:2:9.9:
> > > > S0-D0-C3:2:13.2:
> > > >
> > > > After:
> > > > $ sudo ./perf stat -a -x : --per-core -M tma_core_bound --metric-only true
> > > > core:cpus:% tma_core_bound:
> > > > S0-D0-C0:2:10.5:
> > > > S0-D0-C1:2:15.0:
> > > > S0-D0-C2:2:16.5:
> > > > S0-D0-C3:2:12.5:
> > > >
> > > > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > > > ---
> > > > tools/perf/util/stat-display.c | 37 ++++++++++++++++++++++++++--------
> > > > 1 file changed, 29 insertions(+), 8 deletions(-)
> > > >
> > > > diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> > > > index 91d2f7f65df7..e8673c9f6b49 100644
> > > > --- a/tools/perf/util/stat-display.c
> > > > +++ b/tools/perf/util/stat-display.c
> > > > @@ -47,16 +47,27 @@ static int aggr_header_lens[] = {
> > > > };
> > > >
> > > > static const char *aggr_header_csv[] = {
> > > > - [AGGR_CORE] = "core,cpus,",
> > > > - [AGGR_CACHE] = "cache,cpus,",
> > > > - [AGGR_DIE] = "die,cpus,",
> > > > - [AGGR_SOCKET] = "socket,cpus,",
> > > > - [AGGR_NONE] = "cpu,",
> > > > - [AGGR_THREAD] = "comm-pid,",
> > > > - [AGGR_NODE] = "node,",
> > > > + [AGGR_CORE] = "core%scpus%s",
> > > > + [AGGR_CACHE] = "cache%scpus%s",
> > > > + [AGGR_DIE] = "die%scpus%s",
> > > > + [AGGR_SOCKET] = "socket%scpus%s",
> > > > + [AGGR_NONE] = "cpu%s",
> > > > + [AGGR_THREAD] = "comm-pid%s",
> > > > + [AGGR_NODE] = "node%s",
> > > > [AGGR_GLOBAL] = ""
> > > > };
> > > >
> > > > +static int aggr_header_num[] = {
> > > > + [AGGR_CORE] = 2,
> > > > + [AGGR_CACHE] = 2,
> > > > + [AGGR_DIE] = 2,
> > > > + [AGGR_SOCKET] = 2,
> > > > + [AGGR_NONE] = 1,
> > > > + [AGGR_THREAD] = 1,
> > > > + [AGGR_NODE] = 1,
> > > > + [AGGR_GLOBAL] = 0,
> > > > +};
> > > > +
> > > > static const char *aggr_header_std[] = {
> > > > [AGGR_CORE] = "core",
> > > > [AGGR_CACHE] = "cache",
> > > > @@ -1185,8 +1196,18 @@ static void print_metric_headers_csv(struct perf_stat_config *config,
> > > > {
> > > > if (config->interval)
> > > > fputs("time,", config->output);
> > > > - if (!config->iostat_run)
> > > > + if (config->iostat_run)
> > > > + return;
> > > > +
> > >
> > > Having a static count of commas seems somewhat error prone, perhaps:
> > > ```
> > > const char *header = aggr_header_csv[config->aggr_mode];
> > > if (config->csv_sep == ',' || !strchr(header, ',')) {
> > > fputs(config->output, header);
> > > } else {
> > > char *tmp = strdup(header);
> > > char *p = tmp;
> > > while (p && *p) {
> > > if (p == ',')
> > > *p = config->csv_sep;
> > > p++;
> > > }
> > > fputs(config->output, tmp);
> > > free(tmp);
> > > }
> > > ```
> >
> > Looks good. But I think we should handle longer separators like -x ":::".
> > Will do in v2.
>
> Hi Namhyung,
>
> It looks like this has been forgotten. Did you have a v2?
It's merged to v6.11, please see
https://lore.kernel.org/linux-perf-users/171994580797.2905908.17252651084023923233.b4-ty@kernel.org/
Thanks,
Namhyung
next prev parent reply other threads:[~2025-02-24 20:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-27 20:03 [PATCH 1/2] perf stat: Use field separator in the metric header Namhyung Kim
2024-06-27 20:03 ` [PATCH 2/2] perf stat: Fix a segfault with --per-cluster --metric-only Namhyung Kim
2024-06-28 12:47 ` Arnaldo Carvalho de Melo
2024-06-27 20:48 ` [PATCH 1/2] perf stat: Use field separator in the metric header Ian Rogers
2024-06-27 22:23 ` Namhyung Kim
2025-02-24 18:50 ` Ian Rogers
2025-02-24 20:18 ` Namhyung Kim [this message]
2024-06-28 12:44 ` Arnaldo Carvalho de Melo
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=Z7zUDxho5vLa_2fF@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).