From: Namhyung Kim <namhyung@kernel.org>
To: weilin.wang@intel.com
Cc: Ian Rogers <irogers@google.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Perry Taylor <perry.taylor@intel.com>,
Samantha Alt <samantha.alt@intel.com>,
Caleb Biggers <caleb.biggers@intel.com>
Subject: Re: [RFC PATCH v9 5/7] perf stat: Add command line option for enabling tpebs recording
Date: Fri, 24 May 2024 16:20:47 -0700 [thread overview]
Message-ID: <CAM9d7cg7Xg=pxc5sxfGo7Om2qh3zoj2nbtyAyu6D5MOedfJ6SQ@mail.gmail.com> (raw)
In-Reply-To: <20240521173952.3397644-6-weilin.wang@intel.com>
On Tue, May 21, 2024 at 10:40 AM <weilin.wang@intel.com> wrote:
>
> From: Weilin Wang <weilin.wang@intel.com>
>
> With this command line option, tpebs recording is turned off in perf stat on
> default. It will only be turned on when this option is given in perf stat
> command.
>
> Signed-off-by: Weilin Wang <weilin.wang@intel.com>
> ---
> tools/perf/builtin-stat.c | 19 +++++++++++++------
> tools/perf/util/evsel.c | 19 ++++++++++++++-----
> 2 files changed, 27 insertions(+), 11 deletions(-)
>
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index c0e9dfa3b3c2..c27521fb1aee 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -117,6 +117,7 @@ static volatile sig_atomic_t child_pid = -1;
> static int detailed_run = 0;
> static bool transaction_run;
> static bool topdown_run = false;
> +static bool tpebs_recording = false;
> static bool smi_cost = false;
> static bool smi_reset = false;
> static int big_num_opt = -1;
> @@ -677,9 +678,11 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
> int err;
> bool second_pass = false;
>
> - err = start_tpebs(&stat_config, evsel_list);
> - if (err < 0)
> - return err;
> + if (tpebs_recording) {
> + err = start_tpebs(&stat_config, evsel_list);
> + if (err < 0)
> + return err;
> + }
>
> if (forks) {
> if (evlist__prepare_workload(evsel_list, &target, argv, is_pipe, workload_exec_failed_signal) < 0) {
> @@ -886,9 +889,11 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
>
> t1 = rdclock();
>
> - err = stop_tpebs();
> - if (err < 0)
> - return err;
> + if (tpebs_recording) {
> + err = stop_tpebs();
> + if (err < 0)
> + return err;
> + }
>
> if (stat_config.walltime_run_table)
> stat_config.walltime_run[run_idx] = t1 - t0;
> @@ -1246,6 +1251,8 @@ static struct option stat_options[] = {
> "disable adding events for the metric threshold calculation"),
> OPT_BOOLEAN(0, "topdown", &topdown_run,
> "measure top-down statistics"),
> + OPT_BOOLEAN(0, "enable-tpebs-recording", &tpebs_recording,
Just --tpebs or --tpebs-record? I just prefer short names. :)
> + "enable recording for tpebs when retire_latency required"),
> OPT_UINTEGER(0, "td-level", &stat_config.topdown_level,
> "Set the metrics level for the top-down statistics (0: max level)"),
> OPT_BOOLEAN(0, "smi-cost", &smi_cost,
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 4d700338fc99..e1f3f63dfb54 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -1540,21 +1540,30 @@ static int evsel__set_retire_lat(struct evsel *evsel, int cpu_map_idx, int threa
> }
> }
>
> - if (!found)
> - return -1;
> + /* Set ena and run to non-zero */
> + count->ena = count->run = 1;
> + count->lost = 0;
> +
> + if (!found) {
> + /*
> + * Set default value or 0 when retire_latency for this event is
> + * not found from sampling data (enable_tpebs_recording not set
> + * or 0 sample recorded).
> + */
> + val = 0;
> + return 0;
> + }
>
> /*
> * Only set retire_latency value to the first CPU and thread.
> */
> if (cpu_map_idx == 0 && thread == 0)
> + /* Lost precision when casting from double to __u64. Any improvement? */
Maybe you can save val * 1000 and then later
convert back to double and divide by 1000?
Thanks,
Namhyung
> val = t->val;
> else
> val = 0;
>
> count->val = val;
> - /* Set ena and run to non-zero */
> - count->ena = count->run = 1;
> - count->lost = 0;
> return 0;
> }
>
> --
> 2.43.0
>
next prev parent reply other threads:[~2024-05-24 23:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-21 17:39 [RFC PATCH v9 0/7] TPEBS counting mode support weilin.wang
2024-05-21 17:39 ` [RFC PATCH v9 1/7] perf vendor events intel: Add MTL metric json files weilin.wang
2024-05-21 17:39 ` [RFC PATCH v9 2/7] perf data: Allow to use given fd in data->file.fd weilin.wang
2024-05-21 17:39 ` [RFC PATCH v9 3/7] perf stat: Fork and launch perf record when perf stat needs to get retire latency value for a metric weilin.wang
2024-05-24 23:02 ` Namhyung Kim
2024-05-24 23:45 ` Wang, Weilin
2024-05-26 17:45 ` Namhyung Kim
2024-05-24 23:59 ` Wang, Weilin
2024-05-21 17:39 ` [RFC PATCH v9 4/7] perf stat: Plugin retire_lat value from sampled data to evsel weilin.wang
2024-05-24 23:17 ` Namhyung Kim
2024-05-24 23:51 ` Wang, Weilin
2024-05-26 18:01 ` Namhyung Kim
2024-05-27 4:48 ` Wang, Weilin
2024-05-28 22:16 ` Ian Rogers
2024-05-21 17:39 ` [RFC PATCH v9 5/7] perf stat: Add command line option for enabling tpebs recording weilin.wang
2024-05-24 23:20 ` Namhyung Kim [this message]
2024-05-24 23:22 ` Namhyung Kim
2024-05-24 23:54 ` Wang, Weilin
2024-05-21 17:39 ` [RFC PATCH v9 6/7] perf Document: Add TPEBS to Documents weilin.wang
2024-05-21 17:39 ` [RFC PATCH v9 7/7] perf test: Add test for Intel TPEBS counting mode weilin.wang
2024-05-24 23:24 ` Namhyung Kim
2024-05-23 4:03 ` [RFC PATCH v9 0/7] TPEBS counting mode support Ian Rogers
2024-05-23 16:45 ` Wang, Weilin
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='CAM9d7cg7Xg=pxc5sxfGo7Om2qh3zoj2nbtyAyu6D5MOedfJ6SQ@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).