diff mbox series

[rt-tests,v1,1/3] rt-numa: Use sched_getaffinity() instead of pthread_getaffinity_np()

Message ID 20210704203621.5612-2-wagi@monom.org
State New
Headers show
Series Fix a few fallouts | expand

Commit Message

Daniel Wagner July 4, 2021, 8:36 p.m. UTC
From: Daniel Wagner <dwagner@suse.de>


pthread_getaffinity_np() prevents static builds as glibc does not
expose it for this configuration. Instead use sched_getaffinity()
which is always present and has the exact same semantics.

Fixes: f240656b056b ("rt-tests: cyclictest: Fix -t without a user specified [NUM]")

Signed-off-by: Daniel Wagner <dwagner@suse.de>

---
 src/lib/rt-numa.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

-- 
2.32.0
diff mbox series

Patch

diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c
index babcc634d57e..2d34ae36cc03 100644
--- a/src/lib/rt-numa.c
+++ b/src/lib/rt-numa.c
@@ -68,13 +68,11 @@  int cpu_for_thread_sp(int thread_num, int max_cpus, struct bitmask *cpumask)
 int cpu_for_thread_ua(int thread_num, int max_cpus)
 {
 	int res, num_cpus, i, m, cpu;
-	pthread_t thread;
 	cpu_set_t cpuset;
 
-	thread = pthread_self();
 	CPU_ZERO(&cpuset);
 
-	res = pthread_getaffinity_np(thread, sizeof(cpu_set_t), &cpuset);
+	res = sched_getaffinity(0, sizeof(cpu_set_t), &cpuset);
 	if (res != 0)
 		fatal("pthread_getaffinity_np failed: %s\n", strerror(res));