hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/tools/perf/bench/futex-hash.c
....@@ -18,13 +18,15 @@
1818 #include <stdlib.h>
1919 #include <linux/compiler.h>
2020 #include <linux/kernel.h>
21
+#include <linux/zalloc.h>
2122 #include <sys/time.h>
23
+#include <internal/cpumap.h>
24
+#include <perf/cpumap.h>
2225
2326 #include "../util/stat.h"
2427 #include <subcmd/parse-options.h>
2528 #include "bench.h"
2629 #include "futex.h"
27
-#include "cpumap.h"
2830
2931 #include <err.h>
3032
....@@ -123,7 +125,7 @@
123125 unsigned int i;
124126 pthread_attr_t thread_attr;
125127 struct worker *worker = NULL;
126
- struct cpu_map *cpu;
128
+ struct perf_cpu_map *cpu;
127129
128130 argc = parse_options(argc, argv, options, bench_futex_hash_usage, 0);
129131 if (argc) {
....@@ -131,10 +133,11 @@
131133 exit(EXIT_FAILURE);
132134 }
133135
134
- cpu = cpu_map__new(NULL);
136
+ cpu = perf_cpu_map__new(NULL);
135137 if (!cpu)
136138 goto errmem;
137139
140
+ memset(&act, 0, sizeof(act));
138141 sigfillset(&act.sa_mask);
139142 act.sa_sigaction = toggle_done;
140143 sigaction(SIGINT, &act, NULL);
....@@ -202,7 +205,8 @@
202205 pthread_mutex_destroy(&thread_lock);
203206
204207 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;
206210 update_stats(&throughput_stats, t);
207211 if (!silent) {
208212 if (nfutexes == 1)
....@@ -214,7 +218,7 @@
214218 &worker[i].futex[nfutexes-1], t);
215219 }
216220
217
- free(worker[i].futex);
221
+ zfree(&worker[i].futex);
218222 }
219223
220224 print_summary();