.. | .. |
---|
12 | 12 | #include <subcmd/parse-options.h> |
---|
13 | 13 | #include <linux/compiler.h> |
---|
14 | 14 | #include <linux/kernel.h> |
---|
| 15 | +#include <linux/zalloc.h> |
---|
15 | 16 | #include <errno.h> |
---|
| 17 | +#include <internal/cpumap.h> |
---|
| 18 | +#include <perf/cpumap.h> |
---|
16 | 19 | #include "bench.h" |
---|
17 | 20 | #include "futex.h" |
---|
18 | | -#include "cpumap.h" |
---|
19 | 21 | |
---|
20 | 22 | #include <err.h> |
---|
21 | 23 | #include <stdlib.h> |
---|
.. | .. |
---|
114 | 116 | } |
---|
115 | 117 | |
---|
116 | 118 | static void create_threads(struct worker *w, pthread_attr_t thread_attr, |
---|
117 | | - struct cpu_map *cpu) |
---|
| 119 | + struct perf_cpu_map *cpu) |
---|
118 | 120 | { |
---|
119 | 121 | cpu_set_t cpuset; |
---|
120 | 122 | unsigned int i; |
---|
.. | .. |
---|
148 | 150 | unsigned int i; |
---|
149 | 151 | struct sigaction act; |
---|
150 | 152 | pthread_attr_t thread_attr; |
---|
151 | | - struct cpu_map *cpu; |
---|
| 153 | + struct perf_cpu_map *cpu; |
---|
152 | 154 | |
---|
153 | 155 | argc = parse_options(argc, argv, options, bench_futex_lock_pi_usage, 0); |
---|
154 | 156 | if (argc) |
---|
155 | 157 | goto err; |
---|
156 | 158 | |
---|
157 | | - cpu = cpu_map__new(NULL); |
---|
| 159 | + cpu = perf_cpu_map__new(NULL); |
---|
158 | 160 | if (!cpu) |
---|
159 | 161 | err(EXIT_FAILURE, "calloc"); |
---|
160 | 162 | |
---|
| 163 | + memset(&act, 0, sizeof(act)); |
---|
161 | 164 | sigfillset(&act.sa_mask); |
---|
162 | 165 | act.sa_sigaction = toggle_done; |
---|
163 | 166 | sigaction(SIGINT, &act, NULL); |
---|
.. | .. |
---|
208 | 211 | pthread_mutex_destroy(&thread_lock); |
---|
209 | 212 | |
---|
210 | 213 | for (i = 0; i < nthreads; i++) { |
---|
211 | | - unsigned long t = worker[i].ops / bench__runtime.tv_sec; |
---|
| 214 | + unsigned long t = bench__runtime.tv_sec > 0 ? |
---|
| 215 | + worker[i].ops / bench__runtime.tv_sec : 0; |
---|
212 | 216 | |
---|
213 | 217 | update_stats(&throughput_stats, t); |
---|
214 | 218 | if (!silent) |
---|
.. | .. |
---|
216 | 220 | worker[i].tid, worker[i].futex, t); |
---|
217 | 221 | |
---|
218 | 222 | if (multi) |
---|
219 | | - free(worker[i].futex); |
---|
| 223 | + zfree(&worker[i].futex); |
---|
220 | 224 | } |
---|
221 | 225 | |
---|
222 | 226 | print_summary(); |
---|
223 | 227 | |
---|
224 | 228 | free(worker); |
---|
| 229 | + perf_cpu_map__put(cpu); |
---|
225 | 230 | return ret; |
---|
226 | 231 | err: |
---|
227 | 232 | usage_with_options(bench_futex_lock_pi_usage, options); |
---|