Re: [PATCH rt-tests v2 1/3] rt-numa: Use sched_getaffinity() instead of pthread_getaffinity_np()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Thu, 8 Jul 2021, Daniel Wagner wrote:

> 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@xxxxxxx>
> ---
>  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
> 
> 

It looks okay on the surface but I would like to know where you tested.

Also, in your message you explain that you can't do a static build
but we never made static builds a requirment for rt-tests. I know from
your cover letter than you are trying to do something with arm, if this
is your motivation you should put it in your message. Even if this is your 
motivation is there a reason we have to have a static build there?

Finally, you put "fixes f240656b056b", it is useful to know where this
was introduced in trying to figure out whether we can really replace a 
pthread call with the sched call, but then phrase it that way, because
as far as I know that commit is not a problem needing fixing, so put
"pthread_getaffinity_np call introduced in f240656b056b"
or something like that.

Thanks

John




[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux