public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] Linux: Use rseq to accelerate sched_getcpu
@ 2021-12-09  8:50 Florian Weimer
  0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2021-12-09  8:50 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1d350aa06091211863e41169729cee1bca39f72f

commit 1d350aa06091211863e41169729cee1bca39f72f
Author: Florian Weimer <fweimer@redhat.com>
Date:   Thu Dec 9 09:49:32 2021 +0100

    Linux: Use rseq to accelerate sched_getcpu
    
    Co-Authored-By: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
    Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>

Diff:
---
 sysdeps/unix/sysv/linux/sched_getcpu.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/sched_getcpu.c b/sysdeps/unix/sysv/linux/sched_getcpu.c
index c41e986f2c..6f78edaea1 100644
--- a/sysdeps/unix/sysv/linux/sched_getcpu.c
+++ b/sysdeps/unix/sysv/linux/sched_getcpu.c
@@ -20,8 +20,8 @@
 #include <sysdep.h>
 #include <sysdep-vdso.h>
 
-int
-sched_getcpu (void)
+static int
+vsyscall_sched_getcpu (void)
 {
   unsigned int cpu;
   int r = -1;
@@ -32,3 +32,18 @@ sched_getcpu (void)
 #endif
   return r == -1 ? r : cpu;
 }
+
+#ifdef RSEQ_SIG
+int
+sched_getcpu (void)
+{
+  int cpu_id = THREAD_GETMEM_VOLATILE (THREAD_SELF, rseq_area.cpu_id);
+  return __glibc_likely (cpu_id >= 0) ? cpu_id : vsyscall_sched_getcpu ();
+}
+#else /* RSEQ_SIG */
+int
+sched_getcpu (void)
+{
+  return vsyscall_sched_getcpu ();
+}
+#endif /* RSEQ_SIG */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-09  8:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09  8:50 [glibc] Linux: Use rseq to accelerate sched_getcpu Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).