aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2013-08-29 00:29:53 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-08-29 16:45:39 -0400
commitbdc896617b4fcaa9c89da9a9c5b72660f6741d46 (patch)
treebcdd6ea91b2cf58126e670d8505f3e8fa5df56a6 /tools/perf
parent6810fc915f7a89d8134edb3996dbbf8eac386c26 (diff)
perf trace: Honor target pid / tid options when analyzing a file
Allows capture of raw_syscall events for all processes or threads in a task and then analyzing specific ones. Signed-off-by: David Ahern <dsahern@gmail.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1377750593-48046-4-git-send-email-dsahern@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-trace.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 2a6ebe184802..845facc49ef3 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -8,6 +8,7 @@
8#include "util/thread.h" 8#include "util/thread.h"
9#include "util/parse-options.h" 9#include "util/parse-options.h"
10#include "util/strlist.h" 10#include "util/strlist.h"
11#include "util/intlist.h"
11#include "util/thread_map.h" 12#include "util/thread_map.h"
12 13
13#include <libaudit.h> 14#include <libaudit.h>
@@ -259,6 +260,8 @@ struct trace {
259 unsigned long nr_events; 260 unsigned long nr_events;
260 struct strlist *ev_qualifier; 261 struct strlist *ev_qualifier;
261 bool not_ev_qualifier; 262 bool not_ev_qualifier;
263 struct intlist *tid_list;
264 struct intlist *pid_list;
262 bool sched; 265 bool sched;
263 bool multiple_threads; 266 bool multiple_threads;
264 double duration_filter; 267 double duration_filter;
@@ -653,6 +656,18 @@ out_dump:
653 return 0; 656 return 0;
654} 657}
655 658
659static bool skip_sample(struct trace *trace, struct perf_sample *sample)
660{
661 if ((trace->pid_list && intlist__find(trace->pid_list, sample->pid)) ||
662 (trace->tid_list && intlist__find(trace->tid_list, sample->tid)))
663 return false;
664
665 if (trace->pid_list || trace->tid_list)
666 return true;
667
668 return false;
669}
670
656static int trace__process_sample(struct perf_tool *tool, 671static int trace__process_sample(struct perf_tool *tool,
657 union perf_event *event __maybe_unused, 672 union perf_event *event __maybe_unused,
658 struct perf_sample *sample, 673 struct perf_sample *sample,
@@ -664,6 +679,9 @@ static int trace__process_sample(struct perf_tool *tool,
664 679
665 tracepoint_handler handler = evsel->handler.func; 680 tracepoint_handler handler = evsel->handler.func;
666 681
682 if (skip_sample(trace, sample))
683 return 0;
684
667 if (trace->base_time == 0) 685 if (trace->base_time == 0)
668 trace->base_time = sample->time; 686 trace->base_time = sample->time;
669 687
@@ -683,6 +701,27 @@ perf_session__has_tp(struct perf_session *session, const char *name)
683 return evsel != NULL; 701 return evsel != NULL;
684} 702}
685 703
704static int parse_target_str(struct trace *trace)
705{
706 if (trace->opts.target.pid) {
707 trace->pid_list = intlist__new(trace->opts.target.pid);
708 if (trace->pid_list == NULL) {
709 pr_err("Error parsing process id string\n");
710 return -EINVAL;
711 }
712 }
713
714 if (trace->opts.target.tid) {
715 trace->tid_list = intlist__new(trace->opts.target.tid);
716 if (trace->tid_list == NULL) {
717 pr_err("Error parsing thread id string\n");
718 return -EINVAL;
719 }
720 }
721
722 return 0;
723}
724
686static int trace__run(struct trace *trace, int argc, const char **argv) 725static int trace__run(struct trace *trace, int argc, const char **argv)
687{ 726{
688 struct perf_evlist *evlist = perf_evlist__new(); 727 struct perf_evlist *evlist = perf_evlist__new();
@@ -869,6 +908,10 @@ static int trace__replay(struct trace *trace)
869 goto out; 908 goto out;
870 } 909 }
871 910
911 err = parse_target_str(trace);
912 if (err != 0)
913 goto out;
914
872 setup_pager(); 915 setup_pager();
873 916
874 err = perf_session__process_events(session, &trace->tool); 917 err = perf_session__process_events(session, &trace->tool);