diff options
Diffstat (limited to 'tools/perf/builtin-top.c')
| -rw-r--r-- | tools/perf/builtin-top.c | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index a66f4272b994..b513e40974f4 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
| @@ -102,6 +102,7 @@ struct sym_entry *sym_filter_entry_sched = NULL; | |||
| 102 | static int sym_pcnt_filter = 5; | 102 | static int sym_pcnt_filter = 5; |
| 103 | static int sym_counter = 0; | 103 | static int sym_counter = 0; |
| 104 | static int display_weighted = -1; | 104 | static int display_weighted = -1; |
| 105 | static const char *cpu_list; | ||
| 105 | 106 | ||
| 106 | /* | 107 | /* |
| 107 | * Symbols | 108 | * Symbols |
| @@ -982,6 +983,7 @@ static void event__process_sample(const event_t *self, | |||
| 982 | u64 ip = self->ip.ip; | 983 | u64 ip = self->ip.ip; |
| 983 | struct sym_entry *syme; | 984 | struct sym_entry *syme; |
| 984 | struct addr_location al; | 985 | struct addr_location al; |
| 986 | struct sample_data data; | ||
| 985 | struct machine *machine; | 987 | struct machine *machine; |
| 986 | u8 origin = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | 988 | u8 origin = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; |
| 987 | 989 | ||
| @@ -1024,7 +1026,8 @@ static void event__process_sample(const event_t *self, | |||
| 1024 | if (self->header.misc & PERF_RECORD_MISC_EXACT_IP) | 1026 | if (self->header.misc & PERF_RECORD_MISC_EXACT_IP) |
| 1025 | exact_samples++; | 1027 | exact_samples++; |
| 1026 | 1028 | ||
| 1027 | if (event__preprocess_sample(self, session, &al, symbol_filter) < 0 || | 1029 | if (event__preprocess_sample(self, session, &al, &data, |
| 1030 | symbol_filter) < 0 || | ||
| 1028 | al.filtered) | 1031 | al.filtered) |
| 1029 | return; | 1032 | return; |
| 1030 | 1033 | ||
| @@ -1079,26 +1082,6 @@ static void event__process_sample(const event_t *self, | |||
| 1079 | } | 1082 | } |
| 1080 | } | 1083 | } |
| 1081 | 1084 | ||
| 1082 | static int event__process(event_t *event, struct perf_session *session) | ||
| 1083 | { | ||
| 1084 | switch (event->header.type) { | ||
| 1085 | case PERF_RECORD_COMM: | ||
| 1086 | event__process_comm(event, session); | ||
| 1087 | break; | ||
| 1088 | case PERF_RECORD_MMAP: | ||
| 1089 | event__process_mmap(event, session); | ||
| 1090 | break; | ||
| 1091 | case PERF_RECORD_FORK: | ||
| 1092 | case PERF_RECORD_EXIT: | ||
| 1093 | event__process_task(event, session); | ||
| 1094 | break; | ||
| 1095 | default: | ||
| 1096 | break; | ||
| 1097 | } | ||
| 1098 | |||
| 1099 | return 0; | ||
| 1100 | } | ||
| 1101 | |||
| 1102 | struct mmap_data { | 1085 | struct mmap_data { |
| 1103 | int counter; | 1086 | int counter; |
| 1104 | void *base; | 1087 | void *base; |
| @@ -1351,8 +1334,8 @@ static const struct option options[] = { | |||
| 1351 | "profile events on existing thread id"), | 1334 | "profile events on existing thread id"), |
| 1352 | OPT_BOOLEAN('a', "all-cpus", &system_wide, | 1335 | OPT_BOOLEAN('a', "all-cpus", &system_wide, |
| 1353 | "system-wide collection from all CPUs"), | 1336 | "system-wide collection from all CPUs"), |
| 1354 | OPT_INTEGER('C', "CPU", &profile_cpu, | 1337 | OPT_STRING('C', "cpu", &cpu_list, "cpu", |
| 1355 | "CPU to profile on"), | 1338 | "list of cpus to monitor"), |
| 1356 | OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, | 1339 | OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, |
| 1357 | "file", "vmlinux pathname"), | 1340 | "file", "vmlinux pathname"), |
| 1358 | OPT_BOOLEAN('K', "hide_kernel_symbols", &hide_kernel_symbols, | 1341 | OPT_BOOLEAN('K', "hide_kernel_symbols", &hide_kernel_symbols, |
| @@ -1428,10 +1411,10 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) | |||
| 1428 | return -ENOMEM; | 1411 | return -ENOMEM; |
| 1429 | 1412 | ||
| 1430 | /* CPU and PID are mutually exclusive */ | 1413 | /* CPU and PID are mutually exclusive */ |
| 1431 | if (target_tid > 0 && profile_cpu != -1) { | 1414 | if (target_tid > 0 && cpu_list) { |
| 1432 | printf("WARNING: PID switch overriding CPU\n"); | 1415 | printf("WARNING: PID switch overriding CPU\n"); |
| 1433 | sleep(1); | 1416 | sleep(1); |
| 1434 | profile_cpu = -1; | 1417 | cpu_list = NULL; |
| 1435 | } | 1418 | } |
| 1436 | 1419 | ||
| 1437 | if (!nr_counters) | 1420 | if (!nr_counters) |
| @@ -1469,10 +1452,13 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) | |||
| 1469 | attrs[counter].sample_period = default_interval; | 1452 | attrs[counter].sample_period = default_interval; |
| 1470 | } | 1453 | } |
| 1471 | 1454 | ||
| 1472 | if (target_tid != -1 || profile_cpu != -1) | 1455 | if (target_tid != -1) |
| 1473 | nr_cpus = 1; | 1456 | nr_cpus = 1; |
| 1474 | else | 1457 | else |
| 1475 | nr_cpus = read_cpu_map(); | 1458 | nr_cpus = read_cpu_map(cpu_list); |
| 1459 | |||
| 1460 | if (nr_cpus < 1) | ||
| 1461 | usage_with_options(top_usage, options); | ||
| 1476 | 1462 | ||
| 1477 | get_term_dimensions(&winsize); | 1463 | get_term_dimensions(&winsize); |
| 1478 | if (print_entries == 0) { | 1464 | if (print_entries == 0) { |
