.. | .. |
---|
18 | 18 | #include <stdlib.h> |
---|
19 | 19 | #include <linux/compiler.h> |
---|
20 | 20 | #include <linux/kernel.h> |
---|
| 21 | +#include <linux/zalloc.h> |
---|
21 | 22 | #include <sys/time.h> |
---|
| 23 | +#include <internal/cpumap.h> |
---|
| 24 | +#include <perf/cpumap.h> |
---|
22 | 25 | |
---|
23 | 26 | #include "../util/stat.h" |
---|
24 | 27 | #include <subcmd/parse-options.h> |
---|
25 | 28 | #include "bench.h" |
---|
26 | 29 | #include "futex.h" |
---|
27 | | -#include "cpumap.h" |
---|
28 | 30 | |
---|
29 | 31 | #include <err.h> |
---|
30 | 32 | |
---|
.. | .. |
---|
123 | 125 | unsigned int i; |
---|
124 | 126 | pthread_attr_t thread_attr; |
---|
125 | 127 | struct worker *worker = NULL; |
---|
126 | | - struct cpu_map *cpu; |
---|
| 128 | + struct perf_cpu_map *cpu; |
---|
127 | 129 | |
---|
128 | 130 | argc = parse_options(argc, argv, options, bench_futex_hash_usage, 0); |
---|
129 | 131 | if (argc) { |
---|
.. | .. |
---|
131 | 133 | exit(EXIT_FAILURE); |
---|
132 | 134 | } |
---|
133 | 135 | |
---|
134 | | - cpu = cpu_map__new(NULL); |
---|
| 136 | + cpu = perf_cpu_map__new(NULL); |
---|
135 | 137 | if (!cpu) |
---|
136 | 138 | goto errmem; |
---|
137 | 139 | |
---|
| 140 | + memset(&act, 0, sizeof(act)); |
---|
138 | 141 | sigfillset(&act.sa_mask); |
---|
139 | 142 | act.sa_sigaction = toggle_done; |
---|
140 | 143 | sigaction(SIGINT, &act, NULL); |
---|
.. | .. |
---|
202 | 205 | pthread_mutex_destroy(&thread_lock); |
---|
203 | 206 | |
---|
204 | 207 | for (i = 0; i < nthreads; i++) { |
---|
205 | | - unsigned long t = worker[i].ops / bench__runtime.tv_sec; |
---|
| 208 | + unsigned long t = bench__runtime.tv_sec > 0 ? |
---|
| 209 | + worker[i].ops / bench__runtime.tv_sec : 0; |
---|
206 | 210 | update_stats(&throughput_stats, t); |
---|
207 | 211 | if (!silent) { |
---|
208 | 212 | if (nfutexes == 1) |
---|
.. | .. |
---|
214 | 218 | &worker[i].futex[nfutexes-1], t); |
---|
215 | 219 | } |
---|
216 | 220 | |
---|
217 | | - free(worker[i].futex); |
---|
| 221 | + zfree(&worker[i].futex); |
---|
218 | 222 | } |
---|
219 | 223 | |
---|
220 | 224 | print_summary(); |
---|