Message ID | 20191129210327.26434-6-adhemerval.zanella@linaro.org |
---|---|
State | New |
Headers | show |
Series | [1/7] linux: Update x86 vDSO symbols | expand |
* Adhemerval Zanella: > diff --git a/sysdeps/unix/sysv/linux/sched_getcpu.c b/sysdeps/unix/sysv/linux/sched_getcpu.c > index 65dd9fdda7..3646c8b713 100644 > --- a/sysdeps/unix/sysv/linux/sched_getcpu.c > +++ b/sysdeps/unix/sysv/linux/sched_getcpu.c > @@ -17,23 +17,11 @@ > > #include <errno.h> > #include <sched.h> > -#include <sysdep.h> > - > -#ifdef HAVE_GETCPU_VSYSCALL > -# define HAVE_VSYSCALL > -#endif > -#include <sysdep-vdso.h> > > int > sched_getcpu (void) > { > -#ifdef __NR_getcpu > unsigned int cpu; > - int r = INLINE_VSYSCALL (getcpu, 3, &cpu, NULL, NULL); > - > + int r = __getcpu (&cpu, NULL); > return r == -1 ? r : cpu; > -#else > - __set_errno (ENOSYS); > - return -1; > -#endif > } I wonder if the current state is a useful performance optimization.
On 01/12/2019 11:22, Florian Weimer wrote: > * Adhemerval Zanella: > >> diff --git a/sysdeps/unix/sysv/linux/sched_getcpu.c b/sysdeps/unix/sysv/linux/sched_getcpu.c >> index 65dd9fdda7..3646c8b713 100644 >> --- a/sysdeps/unix/sysv/linux/sched_getcpu.c >> +++ b/sysdeps/unix/sysv/linux/sched_getcpu.c >> @@ -17,23 +17,11 @@ >> >> #include <errno.h> >> #include <sched.h> >> -#include <sysdep.h> >> - >> -#ifdef HAVE_GETCPU_VSYSCALL >> -# define HAVE_VSYSCALL >> -#endif >> -#include <sysdep-vdso.h> >> >> int >> sched_getcpu (void) >> { >> -#ifdef __NR_getcpu >> unsigned int cpu; >> - int r = INLINE_VSYSCALL (getcpu, 3, &cpu, NULL, NULL); >> - >> + int r = __getcpu (&cpu, NULL); >> return r == -1 ? r : cpu; >> -#else >> - __set_errno (ENOSYS); >> - return -1; >> -#endif >> } > > I wonder if the current state is a useful performance optimization. > I thought about that, another option would be to create an internal header with a static inline implementation where both sched_getcpu and getcpu will use and thus removing the function call overhead while continuing to provide only one code that issue the vDSO/syscall.
diff --git a/sysdeps/unix/sysv/linux/sched_getcpu.c b/sysdeps/unix/sysv/linux/sched_getcpu.c index 65dd9fdda7..3646c8b713 100644 --- a/sysdeps/unix/sysv/linux/sched_getcpu.c +++ b/sysdeps/unix/sysv/linux/sched_getcpu.c @@ -17,23 +17,11 @@ #include <errno.h> #include <sched.h> -#include <sysdep.h> - -#ifdef HAVE_GETCPU_VSYSCALL -# define HAVE_VSYSCALL -#endif -#include <sysdep-vdso.h> int sched_getcpu (void) { -#ifdef __NR_getcpu unsigned int cpu; - int r = INLINE_VSYSCALL (getcpu, 3, &cpu, NULL, NULL); - + int r = __getcpu (&cpu, NULL); return r == -1 ? r : cpu; -#else - __set_errno (ENOSYS); - return -1; -#endif }