diff options
author | David Ahern <dsahern@gmail.com> | 2012-02-08 11:32:52 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-02-13 19:54:11 -0500 |
commit | b52956c961be3a04182ae7b776623531601e0fb7 (patch) | |
tree | 2f7ebf4a910dc8cd9014ac9df59f7e2441a5b034 /tools/perf/builtin-stat.c | |
parent | eca1c3e3f937307331fd1fd5ee5205e57f2131ca (diff) |
perf tools: Allow multiple threads or processes in record, stat, top
Allow a user to collect events for multiple threads or processes
using a comma separated list.
e.g., collect data on a VM and its vhost thread:
perf top -p 21483,21485
perf stat -p 21483,21485 -ddd
perf record -p 21483,21485
or monitoring vcpu threads
perf top -t 21488,21489
perf stat -t 21488,21489 -ddd
perf record -t 21488,21489
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1328718772-16688-1-git-send-email-dsahern@gmail.com
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-stat.c')
-rw-r--r-- | tools/perf/builtin-stat.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index d14b37ad7638..ea40e4e8b227 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -182,8 +182,8 @@ static int run_count = 1; | |||
182 | static bool no_inherit = false; | 182 | static bool no_inherit = false; |
183 | static bool scale = true; | 183 | static bool scale = true; |
184 | static bool no_aggr = false; | 184 | static bool no_aggr = false; |
185 | static pid_t target_pid = -1; | 185 | static const char *target_pid; |
186 | static pid_t target_tid = -1; | 186 | static const char *target_tid; |
187 | static pid_t child_pid = -1; | 187 | static pid_t child_pid = -1; |
188 | static bool null_run = false; | 188 | static bool null_run = false; |
189 | static int detailed_run = 0; | 189 | static int detailed_run = 0; |
@@ -296,7 +296,7 @@ static int create_perf_stat_counter(struct perf_evsel *evsel, | |||
296 | if (system_wide) | 296 | if (system_wide) |
297 | return perf_evsel__open_per_cpu(evsel, evsel_list->cpus, | 297 | return perf_evsel__open_per_cpu(evsel, evsel_list->cpus, |
298 | group, group_fd); | 298 | group, group_fd); |
299 | if (target_pid == -1 && target_tid == -1) { | 299 | if (!target_pid && !target_tid) { |
300 | attr->disabled = 1; | 300 | attr->disabled = 1; |
301 | attr->enable_on_exec = 1; | 301 | attr->enable_on_exec = 1; |
302 | } | 302 | } |
@@ -446,7 +446,7 @@ static int run_perf_stat(int argc __used, const char **argv) | |||
446 | exit(-1); | 446 | exit(-1); |
447 | } | 447 | } |
448 | 448 | ||
449 | if (target_tid == -1 && target_pid == -1 && !system_wide) | 449 | if (!target_tid && !target_pid && !system_wide) |
450 | evsel_list->threads->map[0] = child_pid; | 450 | evsel_list->threads->map[0] = child_pid; |
451 | 451 | ||
452 | /* | 452 | /* |
@@ -968,14 +968,14 @@ static void print_stat(int argc, const char **argv) | |||
968 | if (!csv_output) { | 968 | if (!csv_output) { |
969 | fprintf(output, "\n"); | 969 | fprintf(output, "\n"); |
970 | fprintf(output, " Performance counter stats for "); | 970 | fprintf(output, " Performance counter stats for "); |
971 | if(target_pid == -1 && target_tid == -1) { | 971 | if (!target_pid && !target_tid) { |
972 | fprintf(output, "\'%s", argv[0]); | 972 | fprintf(output, "\'%s", argv[0]); |
973 | for (i = 1; i < argc; i++) | 973 | for (i = 1; i < argc; i++) |
974 | fprintf(output, " %s", argv[i]); | 974 | fprintf(output, " %s", argv[i]); |
975 | } else if (target_pid != -1) | 975 | } else if (target_pid) |
976 | fprintf(output, "process id \'%d", target_pid); | 976 | fprintf(output, "process id \'%s", target_pid); |
977 | else | 977 | else |
978 | fprintf(output, "thread id \'%d", target_tid); | 978 | fprintf(output, "thread id \'%s", target_tid); |
979 | 979 | ||
980 | fprintf(output, "\'"); | 980 | fprintf(output, "\'"); |
981 | if (run_count > 1) | 981 | if (run_count > 1) |
@@ -1049,10 +1049,10 @@ static const struct option options[] = { | |||
1049 | "event filter", parse_filter), | 1049 | "event filter", parse_filter), |
1050 | OPT_BOOLEAN('i', "no-inherit", &no_inherit, | 1050 | OPT_BOOLEAN('i', "no-inherit", &no_inherit, |
1051 | "child tasks do not inherit counters"), | 1051 | "child tasks do not inherit counters"), |
1052 | OPT_INTEGER('p', "pid", &target_pid, | 1052 | OPT_STRING('p', "pid", &target_pid, "pid", |
1053 | "stat events on existing process id"), | 1053 | "stat events on existing process id"), |
1054 | OPT_INTEGER('t', "tid", &target_tid, | 1054 | OPT_STRING('t', "tid", &target_tid, "tid", |
1055 | "stat events on existing thread id"), | 1055 | "stat events on existing thread id"), |
1056 | OPT_BOOLEAN('a', "all-cpus", &system_wide, | 1056 | OPT_BOOLEAN('a', "all-cpus", &system_wide, |
1057 | "system-wide collection from all CPUs"), | 1057 | "system-wide collection from all CPUs"), |
1058 | OPT_BOOLEAN('g', "group", &group, | 1058 | OPT_BOOLEAN('g', "group", &group, |
@@ -1190,7 +1190,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used) | |||
1190 | } else if (big_num_opt == 0) /* User passed --no-big-num */ | 1190 | } else if (big_num_opt == 0) /* User passed --no-big-num */ |
1191 | big_num = false; | 1191 | big_num = false; |
1192 | 1192 | ||
1193 | if (!argc && target_pid == -1 && target_tid == -1) | 1193 | if (!argc && !target_pid && !target_tid) |
1194 | usage_with_options(stat_usage, options); | 1194 | usage_with_options(stat_usage, options); |
1195 | if (run_count <= 0) | 1195 | if (run_count <= 0) |
1196 | usage_with_options(stat_usage, options); | 1196 | usage_with_options(stat_usage, options); |
@@ -1206,10 +1206,11 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used) | |||
1206 | if (add_default_attributes()) | 1206 | if (add_default_attributes()) |
1207 | goto out; | 1207 | goto out; |
1208 | 1208 | ||
1209 | if (target_pid != -1) | 1209 | if (target_pid) |
1210 | target_tid = target_pid; | 1210 | target_tid = target_pid; |
1211 | 1211 | ||
1212 | evsel_list->threads = thread_map__new(target_pid, target_tid, UINT_MAX); | 1212 | evsel_list->threads = thread_map__new_str(target_pid, |
1213 | target_tid, UINT_MAX); | ||
1213 | if (evsel_list->threads == NULL) { | 1214 | if (evsel_list->threads == NULL) { |
1214 | pr_err("Problems finding threads of monitor\n"); | 1215 | pr_err("Problems finding threads of monitor\n"); |
1215 | usage_with_options(stat_usage, options); | 1216 | usage_with_options(stat_usage, options); |