aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-stat.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 3840a70f05b7..3e5ea4e2e5fd 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -46,7 +46,7 @@
46#include <sys/prctl.h> 46#include <sys/prctl.h>
47#include <math.h> 47#include <math.h>
48 48
49static struct perf_counter_attr default_attrs[MAX_COUNTERS] = { 49static struct perf_counter_attr default_attrs[] = {
50 50
51 { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK }, 51 { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK },
52 { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CONTEXT_SWITCHES}, 52 { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CONTEXT_SWITCHES},
@@ -477,16 +477,17 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
477{ 477{
478 int status; 478 int status;
479 479
480 memcpy(attrs, default_attrs, sizeof(attrs));
481
482 argc = parse_options(argc, argv, options, stat_usage, 0); 480 argc = parse_options(argc, argv, options, stat_usage, 0);
483 if (!argc) 481 if (!argc)
484 usage_with_options(stat_usage, options); 482 usage_with_options(stat_usage, options);
485 if (run_count <= 0 || run_count > MAX_RUN) 483 if (run_count <= 0 || run_count > MAX_RUN)
486 usage_with_options(stat_usage, options); 484 usage_with_options(stat_usage, options);
487 485
488 if (!null_run && !nr_counters) 486 /* Set attrs and nr_counters if no event is selected and !null_run */
489 nr_counters = 8; 487 if (!null_run && !nr_counters) {
488 memcpy(attrs, default_attrs, sizeof(default_attrs));
489 nr_counters = ARRAY_SIZE(default_attrs);
490 }
490 491
491 nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); 492 nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
492 assert(nr_cpus <= MAX_NR_CPUS); 493 assert(nr_cpus <= MAX_NR_CPUS);