diff options
author | David Ahern <dsahern@gmail.com> | 2015-03-24 11:52:41 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-03-24 12:02:46 -0400 |
commit | e03eaa400cf8b8bded86cc5c41018a1c69152f16 (patch) | |
tree | 50864d78ede1a333b0b6fb8fe09486ed3f3ad1c2 /tools | |
parent | 6b1f342354d45c651cabd2ae0f61f55846f33e10 (diff) |
perf tools: Add pid/tid filtering to report and script commands
The 'record' and 'top' tools already allow a user to specify a CSV of
pids and/or tids of tasks to collect data.
Add those options to the 'report' and 'script' analysis commands to only
consider samples related to the given pids/tids.
This is also inline with the existing comm option.
Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1427212361-7066-1-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Documentation/perf-report.txt | 5 | ||||
-rw-r--r-- | tools/perf/Documentation/perf-script.txt | 6 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 4 | ||||
-rw-r--r-- | tools/perf/builtin-script.c | 4 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 31 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 7 | ||||
-rw-r--r-- | tools/perf/util/thread.h | 11 |
7 files changed, 67 insertions, 1 deletions
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index dd7cccdde498..4879cf638824 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt | |||
@@ -40,6 +40,11 @@ OPTIONS | |||
40 | Only consider symbols in these comms. CSV that understands | 40 | Only consider symbols in these comms. CSV that understands |
41 | file://filename entries. This option will affect the percentage of | 41 | file://filename entries. This option will affect the percentage of |
42 | the overhead column. See --percentage for more info. | 42 | the overhead column. See --percentage for more info. |
43 | --pid=:: | ||
44 | Only show events for given process ID (comma separated list). | ||
45 | |||
46 | --tid=:: | ||
47 | Only show events for given thread ID (comma separated list). | ||
43 | -d:: | 48 | -d:: |
44 | --dsos=:: | 49 | --dsos=:: |
45 | Only consider symbols in these dsos. CSV that understands | 50 | Only consider symbols in these dsos. CSV that understands |
diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt index a21eec05bc42..79445750fcb3 100644 --- a/tools/perf/Documentation/perf-script.txt +++ b/tools/perf/Documentation/perf-script.txt | |||
@@ -193,6 +193,12 @@ OPTIONS | |||
193 | Only display events for these comms. CSV that understands | 193 | Only display events for these comms. CSV that understands |
194 | file://filename entries. | 194 | file://filename entries. |
195 | 195 | ||
196 | --pid=:: | ||
197 | Only show events for given process ID (comma separated list). | ||
198 | |||
199 | --tid=:: | ||
200 | Only show events for given thread ID (comma separated list). | ||
201 | |||
196 | -I:: | 202 | -I:: |
197 | --show-info:: | 203 | --show-info:: |
198 | Display extended information about the perf.data file. This adds | 204 | Display extended information about the perf.data file. This adds |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 81c2f3b97c50..b5b2ad4ca9c4 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -669,6 +669,10 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) | |||
669 | "only consider symbols in these dsos"), | 669 | "only consider symbols in these dsos"), |
670 | OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]", | 670 | OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]", |
671 | "only consider symbols in these comms"), | 671 | "only consider symbols in these comms"), |
672 | OPT_STRING(0, "pid", &symbol_conf.pid_list_str, "pid[,pid...]", | ||
673 | "only consider symbols in these pids"), | ||
674 | OPT_STRING(0, "tid", &symbol_conf.tid_list_str, "tid[,tid...]", | ||
675 | "only consider symbols in these tids"), | ||
672 | OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", | 676 | OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]", |
673 | "only consider these symbols"), | 677 | "only consider these symbols"), |
674 | OPT_STRING(0, "symbol-filter", &report.symbol_filter_str, "filter", | 678 | OPT_STRING(0, "symbol-filter", &report.symbol_filter_str, "filter", |
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index f2a348b57b8f..662366ceb572 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -1562,6 +1562,10 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) | |||
1562 | OPT_STRING('C', "cpu", &cpu_list, "cpu", "list of cpus to profile"), | 1562 | OPT_STRING('C', "cpu", &cpu_list, "cpu", "list of cpus to profile"), |
1563 | OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]", | 1563 | OPT_STRING('c', "comms", &symbol_conf.comm_list_str, "comm[,comm...]", |
1564 | "only display events for these comms"), | 1564 | "only display events for these comms"), |
1565 | OPT_STRING(0, "pid", &symbol_conf.pid_list_str, "pid[,pid...]", | ||
1566 | "only consider symbols in these pids"), | ||
1567 | OPT_STRING(0, "tid", &symbol_conf.tid_list_str, "tid[,tid...]", | ||
1568 | "only consider symbols in these tids"), | ||
1565 | OPT_BOOLEAN('I', "show-info", &show_full_info, | 1569 | OPT_BOOLEAN('I', "show-info", &show_full_info, |
1566 | "display extended information from perf.data file"), | 1570 | "display extended information from perf.data file"), |
1567 | OPT_BOOLEAN('\0', "show-kernel-path", &symbol_conf.show_kernel_path, | 1571 | OPT_BOOLEAN('\0', "show-kernel-path", &symbol_conf.show_kernel_path, |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index a69066865a55..fddeb9073039 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include "machine.h" | 15 | #include "machine.h" |
16 | #include "symbol.h" | 16 | #include "symbol.h" |
17 | #include "strlist.h" | 17 | #include "strlist.h" |
18 | #include "intlist.h" | ||
18 | #include "header.h" | 19 | #include "header.h" |
19 | 20 | ||
20 | #include <elf.h> | 21 | #include <elf.h> |
@@ -1859,6 +1860,20 @@ int setup_list(struct strlist **list, const char *list_str, | |||
1859 | return 0; | 1860 | return 0; |
1860 | } | 1861 | } |
1861 | 1862 | ||
1863 | int setup_intlist(struct intlist **list, const char *list_str, | ||
1864 | const char *list_name) | ||
1865 | { | ||
1866 | if (list_str == NULL) | ||
1867 | return 0; | ||
1868 | |||
1869 | *list = intlist__new(list_str); | ||
1870 | if (!*list) { | ||
1871 | pr_err("problems parsing %s list\n", list_name); | ||
1872 | return -1; | ||
1873 | } | ||
1874 | return 0; | ||
1875 | } | ||
1876 | |||
1862 | static bool symbol__read_kptr_restrict(void) | 1877 | static bool symbol__read_kptr_restrict(void) |
1863 | { | 1878 | { |
1864 | bool value = false; | 1879 | bool value = false; |
@@ -1909,9 +1924,17 @@ int symbol__init(struct perf_session_env *env) | |||
1909 | symbol_conf.comm_list_str, "comm") < 0) | 1924 | symbol_conf.comm_list_str, "comm") < 0) |
1910 | goto out_free_dso_list; | 1925 | goto out_free_dso_list; |
1911 | 1926 | ||
1927 | if (setup_intlist(&symbol_conf.pid_list, | ||
1928 | symbol_conf.pid_list_str, "pid") < 0) | ||
1929 | goto out_free_comm_list; | ||
1930 | |||
1931 | if (setup_intlist(&symbol_conf.tid_list, | ||
1932 | symbol_conf.tid_list_str, "tid") < 0) | ||
1933 | goto out_free_pid_list; | ||
1934 | |||
1912 | if (setup_list(&symbol_conf.sym_list, | 1935 | if (setup_list(&symbol_conf.sym_list, |
1913 | symbol_conf.sym_list_str, "symbol") < 0) | 1936 | symbol_conf.sym_list_str, "symbol") < 0) |
1914 | goto out_free_comm_list; | 1937 | goto out_free_tid_list; |
1915 | 1938 | ||
1916 | /* | 1939 | /* |
1917 | * A path to symbols of "/" is identical to "" | 1940 | * A path to symbols of "/" is identical to "" |
@@ -1930,6 +1953,10 @@ int symbol__init(struct perf_session_env *env) | |||
1930 | symbol_conf.initialized = true; | 1953 | symbol_conf.initialized = true; |
1931 | return 0; | 1954 | return 0; |
1932 | 1955 | ||
1956 | out_free_tid_list: | ||
1957 | intlist__delete(symbol_conf.tid_list); | ||
1958 | out_free_pid_list: | ||
1959 | intlist__delete(symbol_conf.pid_list); | ||
1933 | out_free_comm_list: | 1960 | out_free_comm_list: |
1934 | strlist__delete(symbol_conf.comm_list); | 1961 | strlist__delete(symbol_conf.comm_list); |
1935 | out_free_dso_list: | 1962 | out_free_dso_list: |
@@ -1944,6 +1971,8 @@ void symbol__exit(void) | |||
1944 | strlist__delete(symbol_conf.sym_list); | 1971 | strlist__delete(symbol_conf.sym_list); |
1945 | strlist__delete(symbol_conf.dso_list); | 1972 | strlist__delete(symbol_conf.dso_list); |
1946 | strlist__delete(symbol_conf.comm_list); | 1973 | strlist__delete(symbol_conf.comm_list); |
1974 | intlist__delete(symbol_conf.tid_list); | ||
1975 | intlist__delete(symbol_conf.pid_list); | ||
1947 | vmlinux_path__exit(); | 1976 | vmlinux_path__exit(); |
1948 | symbol_conf.sym_list = symbol_conf.dso_list = symbol_conf.comm_list = NULL; | 1977 | symbol_conf.sym_list = symbol_conf.dso_list = symbol_conf.comm_list = NULL; |
1949 | symbol_conf.initialized = false; | 1978 | symbol_conf.initialized = false; |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index efdaaa544041..09561500164a 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -78,6 +78,7 @@ static inline size_t symbol__size(const struct symbol *sym) | |||
78 | } | 78 | } |
79 | 79 | ||
80 | struct strlist; | 80 | struct strlist; |
81 | struct intlist; | ||
81 | 82 | ||
82 | struct symbol_conf { | 83 | struct symbol_conf { |
83 | unsigned short priv_size; | 84 | unsigned short priv_size; |
@@ -115,6 +116,8 @@ struct symbol_conf { | |||
115 | const char *guestmount; | 116 | const char *guestmount; |
116 | const char *dso_list_str, | 117 | const char *dso_list_str, |
117 | *comm_list_str, | 118 | *comm_list_str, |
119 | *pid_list_str, | ||
120 | *tid_list_str, | ||
118 | *sym_list_str, | 121 | *sym_list_str, |
119 | *col_width_list_str; | 122 | *col_width_list_str; |
120 | struct strlist *dso_list, | 123 | struct strlist *dso_list, |
@@ -124,6 +127,8 @@ struct symbol_conf { | |||
124 | *dso_to_list, | 127 | *dso_to_list, |
125 | *sym_from_list, | 128 | *sym_from_list, |
126 | *sym_to_list; | 129 | *sym_to_list; |
130 | struct intlist *pid_list, | ||
131 | *tid_list; | ||
127 | const char *symfs; | 132 | const char *symfs; |
128 | }; | 133 | }; |
129 | 134 | ||
@@ -295,5 +300,7 @@ int compare_proc_modules(const char *from, const char *to); | |||
295 | 300 | ||
296 | int setup_list(struct strlist **list, const char *list_str, | 301 | int setup_list(struct strlist **list, const char *list_str, |
297 | const char *list_name); | 302 | const char *list_name); |
303 | int setup_intlist(struct intlist **list, const char *list_str, | ||
304 | const char *list_name); | ||
298 | 305 | ||
299 | #endif /* __PERF_SYMBOL */ | 306 | #endif /* __PERF_SYMBOL */ |
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index 783b6688d2f7..9b8a54dc34a8 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <sys/types.h> | 7 | #include <sys/types.h> |
8 | #include "symbol.h" | 8 | #include "symbol.h" |
9 | #include <strlist.h> | 9 | #include <strlist.h> |
10 | #include <intlist.h> | ||
10 | 11 | ||
11 | struct thread_stack; | 12 | struct thread_stack; |
12 | 13 | ||
@@ -100,6 +101,16 @@ static inline bool thread__is_filtered(struct thread *thread) | |||
100 | return true; | 101 | return true; |
101 | } | 102 | } |
102 | 103 | ||
104 | if (symbol_conf.pid_list && | ||
105 | !intlist__has_entry(symbol_conf.pid_list, thread->pid_)) { | ||
106 | return true; | ||
107 | } | ||
108 | |||
109 | if (symbol_conf.tid_list && | ||
110 | !intlist__has_entry(symbol_conf.tid_list, thread->tid)) { | ||
111 | return true; | ||
112 | } | ||
113 | |||
103 | return false; | 114 | return false; |
104 | } | 115 | } |
105 | 116 | ||