This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Add getcpu
* H. J. Lu:
> +* The getcpu wrapper function has been added, which returns currently
> + used CPU and NUMA node. This function is Linux-specific.
“returns the currently used” (not sure)?
> diff --git a/sysdeps/unix/sysv/linux/tst-skeleton-affinity.c b/sysdeps/unix/sysv/linux/tst-skeleton-affinity.c
> index 695c1ccdbd..fd1357beb1 100644
> --- a/sysdeps/unix/sysv/linux/tst-skeleton-affinity.c
> +++ b/sysdeps/unix/sysv/linux/tst-skeleton-affinity.c
> @@ -165,6 +165,18 @@ test_size (const struct conf *conf, size_t size)
> for (int cpu = 0; cpu <= conf->last_cpu; ++cpu)
> {
> int active_cpu = sched_getcpu ();
> + unsigned int numa_cpu, numa_node;
> + if (getcpu (&numa_cpu, &numa_node))
!= NULL
> + {
> + printf ("error: getcpu: %m\n");
> + return false;
Okay, ENOSYS is a hard error here because we have checked for a working
sched_getcpu.
> + }
> + if ((unsigned int) active_cpu != numa_cpu)
> + {
> + printf ("error: Unexpected CPU %d, expected %d\n",
> + active_cpu, numa_cpu);
> + return false;
> + }
> if (last_active_cpu >= 0 && last_active_cpu != active_cpu)
I think you need to move the getcpu call and this check down further,
after the setaffinity call with a single-element CPU set.
Thanks,
Florian