Skip to contentSkip to conversation

perf trace: Filter out the trace pid when no threads are specified

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Feb 26, 2015 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  241b057ce5c01a24c280f124fab60109cb562589
Gitweb:     http://git.kernel.org/tip/241b057ce5c01a24c280f124fab60109cb562589
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Sat, 21 Feb 2015 10:15:21 -0800
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Sun, 22 Feb 2015 22:14:48 -0300

perf trace: Filter out the trace pid when no threads are specified

To avoid tracing the tracer.

Cc Adrian Hunter <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc David Ahern <[email protected]>
Cc Don Zickus <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/builtin-trace.c | 9 +++++++++
 1 file changed, 9 insertions(+)
tools/perf/builtin-trace.c +9 -0
index 3a696aa..cb33e4c 100644
@@ -2151,6 +2151,15 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
 	if (err < 0)
 		goto out_error_open;
 
+	/*
+	 * Better not use !target__has_task() here because we need to cover the
+	 * case where no threads were specified in the command line, but a
+	 * workload was, and in that case we will fill in the thread_map when
+	 * we fork the workload in perf_evlist__prepare_workload.
+	 */
+	if (evlist->threads->map[0] == -1)
+		perf_evlist__set_filter_pid(evlist, getpid());
+
 	err = perf_evlist__mmap(evlist, trace->opts.mmap_pages, false);
 	if (err < 0)
 		goto out_error_mmap;