diff options
-rw-r--r-- | tools/perf/builtin-stat.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 6d3eeac1ea25..5e04fcc8d077 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -109,6 +109,10 @@ static u64 walltime_nsecs_noise; | |||
109 | static u64 runtime_cycles_avg; | 109 | static u64 runtime_cycles_avg; |
110 | static u64 runtime_cycles_noise; | 110 | static u64 runtime_cycles_noise; |
111 | 111 | ||
112 | |||
113 | #define ERR_PERF_OPEN \ | ||
114 | "Error: counter %d, sys_perf_counter_open() syscall returned with %d (%s)\n" | ||
115 | |||
112 | static void create_perf_stat_counter(int counter) | 116 | static void create_perf_stat_counter(int counter) |
113 | { | 117 | { |
114 | struct perf_counter_attr *attr = attrs + counter; | 118 | struct perf_counter_attr *attr = attrs + counter; |
@@ -119,20 +123,20 @@ static void create_perf_stat_counter(int counter) | |||
119 | 123 | ||
120 | if (system_wide) { | 124 | if (system_wide) { |
121 | int cpu; | 125 | int cpu; |
122 | for (cpu = 0; cpu < nr_cpus; cpu ++) { | 126 | for (cpu = 0; cpu < nr_cpus; cpu++) { |
123 | fd[cpu][counter] = sys_perf_counter_open(attr, -1, cpu, -1, 0); | 127 | fd[cpu][counter] = sys_perf_counter_open(attr, -1, cpu, -1, 0); |
124 | if (fd[cpu][counter] < 0 && verbose) { | 128 | if (fd[cpu][counter] < 0 && verbose) |
125 | printf("Error: counter %d, sys_perf_counter_open() syscall returned with %d (%s)\n", counter, fd[cpu][counter], strerror(errno)); | 129 | fprintf(stderr, ERR_PERF_OPEN, counter, |
126 | } | 130 | fd[cpu][counter], strerror(errno)); |
127 | } | 131 | } |
128 | } else { | 132 | } else { |
129 | attr->inherit = inherit; | 133 | attr->inherit = inherit; |
130 | attr->disabled = 1; | 134 | attr->disabled = 1; |
131 | 135 | ||
132 | fd[0][counter] = sys_perf_counter_open(attr, 0, -1, -1, 0); | 136 | fd[0][counter] = sys_perf_counter_open(attr, 0, -1, -1, 0); |
133 | if (fd[0][counter] < 0 && verbose) { | 137 | if (fd[0][counter] < 0 && verbose) |
134 | printf("Error: counter %d, sys_perf_counter_open() syscall returned with %d (%s)\n", counter, fd[0][counter], strerror(errno)); | 138 | fprintf(stderr, ERR_PERF_OPEN, counter, |
135 | } | 139 | fd[0][counter], strerror(errno)); |
136 | } | 140 | } |
137 | } | 141 | } |
138 | 142 | ||
@@ -168,7 +172,7 @@ static void read_counter(int counter) | |||
168 | count[0] = count[1] = count[2] = 0; | 172 | count[0] = count[1] = count[2] = 0; |
169 | 173 | ||
170 | nv = scale ? 3 : 1; | 174 | nv = scale ? 3 : 1; |
171 | for (cpu = 0; cpu < nr_cpus; cpu ++) { | 175 | for (cpu = 0; cpu < nr_cpus; cpu++) { |
172 | if (fd[cpu][counter] < 0) | 176 | if (fd[cpu][counter] < 0) |
173 | continue; | 177 | continue; |
174 | 178 | ||