From: "Adrián Herrera Arcila" <adrian.herrera@arm.com>
To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
acme@kernel.org
Cc: peterz@infradead.org, mingo@redhat.com, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
namhyung@kernel.org, leo.yan@linaro.org, songliubraving@fb.com,
james.clark@arm.com,
"Adrián Herrera Arcila" <adrian.herrera@arm.com>
Subject: [PATCH 1/2] perf stat: refactor __run_perf_stat common code
Date: Fri, 29 Jul 2022 16:12:43 +0000 [thread overview]
Message-ID: <20220729161244.10522-1-adrian.herrera@arm.com> (raw)
This extracts common code from the branches of the forks if-then-else.
enable_counters(), which was at the beginning of both branches of the
conditional, is now unconditional; evlist__start_workload is extracted
to a different if, which enables making the common clocking code
unconditional.
Signed-off-by: Adrián Herrera Arcila <adrian.herrera@arm.com>
---
tools/perf/builtin-stat.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index d2ecd4d29624..318ffd119dad 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -966,18 +966,18 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
return err;
}
- /*
- * Enable counters and exec the command:
- */
- if (forks) {
- err = enable_counters();
- if (err)
- return -1;
+ err = enable_counters();
+ if (err)
+ return -1;
+
+ /* Exec the command, if any */
+ if (forks)
evlist__start_workload(evsel_list);
- t0 = rdclock();
- clock_gettime(CLOCK_MONOTONIC, &ref_time);
+ t0 = rdclock();
+ clock_gettime(CLOCK_MONOTONIC, &ref_time);
+ if (forks) {
if (interval || timeout || evlist__ctlfd_initialized(evsel_list))
status = dispatch_events(forks, timeout, interval, ×);
if (child_pid != -1) {
@@ -995,13 +995,6 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
if (WIFSIGNALED(status))
psignal(WTERMSIG(status), argv[0]);
} else {
- err = enable_counters();
- if (err)
- return -1;
-
- t0 = rdclock();
- clock_gettime(CLOCK_MONOTONIC, &ref_time);
-
status = dispatch_events(forks, timeout, interval, ×);
}
--
2.36.1
next reply other threads:[~2022-07-29 16:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-29 16:12 Adrián Herrera Arcila [this message]
2022-07-29 16:12 ` [PATCH 2/2] perf stat: fix unexpected delay behaviour Adrián Herrera Arcila
2022-08-01 8:20 ` James Clark
2022-12-13 14:44 ` Arnaldo Carvalho de Melo
2022-12-13 16:40 ` Namhyung Kim
2022-12-14 14:26 ` James Clark
2022-12-14 14:41 ` Arnaldo Carvalho de Melo
2022-12-14 15:57 ` Leo Yan
2022-12-14 17:35 ` Arnaldo Carvalho de Melo
2022-12-15 1:45 ` Leo Yan
2022-08-01 11:45 ` Leo Yan
2022-08-01 11:27 ` [PATCH 1/2] perf stat: refactor __run_perf_stat common code Leo Yan
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=20220729161244.10522-1-adrian.herrera@arm.com \
--to=adrian.herrera@arm.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=james.clark@arm.com \
--cc=jolsa@kernel.org \
--cc=leo.yan@linaro.org \
--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=songliubraving@fb.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).