From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Adrian Hunter <adrian.hunter@intel.com>,
David Ahern <dsahern@gmail.com>, Don Zickus <dzickus@redhat.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Jiri Olsa <jolsa@redhat.com>, Mike Galbraith <efault@gmx.de>,
Namhyung Kim <namhyung@kernel.org>,
Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <peterz@infradead.org>,
Stephane Eranian <eranian@google.com>
Subject: [PATCH 02/33] perf evlist: Don't run workload if not told to
Date: Mon, 4 Aug 2014 13:17:13 -0300 [thread overview]
Message-ID: <1407169064-25625-3-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1407169064-25625-1-git-send-email-acme@kernel.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
The perf_evlist__prepare_workload() method works by forking and then
waiting on a fd that must be written to to allow the workload to be
exec()ed.
But if the tool calling it fails to, say, set up the events with which
it wants to sample the workload for, it will not call
perf_evlist__start_workload(), but even in this case the workload ended
up running:
[acme@zoo linux]$ trace /bin/echo workload ends up running, it should not...
Couldn't mmap the events: Operation not permitted
workload ends up running, it should not...
[acme@zoo linux]$
So check if at least one byte was written before letting exec() be
called.
Now the expected behaviour:
[acme@zoo linux]$ trace /bin/echo workload ends up running, it should not...
Couldn't mmap the events: Operation not permitted
[acme@zoo linux]$
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-oh1ixo8m74rf295a05gfjw8b@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/evlist.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index 814e954c1318..3b366c085021 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1061,6 +1061,8 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist, struct target *tar
}
if (!evlist->workload.pid) {
+ int ret;
+
if (pipe_output)
dup2(2, 1);
@@ -1078,8 +1080,22 @@ int perf_evlist__prepare_workload(struct perf_evlist *evlist, struct target *tar
/*
* Wait until the parent tells us to go.
*/
- if (read(go_pipe[0], &bf, 1) == -1)
- perror("unable to read pipe");
+ ret = read(go_pipe[0], &bf, 1);
+ /*
+ * The parent will ask for the execvp() to be performed by
+ * writing exactly one byte, in workload.cork_fd, usually via
+ * perf_evlist__start_workload().
+ *
+ * For cancelling the workload without actuallin running it,
+ * the parent will just close workload.cork_fd, without writing
+ * anything, i.e. read will return zero and we just exit()
+ * here.
+ */
+ if (ret != 1) {
+ if (ret == -1)
+ perror("unable to read pipe");
+ exit(ret);
+ }
execvp(argv[0], (char **)argv);
--
1.9.3
next prev parent reply other threads:[~2014-08-04 16:18 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-04 16:17 [GIT PULL 00/33] perf/core improvements and fixes Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 01/33] perf tools: Fix arm64 build error Arnaldo Carvalho de Melo
2014-08-04 16:17 ` Arnaldo Carvalho de Melo [this message]
2014-08-04 16:17 ` [PATCH 03/33] perf symbols: Make sure --symfs usage includes the path separator Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 04/33] perf kvm stat: Properly show submicrosecond times Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 05/33] perf record: Allow the user to disable time stamps Arnaldo Carvalho de Melo
2014-08-05 6:08 ` Ingo Molnar
2014-08-05 13:33 ` Arnaldo Carvalho de Melo
2014-08-12 14:58 ` Ingo Molnar
2014-08-12 15:29 ` Arnaldo Carvalho de Melo
2014-08-13 5:08 ` Ingo Molnar
2014-08-05 14:17 ` Andi Kleen
2014-08-05 14:31 ` Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 06/33] perf tools: Rename ordered_samples bool to ordered_events Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 07/33] perf tools: Rename ordered_samples struct " Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 08/33] perf tools: Rename ordered_events members Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 09/33] perf tools: Add ordered_events__(new|delete) interface Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 10/33] perf tools: Factor ordered_events__flush to be more generic Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 11/33] perf tools: Limit ordered events queue size Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 12/33] perf tools: Flush ordered events in case of allocation failure Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 13/33] perf tools: Make perf_session__deliver_event global Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 14/33] perf tools: Create ordered-events object Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 15/33] perf tools: Use list_move in ordered_events_delete function Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 16/33] perf tools: Add ordered_events__init function Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 17/33] perf tools: Add ordered_events__free function Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 18/33] perf tools: Add perf_config_u64 function Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 19/33] perf tools: Add report.queue-size config file option Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 20/33] perf tools: Add debug prints for ordered events queue Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 21/33] perf tools: Allow out of order messages in forced flush Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 22/33] perf tools: Show better error message in case we fail to open counters due to EBUSY error Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 23/33] perf kmem: Do not ignore mmap events Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 24/33] perf tools: Fix make PYTHON override Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 25/33] perf tools: Left-align output contents Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 26/33] perf tools: Make __hpp__fmt() receive an additional len argument Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 27/33] perf tools: Save column length in perf_hpp_fmt Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 28/33] perf report: Honor column width setting Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 29/33] perf top: Add -w option for setting column width Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 30/33] perf tools: Add name field into perf_hpp_fmt Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 31/33] perf tools: Fix column alignment when headers aren't shown on TUI Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 32/33] perf tools: Fix PERF_FLAG_FD_CLOEXEC flag probing event type open counters due to EBUSY error Arnaldo Carvalho de Melo
2014-08-04 16:17 ` [PATCH 33/33] perf tools: Default to python version 2 Arnaldo Carvalho de Melo
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=1407169064-25625-3-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=dsahern@gmail.com \
--cc=dzickus@redhat.com \
--cc=efault@gmx.de \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=paulus@samba.org \
--cc=peterz@infradead.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).