[PATCH v2 5/6] perf tool: Allow system-wide 'perf stat' without 'command'

From: Lin Ming
Date: Fri Jul 15 2011 - 10:31:25 EST


There are package level counters, for example Intel uncore counters,
can't be limited to process. So we should allow 'perf stat' to run without 'command'.

$ sudo perf stat -a -C 0 -e uncore:cycle
^C
Performance counter stats for 'CPU 0':

56,547,314 uncore:cycle

Signed-off-by: Lin Ming <ming.m.lin@xxxxxxxxx>
---
tools/perf/builtin-stat.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 1d08c80..84546ff 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -958,7 +958,14 @@ static void print_stat(int argc, const char **argv)
if (!csv_output) {
fprintf(stderr, "\n");
fprintf(stderr, " Performance counter stats for ");
- if(target_pid == -1 && target_tid == -1) {
+ if (system_wide) {
+ fprintf(stderr, "\'CPU ");
+ for (i = 0; i < evsel_list->cpus->nr; i++) {
+ fprintf(stderr, "%d", evsel_list->cpus->map[i]);
+ if (i < evsel_list->cpus->nr - 1)
+ fprintf(stderr, ",");
+ }
+ } else if (target_pid == -1 && target_tid == -1) {
fprintf(stderr, "\'%s", argv[0]);
for (i = 1; i < argc; i++)
fprintf(stderr, " %s", argv[i]);
@@ -1166,7 +1173,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
} else if (big_num_opt == 0) /* User passed --no-big-num */
big_num = false;

- if (!argc && target_pid == -1 && target_tid == -1)
+ if (!system_wide && !argc && target_pid == -1 && target_tid == -1)
usage_with_options(stat_usage, options);
if (run_count <= 0)
usage_with_options(stat_usage, options);
--
1.7.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/