diff options
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r-- | tools/perf/builtin-top.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 8f80df896038..e8b033c074f9 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -64,7 +64,6 @@ | |||
64 | #include <linux/unistd.h> | 64 | #include <linux/unistd.h> |
65 | #include <linux/types.h> | 65 | #include <linux/types.h> |
66 | 66 | ||
67 | |||
68 | void get_term_dimensions(struct winsize *ws) | 67 | void get_term_dimensions(struct winsize *ws) |
69 | { | 68 | { |
70 | char *s = getenv("LINES"); | 69 | char *s = getenv("LINES"); |
@@ -537,10 +536,20 @@ static void perf_top__sort_new_samples(void *arg) | |||
537 | 536 | ||
538 | static void *display_thread_tui(void *arg) | 537 | static void *display_thread_tui(void *arg) |
539 | { | 538 | { |
539 | struct perf_evsel *pos; | ||
540 | struct perf_top *top = arg; | 540 | struct perf_top *top = arg; |
541 | const char *help = "For a higher level overview, try: perf top --sort comm,dso"; | 541 | const char *help = "For a higher level overview, try: perf top --sort comm,dso"; |
542 | 542 | ||
543 | perf_top__sort_new_samples(top); | 543 | perf_top__sort_new_samples(top); |
544 | |||
545 | /* | ||
546 | * Initialize the uid_filter_str, in the future the TUI will allow | ||
547 | * Zooming in/out UIDs. For now juse use whatever the user passed | ||
548 | * via --uid. | ||
549 | */ | ||
550 | list_for_each_entry(pos, &top->evlist->entries, node) | ||
551 | pos->hists.uid_filter_str = top->uid_str; | ||
552 | |||
544 | perf_evlist__tui_browse_hists(top->evlist, help, | 553 | perf_evlist__tui_browse_hists(top->evlist, help, |
545 | perf_top__sort_new_samples, | 554 | perf_top__sort_new_samples, |
546 | top, top->delay_secs); | 555 | top, top->delay_secs); |
@@ -949,7 +958,7 @@ static int __cmd_top(struct perf_top *top) | |||
949 | if (ret) | 958 | if (ret) |
950 | goto out_delete; | 959 | goto out_delete; |
951 | 960 | ||
952 | if (top->target_tid != -1) | 961 | if (top->target_tid != -1 || top->uid != UINT_MAX) |
953 | perf_event__synthesize_thread_map(&top->tool, top->evlist->threads, | 962 | perf_event__synthesize_thread_map(&top->tool, top->evlist->threads, |
954 | perf_event__process, | 963 | perf_event__process, |
955 | &top->session->host_machine); | 964 | &top->session->host_machine); |
@@ -1089,6 +1098,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) | |||
1089 | .delay_secs = 2, | 1098 | .delay_secs = 2, |
1090 | .target_pid = -1, | 1099 | .target_pid = -1, |
1091 | .target_tid = -1, | 1100 | .target_tid = -1, |
1101 | .uid = UINT_MAX, | ||
1092 | .freq = 1000, /* 1 KHz */ | 1102 | .freq = 1000, /* 1 KHz */ |
1093 | .sample_id_all_avail = true, | 1103 | .sample_id_all_avail = true, |
1094 | .mmap_pages = 128, | 1104 | .mmap_pages = 128, |
@@ -1162,6 +1172,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) | |||
1162 | "Display raw encoding of assembly instructions (default)"), | 1172 | "Display raw encoding of assembly instructions (default)"), |
1163 | OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style", | 1173 | OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style", |
1164 | "Specify disassembler style (e.g. -M intel for intel syntax)"), | 1174 | "Specify disassembler style (e.g. -M intel for intel syntax)"), |
1175 | OPT_STRING('u', "uid", &top.uid_str, "user", "user to profile"), | ||
1165 | OPT_END() | 1176 | OPT_END() |
1166 | }; | 1177 | }; |
1167 | 1178 | ||
@@ -1187,6 +1198,10 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) | |||
1187 | 1198 | ||
1188 | setup_browser(false); | 1199 | setup_browser(false); |
1189 | 1200 | ||
1201 | top.uid = parse_target_uid(top.uid_str, top.target_tid, top.target_pid); | ||
1202 | if (top.uid_str != NULL && top.uid == UINT_MAX - 1) | ||
1203 | goto out_delete_evlist; | ||
1204 | |||
1190 | /* CPU and PID are mutually exclusive */ | 1205 | /* CPU and PID are mutually exclusive */ |
1191 | if (top.target_tid > 0 && top.cpu_list) { | 1206 | if (top.target_tid > 0 && top.cpu_list) { |
1192 | printf("WARNING: PID switch overriding CPU\n"); | 1207 | printf("WARNING: PID switch overriding CPU\n"); |
@@ -1198,7 +1213,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) | |||
1198 | top.target_tid = top.target_pid; | 1213 | top.target_tid = top.target_pid; |
1199 | 1214 | ||
1200 | if (perf_evlist__create_maps(top.evlist, top.target_pid, | 1215 | if (perf_evlist__create_maps(top.evlist, top.target_pid, |
1201 | top.target_tid, top.cpu_list) < 0) | 1216 | top.target_tid, top.uid, top.cpu_list) < 0) |
1202 | usage_with_options(top_usage, options); | 1217 | usage_with_options(top_usage, options); |
1203 | 1218 | ||
1204 | if (!top.evlist->nr_entries && | 1219 | if (!top.evlist->nr_entries && |
@@ -1262,6 +1277,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) | |||
1262 | 1277 | ||
1263 | status = __cmd_top(&top); | 1278 | status = __cmd_top(&top); |
1264 | 1279 | ||
1280 | out_delete_evlist: | ||
1265 | perf_evlist__delete(top.evlist); | 1281 | perf_evlist__delete(top.evlist); |
1266 | 1282 | ||
1267 | return status; | 1283 | return status; |