From: Namhyung Kim <namhyung@kernel.org>
To: "Wang, Weilin" <weilin.wang@intel.com>
Cc: Ian Rogers <irogers@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
"Hunter, Adrian" <adrian.hunter@intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
"linux-perf-users@vger.kernel.org"
<linux-perf-users@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Taylor, Perry" <perry.taylor@intel.com>,
"Alt, Samantha" <samantha.alt@intel.com>,
"Biggers, Caleb" <caleb.biggers@intel.com>
Subject: Re: [RFC PATCH v3 2/6] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric.
Date: Mon, 11 Mar 2024 15:27:48 -0700 [thread overview]
Message-ID: <CAM9d7cguqEnxABCNYDr6W93sY3hPRBV1ieuWhy+6+H54OmWprA@mail.gmail.com> (raw)
In-Reply-To: <CO6PR11MB5635949BE12E694160F28D5CEE242@CO6PR11MB5635.namprd11.prod.outlook.com>
On Mon, Mar 11, 2024 at 2:30 PM Wang, Weilin <weilin.wang@intel.com> wrote:
>
>
>
> > -----Original Message-----
> > From: Namhyung Kim <namhyung@kernel.org>
> > Sent: Monday, March 11, 2024 2:08 PM
> > To: Wang, Weilin <weilin.wang@intel.com>
> > Cc: Ian Rogers <irogers@google.com>; Peter Zijlstra <peterz@infradead.org>;
> > Ingo Molnar <mingo@redhat.com>; Arnaldo Carvalho de Melo
> > <acme@kernel.org>; Alexander Shishkin
> > <alexander.shishkin@linux.intel.com>; Jiri Olsa <jolsa@kernel.org>; Hunter,
> > Adrian <adrian.hunter@intel.com>; Kan Liang <kan.liang@linux.intel.com>;
> > linux-perf-users@vger.kernel.org; linux-kernel@vger.kernel.org; Taylor, Perry
> > <perry.taylor@intel.com>; Alt, Samantha <samantha.alt@intel.com>; Biggers,
> > Caleb <caleb.biggers@intel.com>
> > Subject: Re: [RFC PATCH v3 2/6] perf stat: Fork and launch perf record when
> > perf stat needs to get retire latency value for a metric.
> >
> > Hello Weilin,
> >
> > On Fri, Mar 1, 2024 at 4:11 PM <weilin.wang@intel.com> wrote:
> > >
> > > From: Weilin Wang <weilin.wang@intel.com>
> > >
> > > When retire_latency value is used in a metric formula, perf stat would fork a
> > > perf record process with "-e" and "-W" options. Perf record will collect
> > > required retire_latency values in parallel while perf stat is collecting
> > > counting values.
> > >
> > > At the point of time that perf stat stops counting, it would send sigterm
> > signal
> > > to perf record process and receiving sampling data back from perf record
> > from a
> > > pipe. Perf stat will then process the received data to get retire latency data
> > > and calculate metric result.
> > >
> > > Signed-off-by: Weilin Wang <weilin.wang@intel.com>
> > > ---
> > > tools/perf/builtin-stat.c | 179
> > +++++++++++++++++++++++++++++++++-
> > > tools/perf/util/data.c | 4 +
> > > tools/perf/util/data.h | 1 +
> > > tools/perf/util/metricgroup.h | 7 ++
> > > tools/perf/util/stat.h | 3 +
> > > 5 files changed, 191 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> > > index 5a3093541cff..3890a579349e 100644
> > > --- a/tools/perf/builtin-stat.c
> > > +++ b/tools/perf/builtin-stat.c
> > > @@ -94,8 +94,13 @@
> > > #include <perf/evlist.h>
> > > #include <internal/threadmap.h>
> > >
> > > +#include "util/sample.h"
> > > +#include <sys/param.h>
> > > +#include <subcmd/run-command.h>
> > > +
> > > #define DEFAULT_SEPARATOR " "
> > > #define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi"
> > > +#define PERF_DATA "-"
> > >
> > > static void print_counters(struct timespec *ts, int argc, const char **argv);
> > >
> > > @@ -162,7 +167,8 @@ static struct perf_stat_config stat_config = {
> > > .ctl_fd = -1,
> > > .ctl_fd_ack = -1,
> > > .iostat_run = false,
> > > - .tpebs_event_size = 0,
> > > + .tpebs_event_size = 0,
> > > + .tpebs_pid = -1,
> > > };
> > >
> > > static bool cpus_map_matched(struct evsel *a, struct evsel *b)
> > > @@ -687,12 +693,163 @@ static enum counter_recovery
> > stat_handle_error(struct evsel *counter)
> > > return COUNTER_FATAL;
> > > }
> > >
> > > -static int __run_perf_record(void)
> > > +static int __run_perf_record(const char **record_argv)
> > > {
> > > + int i = 0;
> > > + struct tpebs_event *e;
> >
> > Please put a blank line after the declaration.
> >
> >
> > > pr_debug("Prepare perf record for retire_latency\n");
> > > +
> > > +
> >
> > A duplicate new line.
> >
> > > + record_argv[i++] = "perf";
> > > + record_argv[i++] = "record";
> > > + record_argv[i++] = "-W";
> > > +
> > > + if (stat_config.user_requested_cpu_list) {
> > > + record_argv[i++] = "-C";
> > > + record_argv[i++] = stat_config.user_requested_cpu_list;
> > > + }
> > > +
> > > + if (stat_config.system_wide)
> > > + record_argv[i++] = "-a";
> > > +
> > > + list_for_each_entry(e, &stat_config.tpebs_events, nd) {
> > > + record_argv[i++] = "-e";
> > > + record_argv[i++] = e->name;
> > > + }
> > > +
> > > + record_argv[i++] = "-o";
> > > + record_argv[i++] = PERF_DATA;
> >
> > I don't think you need side-band records and synthesizing for this.
> > I'd like to disable all of them but it'd require changes in perf record.
> > For now, you need to pass --synth=no at least.
> >
> > Thanks,
> > Namhyung
> >
>
> Thanks Namhyung! I will update the code and send a new version.
Sure, let me finish my review before then.
Thanks,
Namhyung
next prev parent reply other threads:[~2024-03-11 22:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-02 0:11 [RFC PATCH v3 0/6] TPEBS counting mode support weilin.wang
2024-03-02 0:11 ` [RFC PATCH v3 1/6] perf stat: Parse and find tpebs events when parsing metrics to prepare for perf record sampling weilin.wang
2024-03-12 6:14 ` Namhyung Kim
2024-03-02 0:11 ` [RFC PATCH v3 2/6] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric weilin.wang
2024-03-11 21:08 ` Namhyung Kim
2024-03-11 21:30 ` Wang, Weilin
2024-03-11 22:27 ` Namhyung Kim [this message]
2024-03-12 6:40 ` Namhyung Kim
2024-03-12 21:51 ` Wang, Weilin
2024-03-02 0:11 ` [RFC PATCH v3 3/6] perf stat: Add retire latency values into the expr_parse_ctx to prepare for final metric calculation weilin.wang
2024-03-12 6:42 ` Namhyung Kim
2024-03-02 0:11 ` [RFC PATCH v3 4/6] perf stat: Create another thread for sample data processing weilin.wang
2024-03-12 6:47 ` Namhyung Kim
2024-03-12 21:51 ` Wang, Weilin
2024-03-02 0:11 ` [RFC PATCH v3 5/6] perf stat: Add retire latency print functions to print out at the very end of print out weilin.wang
2024-03-12 6:49 ` Namhyung Kim
2024-03-02 0:11 ` [RFC PATCH v3 6/6] perf vendor events intel: Add MTL metric json files weilin.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=CAM9d7cguqEnxABCNYDr6W93sY3hPRBV1ieuWhy+6+H54OmWprA@mail.gmail.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=caleb.biggers@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@redhat.com \
--cc=perry.taylor@intel.com \
--cc=peterz@infradead.org \
--cc=samantha.alt@intel.com \
--cc=weilin.wang@intel.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;
as well as URLs for NNTP newsgroup(s).