[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241115172035.795842-10-bigeasy@linutronix.de>
Date: Fri, 15 Nov 2024 17:58:50 +0100
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: linux-kernel@...r.kernel.org
Cc: André Almeida <andrealmeid@...lia.com>,
Darren Hart <dvhart@...radead.org>,
Davidlohr Bueso <dave@...olabs.net>,
Ingo Molnar <mingo@...hat.com>,
Juri Lelli <juri.lelli@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Valentin Schneider <vschneid@...hat.com>,
Waiman Long <longman@...hat.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Subject: [RFC PATCH v3 9/9] tools/perf: Allocate futex locks on the local CPU-node.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
---
tools/perf/bench/futex-hash.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c
index f40b7df6ef3d0..7c8f3cff3c611 100644
--- a/tools/perf/bench/futex-hash.c
+++ b/tools/perf/bench/futex-hash.c
@@ -122,6 +122,8 @@ static void print_summary(void)
(int)bench__runtime.tv_sec);
}
+#include <numa.h>
+
#define PR_FUTEX_HASH 74
# define PR_FUTEX_HASH_SET_SLOTS 1
# define PR_FUTEX_HASH_GET_SLOTS 2
@@ -212,14 +214,19 @@ int bench_futex_hash(int argc, const char **argv)
size = CPU_ALLOC_SIZE(4096);
for (i = 0; i < params.nthreads; i++) {
+ unsigned int cpu_num;
worker[i].tid = i;
- worker[i].futex = calloc(params.nfutexes, sizeof(*worker[i].futex));
- if (!worker[i].futex)
- goto errmem;
CPU_ZERO_S(size, cpuset);
+ cpu_num = get_cpu_bit(&cpuset_, sizeof(cpuset_), i % nrcpus);
+ //worker[i].futex = calloc(params.nfutexes, sizeof(*worker[i].futex));
- CPU_SET_S(get_cpu_bit(&cpuset_, sizeof(cpuset_), i % nrcpus), size, cpuset);
+ worker[i].futex = numa_alloc_onnode(params.nfutexes * sizeof(*worker[i].futex),
+ numa_node_of_cpu(cpu_num));
+ if (worker[i].futex == MAP_FAILED || worker[i].futex == NULL)
+ goto errmem;
+
+ CPU_SET_S(cpu_num, size, cpuset);
ret = pthread_attr_setaffinity_np(&thread_attr, size, cpuset);
if (ret) {
@@ -271,7 +278,7 @@ int bench_futex_hash(int argc, const char **argv)
&worker[i].futex[params.nfutexes-1], t);
}
- zfree(&worker[i].futex);
+ numa_free(worker[i].futex, params.nfutexes * sizeof(*worker[i].futex));
}
print_summary();
--
2.45.2
Powered by blists - more mailing lists