lkml.org 
[lkml]   [2020]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH glibc 6/9] glibc: sched_getcpu(): use rseq cpu_id TLS on Linux (v7)
Date
* Mathieu Desnoyers via Libc-alpha:

> diff --git a/sysdeps/unix/sysv/linux/sched_getcpu.c b/sysdeps/unix/sysv/linux/sched_getcpu.c
> index c019cfb3cf..2269c4f2bd 100644
> --- a/sysdeps/unix/sysv/linux/sched_getcpu.c
> +++ b/sysdeps/unix/sysv/linux/sched_getcpu.c
> @@ -18,10 +18,15 @@
> #include <errno.h>
> #include <sched.h>
> #include <sysdep.h>
> +#include <atomic.h>
> #include <sysdep-vdso.h>
>
> -int
> -sched_getcpu (void)
> +#ifdef HAVE_GETCPU_VSYSCALL
> +# define HAVE_VSYSCALL
> +#endif
> +
> +static int
> +vsyscall_sched_getcpu (void)
> {
> unsigned int cpu;
> int r = -1;
> @@ -32,3 +37,21 @@ sched_getcpu (void)
> #endif
> return r == -1 ? r : cpu;
> }
> +
> +#include <sys/rseq.h>
> +
> +#ifdef RSEQ_SIG
> +int
> +sched_getcpu (void)
> +{
> + int cpu_id = atomic_load_relaxed (&__rseq_abi.cpu_id);
> +
> + return cpu_id >= 0 ? cpu_id : vsyscall_sched_getcpu ();
> +}
> +#else
> +int
> +sched_getcpu (void)
> +{
> + return vsyscall_sched_getcpu ();
> +}
> +#endif

This patch needs to be rebased on current master, but the direction
looks right to me.

\
 
 \ /
  Last update: 2020-04-27 11:14    [W:0.027 / U:7.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site