aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-stat.c')
-rw-r--r--tools/perf/builtin-stat.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 2e03524a1de0..095a90e012a1 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -64,7 +64,7 @@ static struct perf_counter_attr default_attrs[] = {
64 64
65static int system_wide = 0; 65static int system_wide = 0;
66static int verbose = 0; 66static int verbose = 0;
67static int nr_cpus = 0; 67static unsigned int nr_cpus = 0;
68static int run_idx = 0; 68static int run_idx = 0;
69 69
70static int run_count = 1; 70static int run_count = 1;
@@ -108,7 +108,8 @@ static void create_perf_stat_counter(int counter, int pid)
108 PERF_FORMAT_TOTAL_TIME_RUNNING; 108 PERF_FORMAT_TOTAL_TIME_RUNNING;
109 109
110 if (system_wide) { 110 if (system_wide) {
111 int cpu; 111 unsigned int cpu;
112
112 for (cpu = 0; cpu < nr_cpus; cpu++) { 113 for (cpu = 0; cpu < nr_cpus; cpu++) {
113 fd[cpu][counter] = sys_perf_counter_open(attr, -1, cpu, -1, 0); 114 fd[cpu][counter] = sys_perf_counter_open(attr, -1, cpu, -1, 0);
114 if (fd[cpu][counter] < 0 && verbose) 115 if (fd[cpu][counter] < 0 && verbose)
@@ -150,8 +151,8 @@ static inline int nsec_counter(int counter)
150static void read_counter(int counter) 151static void read_counter(int counter)
151{ 152{
152 u64 *count, single_count[3]; 153 u64 *count, single_count[3];
153 ssize_t res; 154 unsigned int cpu;
154 int cpu, nv; 155 size_t res, nv;
155 int scaled; 156 int scaled;
156 157
157 count = event_res[run_idx][counter]; 158 count = event_res[run_idx][counter];
@@ -165,6 +166,7 @@ static void read_counter(int counter)
165 166
166 res = read(fd[cpu][counter], single_count, nv * sizeof(u64)); 167 res = read(fd[cpu][counter], single_count, nv * sizeof(u64));
167 assert(res == nv * sizeof(u64)); 168 assert(res == nv * sizeof(u64));
169
168 close(fd[cpu][counter]); 170 close(fd[cpu][counter]);
169 fd[cpu][counter] = -1; 171 fd[cpu][counter] = -1;
170 172
@@ -200,7 +202,7 @@ static void read_counter(int counter)
200 runtime_cycles[run_idx] = count[0]; 202 runtime_cycles[run_idx] = count[0];
201} 203}
202 204
203static int run_perf_stat(int argc, const char **argv) 205static int run_perf_stat(int argc __used, const char **argv)
204{ 206{
205 unsigned long long t0, t1; 207 unsigned long long t0, t1;
206 int status = 0; 208 int status = 0;
@@ -390,7 +392,7 @@ static void calc_avg(void)
390 event_res_avg[j]+1, event_res[i][j]+1); 392 event_res_avg[j]+1, event_res[i][j]+1);
391 update_avg("counter/2", j, 393 update_avg("counter/2", j,
392 event_res_avg[j]+2, event_res[i][j]+2); 394 event_res_avg[j]+2, event_res[i][j]+2);
393 if (event_scaled[i][j] != -1) 395 if (event_scaled[i][j] != (u64)-1)
394 update_avg("scaled", j, 396 update_avg("scaled", j,
395 event_scaled_avg + j, event_scaled[i]+j); 397 event_scaled_avg + j, event_scaled[i]+j);
396 else 398 else
@@ -510,7 +512,7 @@ static const struct option options[] = {
510 OPT_END() 512 OPT_END()
511}; 513};
512 514
513int cmd_stat(int argc, const char **argv, const char *prefix) 515int cmd_stat(int argc, const char **argv, const char *prefix __used)
514{ 516{
515 int status; 517 int status;
516 518
@@ -528,7 +530,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
528 530
529 nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); 531 nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
530 assert(nr_cpus <= MAX_NR_CPUS); 532 assert(nr_cpus <= MAX_NR_CPUS);
531 assert(nr_cpus >= 0); 533 assert((int)nr_cpus >= 0);
532 534
533 /* 535 /*
534 * We dont want to block the signals - that would cause 536 * We dont want to block the signals - that would cause