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/perf/util | |
| 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/perf/util')
| -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 |
3 files changed, 48 insertions, 1 deletions
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 | ||
