From: tip-bot for Namhyung Kim <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: acme@redhat.com, linux-kernel@vger.kernel.org, paulus@samba.org,
hpa@zytor.com, mingo@kernel.org, a.p.zijlstra@chello.nl,
namhyung.kim@lge.com, namhyung@kernel.org, jolsa@redhat.com,
dsahern@gmail.com, tglx@linutronix.de
Subject: [tip:perf/core] perf stat: Use perf_evlist__prepare/ start_workload()
Date: Thu, 21 Mar 2013 04:11:38 -0700 [thread overview]
Message-ID: <tip-acf2892270dcc4288c572b1159474c81f3819749@git.kernel.org> (raw)
In-Reply-To: <1362987798-24969-7-git-send-email-namhyung@kernel.org>
Commit-ID: acf2892270dcc4288c572b1159474c81f3819749
Gitweb: http://git.kernel.org/tip/acf2892270dcc4288c572b1159474c81f3819749
Author: Namhyung Kim <namhyung.kim@lge.com>
AuthorDate: Mon, 11 Mar 2013 16:43:18 +0900
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 15 Mar 2013 13:06:04 -0300
perf stat: Use perf_evlist__prepare/start_workload()
The perf stat had an open code to the duplicated work. Use the helper
as it now can be called without struct perf_record_opts.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1362987798-24969-7-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/builtin-stat.c | 58 ++++++-----------------------------------------
1 file changed, 7 insertions(+), 51 deletions(-)
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 20ffaf9..69fe6ed 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -337,16 +337,14 @@ static void print_interval(void)
}
}
-static int __run_perf_stat(int argc __maybe_unused, const char **argv)
+static int __run_perf_stat(int argc, const char **argv)
{
char msg[512];
unsigned long long t0, t1;
struct perf_evsel *counter;
struct timespec ts;
int status = 0;
- int child_ready_pipe[2], go_pipe[2];
const bool forks = (argc > 0);
- char buf;
if (interval) {
ts.tv_sec = interval / 1000;
@@ -362,55 +360,12 @@ static int __run_perf_stat(int argc __maybe_unused, const char **argv)
return -1;
}
- if (forks && (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) {
- perror("failed to create pipes");
- return -1;
- }
-
if (forks) {
- if ((child_pid = fork()) < 0)
- perror("failed to fork");
-
- if (!child_pid) {
- close(child_ready_pipe[0]);
- close(go_pipe[1]);
- fcntl(go_pipe[0], F_SETFD, FD_CLOEXEC);
-
- /*
- * Do a dummy execvp to get the PLT entry resolved,
- * so we avoid the resolver overhead on the real
- * execvp call.
- */
- execvp("", (char **)argv);
-
- /*
- * Tell the parent we're ready to go
- */
- close(child_ready_pipe[1]);
-
- /*
- * Wait until the parent tells us to go.
- */
- if (read(go_pipe[0], &buf, 1) == -1)
- perror("unable to read pipe");
-
- execvp(argv[0], (char **)argv);
-
- perror(argv[0]);
- exit(-1);
+ if (perf_evlist__prepare_workload(evsel_list, &target, argv,
+ false, false) < 0) {
+ perror("failed to prepare workload");
+ return -1;
}
-
- if (perf_target__none(&target))
- evsel_list->threads->map[0] = child_pid;
-
- /*
- * Wait for the child to be ready to exec.
- */
- close(child_ready_pipe[1]);
- close(go_pipe[0]);
- if (read(child_ready_pipe[0], &buf, 1) == -1)
- perror("unable to read pipe");
- close(child_ready_pipe[0]);
}
if (group)
@@ -457,7 +412,8 @@ static int __run_perf_stat(int argc __maybe_unused, const char **argv)
clock_gettime(CLOCK_MONOTONIC, &ref_time);
if (forks) {
- close(go_pipe[1]);
+ perf_evlist__start_workload(evsel_list);
+
if (interval) {
while (!waitpid(child_pid, &status, WNOHANG)) {
nanosleep(&ts, NULL);
next prev parent reply other threads:[~2013-03-21 11:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-11 7:43 [PATCH 1/7] perf evlist: Remove cpus and threads arguments from perf_evlist__new() Namhyung Kim
2013-03-11 7:43 ` [PATCH 2/7] perf evlist: Use cpu_map__nr() helper Namhyung Kim
2013-03-21 11:05 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-03-11 7:43 ` [PATCH 3/7] perf evlist: Add thread_map__nr() helper Namhyung Kim
2013-03-21 11:07 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-03-11 7:43 ` [PATCH 4/7] perf evlist: Pass struct perf_target to perf_evlist__prepare_workload() Namhyung Kim
2013-03-21 11:08 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-03-11 7:43 ` [PATCH 5/7] perf evlist: Do not pass struct record_opts " Namhyung Kim
2013-03-21 11:09 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-03-11 7:43 ` [PATCH 6/7] perf evlist: Add want_signal parameter " Namhyung Kim
2013-03-21 11:10 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-03-11 7:43 ` [PATCH 7/7] perf stat: use perf_evlist__prepare/start_workload() Namhyung Kim
2013-03-21 11:11 ` tip-bot for Namhyung Kim [this message]
2013-03-21 11:04 ` [tip:perf/core] perf evlist: Remove cpus and threads arguments from perf_evlist__new() tip-bot for Namhyung Kim
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=tip-acf2892270dcc4288c572b1159474c81f3819749@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--cc=namhyung@kernel.org \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
/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).