From: Song Liu <songliubraving@fb.com>
To: <linux-kernel@vger.kernel.org>
Cc: <kernel-team@fb.com>, <acme@kernel.org>, <acme@redhat.com>,
<namhyung@kernel.org>, <jolsa@kernel.org>,
Song Liu <songliubraving@fb.com>
Subject: [PATCH v2 2/3] perf-stat: measure t0 and ref_time after enable_counters()
Date: Tue, 16 Mar 2021 14:18:36 -0700 [thread overview]
Message-ID: <20210316211837.910506-3-songliubraving@fb.com> (raw)
In-Reply-To: <20210316211837.910506-1-songliubraving@fb.com>
Take measurements of t0 and ref_time after enable_counters(), so that
they only measure the time consumed when the counters are enabled.
Signed-off-by: Song Liu <songliubraving@fb.com>
---
tools/perf/builtin-stat.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 92696373da994..d030c3a49a8e4 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -931,15 +931,15 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
/*
* Enable counters and exec the command:
*/
- t0 = rdclock();
- clock_gettime(CLOCK_MONOTONIC, &ref_time);
-
if (forks) {
evlist__start_workload(evsel_list);
err = enable_counters();
if (err)
return -1;
+ t0 = rdclock();
+ clock_gettime(CLOCK_MONOTONIC, &ref_time);
+
if (interval || timeout || evlist__ctlfd_initialized(evsel_list))
status = dispatch_events(forks, timeout, interval, ×);
if (child_pid != -1) {
@@ -960,6 +960,10 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
err = enable_counters();
if (err)
return -1;
+
+ t0 = rdclock();
+ clock_gettime(CLOCK_MONOTONIC, &ref_time);
+
status = dispatch_events(forks, timeout, interval, ×);
}
--
2.30.2
next prev parent reply other threads:[~2021-03-16 21:19 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 21:18 [PATCH v2 0/3] perf-stat: share hardware PMCs with BPF Song Liu
2021-03-16 21:18 ` [PATCH v2 1/3] perf-stat: introduce bperf, " Song Liu
2021-03-18 5:54 ` Namhyung Kim
2021-03-18 7:22 ` Song Liu
2021-03-18 13:49 ` Namhyung Kim
2021-03-18 17:16 ` Song Liu
2021-03-18 21:15 ` Jiri Olsa
2021-03-19 18:41 ` Arnaldo Carvalho de Melo
2021-03-19 18:55 ` Jiri Olsa
2021-03-19 22:06 ` Song Liu
2021-03-23 0:53 ` Song Liu
2021-03-23 12:25 ` Arnaldo Carvalho de Melo
2021-03-23 12:37 ` Arnaldo Carvalho de Melo
2021-03-23 18:27 ` Arnaldo Carvalho de Melo
2021-03-16 21:18 ` Song Liu [this message]
2021-03-16 21:18 ` [PATCH v2 3/3] perf-test: add a test for perf-stat --bpf-counters option Song Liu
2021-03-18 6:07 ` Namhyung Kim
2021-03-18 7:39 ` Song Liu
2021-03-17 5:29 ` [PATCH v2 0/3] perf-stat: share hardware PMCs with BPF Namhyung Kim
2021-03-17 9:19 ` Jiri Olsa
2021-03-17 13:11 ` Arnaldo Carvalho de Melo
2021-03-18 3:52 ` Song Liu
2021-03-18 4:32 ` Namhyung Kim
2021-03-18 7:03 ` Song Liu
2021-03-18 21:14 ` Jiri Olsa
2021-03-19 0:09 ` Arnaldo
2021-03-19 0:22 ` Song Liu
2021-03-19 0:54 ` Namhyung Kim
2021-03-19 15:35 ` Arnaldo Carvalho de Melo
2021-03-19 15:58 ` Namhyung Kim
2021-03-19 16:14 ` Song Liu
2021-03-23 21:10 ` Arnaldo Carvalho de Melo
2021-03-23 21:26 ` Song Liu
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=20210316211837.910506-3-songliubraving@fb.com \
--to=songliubraving@fb.com \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=jolsa@kernel.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@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;
as well as URLs for NNTP newsgroup(s).