From: Daniel Wagner <dwagner@suse.de>
To: Clark Williams <williams@redhat.com>, John Kacur <jkacur@redhat.com>
Cc: linux-rt-users@vger.kernel.org, Daniel Wagner <dwagner@suse.de>
Subject: [PATCH rt-tests v3 1/1] rt-numa: Use sched_getaffinity() instead of pthread_getaffinity_np()
Date: Mon, 19 Jul 2021 10:15:05 +0200 [thread overview]
Message-ID: <20210719081505.520-2-dwagner@suse.de> (raw)
In-Reply-To: <20210719081505.520-1-dwagner@suse.de>
pthread_getaffinity_np() prevents static builds as glibc does not
expose it for this configuration. Instead use sched_getaffinity()
directly as pthread_getaffinity_np() is just a fancy glibc wrapper
around sched_getaffinity().
Static builds helps in in situation where the rootfs is minimal
and does for example not ship libnuma.
The pthread_getaffinity_np call was introduced by commit
f240656b056b ("rt-tests: cyclictest: Fix -t without a user specified
[NUM]")
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
src/lib/rt-numa.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c
index babcc634d57e..bb0121a65eca 100644
--- a/src/lib/rt-numa.c
+++ b/src/lib/rt-numa.c
@@ -68,15 +68,13 @@ 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));
+ fatal("sched_getaffinity failed: %s\n", strerror(res));
num_cpus = CPU_COUNT(&cpuset);
m = thread_num % num_cpus;
--
2.32.0
next prev parent reply other threads:[~2021-07-19 9:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-19 8:15 [PATCH rt-tests v3 0/1] Fix a few fallouts Daniel Wagner
2021-07-19 8:15 ` Daniel Wagner [this message]
2021-08-27 7:31 ` [PATCH rt-tests v3 1/1] rt-numa: Use sched_getaffinity() instead of pthread_getaffinity_np() Daniel Wagner
2021-08-27 17:09 ` John Kacur
2021-08-29 19:58 ` Daniel Wagner
2021-08-30 12:54 ` John Kacur
2021-08-30 13:10 ` Daniel Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210719081505.520-2-dwagner@suse.de \
--to=dwagner@suse.de \
--cc=jkacur@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=williams@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.