49 lines
1.2 KiB
Diff
49 lines
1.2 KiB
Diff
|
|
From 00bae0eb5212a1ec4e8b4b90294937903628e7ce Mon Sep 17 00:00:00 2001
|
||
|
|
From: Florian Weimer <fweimer@redhat.com>
|
||
|
|
Date: Thu, 9 Dec 2021 09:49:32 +0100
|
||
|
|
Subject: [PATCH 5/9] Linux: Use rseq to accelerate sched_getcpu
|
||
|
|
|
||
|
|
Co-Authored-By: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
|
||
|
|
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||
|
|
---
|
||
|
|
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 c41e986f..6f78edae 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 */
|
||
|
|
--
|
||
|
|
2.23.0
|
||
|
|
|