mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-06 20:58:33 +01:00
Linux: Use rseq to accelerate sched_getcpu
Co-Authored-By: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
This commit is contained in:
parent
95e114a091
commit
1d350aa060
1 changed files with 17 additions and 2 deletions
|
@ -20,8 +20,8 @@
|
||||||
#include <sysdep.h>
|
#include <sysdep.h>
|
||||||
#include <sysdep-vdso.h>
|
#include <sysdep-vdso.h>
|
||||||
|
|
||||||
int
|
static int
|
||||||
sched_getcpu (void)
|
vsyscall_sched_getcpu (void)
|
||||||
{
|
{
|
||||||
unsigned int cpu;
|
unsigned int cpu;
|
||||||
int r = -1;
|
int r = -1;
|
||||||
|
@ -32,3 +32,18 @@ sched_getcpu (void)
|
||||||
#endif
|
#endif
|
||||||
return r == -1 ? r : cpu;
|
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 */
|
||||||
|
|
Loading…
Add table
Reference in a new issue