Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

David Ahern and committed by
Arnaldo Carvalho de Melo
aa07df6e 350f54fa

+9 -40
+9 -40
tools/perf/builtin-trace.c
··· 74 74 size_t nr; 75 75 int *entries; 76 76 } ev_qualifier_ids; 77 - struct intlist *tid_list; 78 - struct intlist *pid_list; 79 77 struct { 80 78 size_t nr; 81 79 pid_t *entries; ··· 1888 1890 return err; 1889 1891 } 1890 1892 1891 - static bool skip_sample(struct trace *trace, struct perf_sample *sample) 1892 - { 1893 - if ((trace->pid_list && intlist__find(trace->pid_list, sample->pid)) || 1894 - (trace->tid_list && intlist__find(trace->tid_list, sample->tid))) 1895 - return false; 1896 - 1897 - if (trace->pid_list || trace->tid_list) 1898 - return true; 1899 - 1900 - return false; 1901 - } 1902 - 1903 1893 static void trace__set_base_time(struct trace *trace, 1904 1894 struct perf_evsel *evsel, 1905 1895 struct perf_sample *sample) ··· 1912 1926 struct machine *machine __maybe_unused) 1913 1927 { 1914 1928 struct trace *trace = container_of(tool, struct trace, tool); 1929 + struct thread *thread; 1915 1930 int err = 0; 1916 1931 1917 1932 tracepoint_handler handler = evsel->handler; 1918 1933 1919 - if (skip_sample(trace, sample)) 1934 + thread = machine__findnew_thread(trace->host, sample->pid, sample->tid); 1935 + if (thread && thread__is_filtered(thread)) 1920 1936 return 0; 1921 1937 1922 1938 trace__set_base_time(trace, evsel, sample); ··· 1929 1941 } 1930 1942 1931 1943 return err; 1932 - } 1933 - 1934 - static int parse_target_str(struct trace *trace) 1935 - { 1936 - if (trace->opts.target.pid) { 1937 - trace->pid_list = intlist__new(trace->opts.target.pid); 1938 - if (trace->pid_list == NULL) { 1939 - pr_err("Error parsing process id string\n"); 1940 - return -EINVAL; 1941 - } 1942 - } 1943 - 1944 - if (trace->opts.target.tid) { 1945 - trace->tid_list = intlist__new(trace->opts.target.tid); 1946 - if (trace->tid_list == NULL) { 1947 - pr_err("Error parsing thread id string\n"); 1948 - return -EINVAL; 1949 - } 1950 - } 1951 - 1952 - return 0; 1953 1944 } 1954 1945 1955 1946 static int trace__record(struct trace *trace, int argc, const char **argv) ··· 2427 2460 if (session == NULL) 2428 2461 return -1; 2429 2462 2463 + if (trace->opts.target.pid) 2464 + symbol_conf.pid_list_str = strdup(trace->opts.target.pid); 2465 + 2466 + if (trace->opts.target.tid) 2467 + symbol_conf.tid_list_str = strdup(trace->opts.target.tid); 2468 + 2430 2469 if (symbol__init(&session->header.env) < 0) 2431 2470 goto out; 2432 2471 ··· 2475 2502 evsel->attr.config == PERF_COUNT_SW_PAGE_FAULTS)) 2476 2503 evsel->handler = trace__pgfault; 2477 2504 } 2478 - 2479 - err = parse_target_str(trace); 2480 - if (err != 0) 2481 - goto out; 2482 2505 2483 2506 setup_pager(); 2484 2507