aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2016-11-25 11:29:52 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-11-25 14:04:22 -0500
commitaa07df6eb5061eed3f5d0820dc646d7f6ddface2 (patch)
treee2bae538bc9deb8fee24bd8c3d8cf5117371cf93
parent350f54fab2afd7f819e64fbeecdf980086fa59f2 (diff)
perf trace: Update tid/pid filtering option to leverage symbol_conf
Leverage pid/tid filtering done by symbol_conf hooks. Signed-off-by: David Ahern <dsahern@gmail.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Link: http://lkml.kernel.org/r/1480091392-35645-1-git-send-email-dsa@cumulusnetworks.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-trace.c49
1 files changed, 9 insertions, 40 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 5f45166c892d..206bf72b77fc 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -74,8 +74,6 @@ struct trace {
74 size_t nr; 74 size_t nr;
75 int *entries; 75 int *entries;
76 } ev_qualifier_ids; 76 } ev_qualifier_ids;
77 struct intlist *tid_list;
78 struct intlist *pid_list;
79 struct { 77 struct {
80 size_t nr; 78 size_t nr;
81 pid_t *entries; 79 pid_t *entries;
@@ -1890,18 +1888,6 @@ out_put:
1890 return err; 1888 return err;
1891} 1889}
1892 1890
1893static bool skip_sample(struct trace *trace, struct perf_sample *sample)
1894{
1895 if ((trace->pid_list && intlist__find(trace->pid_list, sample->pid)) ||
1896 (trace->tid_list && intlist__find(trace->tid_list, sample->tid)))
1897 return false;
1898
1899 if (trace->pid_list || trace->tid_list)
1900 return true;
1901
1902 return false;
1903}
1904
1905static void trace__set_base_time(struct trace *trace, 1891static void trace__set_base_time(struct trace *trace,
1906 struct perf_evsel *evsel, 1892 struct perf_evsel *evsel,
1907 struct perf_sample *sample) 1893 struct perf_sample *sample)
@@ -1926,11 +1912,13 @@ static int trace__process_sample(struct perf_tool *tool,
1926 struct machine *machine __maybe_unused) 1912 struct machine *machine __maybe_unused)
1927{ 1913{
1928 struct trace *trace = container_of(tool, struct trace, tool); 1914 struct trace *trace = container_of(tool, struct trace, tool);
1915 struct thread *thread;
1929 int err = 0; 1916 int err = 0;
1930 1917
1931 tracepoint_handler handler = evsel->handler; 1918 tracepoint_handler handler = evsel->handler;
1932 1919
1933 if (skip_sample(trace, sample)) 1920 thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
1921 if (thread && thread__is_filtered(thread))
1934 return 0; 1922 return 0;
1935 1923
1936 trace__set_base_time(trace, evsel, sample); 1924 trace__set_base_time(trace, evsel, sample);
@@ -1943,27 +1931,6 @@ static int trace__process_sample(struct perf_tool *tool,
1943 return err; 1931 return err;
1944} 1932}
1945 1933
1946static int parse_target_str(struct trace *trace)
1947{
1948 if (trace->opts.target.pid) {
1949 trace->pid_list = intlist__new(trace->opts.target.pid);
1950 if (trace->pid_list == NULL) {
1951 pr_err("Error parsing process id string\n");
1952 return -EINVAL;
1953 }
1954 }
1955
1956 if (trace->opts.target.tid) {
1957 trace->tid_list = intlist__new(trace->opts.target.tid);
1958 if (trace->tid_list == NULL) {
1959 pr_err("Error parsing thread id string\n");
1960 return -EINVAL;
1961 }
1962 }
1963
1964 return 0;
1965}
1966
1967static int trace__record(struct trace *trace, int argc, const char **argv) 1934static int trace__record(struct trace *trace, int argc, const char **argv)
1968{ 1935{
1969 unsigned int rec_argc, i, j; 1936 unsigned int rec_argc, i, j;
@@ -2460,6 +2427,12 @@ static int trace__replay(struct trace *trace)
2460 if (session == NULL) 2427 if (session == NULL)
2461 return -1; 2428 return -1;
2462 2429
2430 if (trace->opts.target.pid)
2431 symbol_conf.pid_list_str = strdup(trace->opts.target.pid);
2432
2433 if (trace->opts.target.tid)
2434 symbol_conf.tid_list_str = strdup(trace->opts.target.tid);
2435
2463 if (symbol__init(&session->header.env) < 0) 2436 if (symbol__init(&session->header.env) < 0)
2464 goto out; 2437 goto out;
2465 2438
@@ -2503,10 +2476,6 @@ static int trace__replay(struct trace *trace)
2503 evsel->handler = trace__pgfault; 2476 evsel->handler = trace__pgfault;
2504 } 2477 }
2505 2478
2506 err = parse_target_str(trace);
2507 if (err != 0)
2508 goto out;
2509
2510 setup_pager(); 2479 setup_pager();
2511 2480
2512 err = perf_session__process_events(session); 2481 err = perf_session__process_events(session);