hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/tools/perf/bench/futex-lock-pi.c
....@@ -12,10 +12,12 @@
1212 #include <subcmd/parse-options.h>
1313 #include <linux/compiler.h>
1414 #include <linux/kernel.h>
15
+#include <linux/zalloc.h>
1516 #include <errno.h>
17
+#include <internal/cpumap.h>
18
+#include <perf/cpumap.h>
1619 #include "bench.h"
1720 #include "futex.h"
18
-#include "cpumap.h"
1921
2022 #include <err.h>
2123 #include <stdlib.h>
....@@ -114,7 +116,7 @@
114116 }
115117
116118 static void create_threads(struct worker *w, pthread_attr_t thread_attr,
117
- struct cpu_map *cpu)
119
+ struct perf_cpu_map *cpu)
118120 {
119121 cpu_set_t cpuset;
120122 unsigned int i;
....@@ -148,16 +150,17 @@
148150 unsigned int i;
149151 struct sigaction act;
150152 pthread_attr_t thread_attr;
151
- struct cpu_map *cpu;
153
+ struct perf_cpu_map *cpu;
152154
153155 argc = parse_options(argc, argv, options, bench_futex_lock_pi_usage, 0);
154156 if (argc)
155157 goto err;
156158
157
- cpu = cpu_map__new(NULL);
159
+ cpu = perf_cpu_map__new(NULL);
158160 if (!cpu)
159161 err(EXIT_FAILURE, "calloc");
160162
163
+ memset(&act, 0, sizeof(act));
161164 sigfillset(&act.sa_mask);
162165 act.sa_sigaction = toggle_done;
163166 sigaction(SIGINT, &act, NULL);
....@@ -208,7 +211,8 @@
208211 pthread_mutex_destroy(&thread_lock);
209212
210213 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;
212216
213217 update_stats(&throughput_stats, t);
214218 if (!silent)
....@@ -216,12 +220,13 @@
216220 worker[i].tid, worker[i].futex, t);
217221
218222 if (multi)
219
- free(worker[i].futex);
223
+ zfree(&worker[i].futex);
220224 }
221225
222226 print_summary();
223227
224228 free(worker);
229
+ perf_cpu_map__put(cpu);
225230 return ret;
226231 err:
227232 usage_with_options(bench_futex_lock_pi_usage, options);