1 From decadad73858bc108828eed5540c7955dc2a977b Mon Sep 17 00:00:00 2001
2 From: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
3 Date: Fri, 7 Jun 2013 14:44:58 -0500
4 Subject: [PATCH 1/2] PowerPC: Change sched_getcpu to use vDSO getcpu instead of syscall.
6 Backport of d5e0b9bd6e296f3ec5263fa296d39f3fed9b8fa2 from master.
8 sysdeps/unix/sysv/linux/powerpc/Versions | 1 +
9 sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h | 2 +
10 sysdeps/unix/sysv/linux/powerpc/init-first.c | 3 ++
11 sysdeps/unix/sysv/linux/powerpc/sched_getcpu.c | 30 ++++++++++++++++++++++
12 4 files changed, 36 insertions(+), 0 deletions(-)
13 create mode 100644 sysdeps/unix/sysv/linux/powerpc/sched_getcpu.c
15 diff --git a/sysdeps/unix/sysv/linux/powerpc/Versions b/sysdeps/unix/sysv/linux/powerpc/Versions
16 index 1ef53b9..396a423 100644
17 --- a/sysdeps/unix/sysv/linux/powerpc/Versions
18 +++ b/sysdeps/unix/sysv/linux/powerpc/Versions
19 @@ -3,5 +3,6 @@ libc {
26 diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h b/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h
27 index 746d9ce..c3026d5 100644
28 --- a/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h
29 +++ b/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h
30 @@ -31,6 +31,8 @@ extern void *__vdso_clock_getres;
32 extern void *__vdso_get_tbfreq;
34 +extern void *__vdso_getcpu;
38 #endif /* _LIBC_VDSO_H */
39 diff --git a/sysdeps/unix/sysv/linux/powerpc/init-first.c b/sysdeps/unix/sysv/linux/powerpc/init-first.c
40 index 92dacc7..cfed655 100644
41 --- a/sysdeps/unix/sysv/linux/powerpc/init-first.c
42 +++ b/sysdeps/unix/sysv/linux/powerpc/init-first.c
43 @@ -27,6 +27,7 @@ void *__vdso_gettimeofday attribute_hidden;
44 void *__vdso_clock_gettime;
45 void *__vdso_clock_getres;
46 void *__vdso_get_tbfreq;
51 @@ -41,6 +42,8 @@ _libc_vdso_platform_setup (void)
52 __vdso_clock_getres = _dl_vdso_vsym ("__kernel_clock_getres", &linux2615);
54 __vdso_get_tbfreq = _dl_vdso_vsym ("__kernel_vdso_get_tbfreq", &linux2615);
56 + __vdso_getcpu = _dl_vdso_vsym ("__kernel_getcpu", &linux2615);
59 # define VDSO_SETUP _libc_vdso_platform_setup
60 diff --git a/sysdeps/unix/sysv/linux/powerpc/sched_getcpu.c b/sysdeps/unix/sysv/linux/powerpc/sched_getcpu.c
62 index 0000000..617e6f1
64 +++ b/sysdeps/unix/sysv/linux/powerpc/sched_getcpu.c
66 +/* Copyright (C) 2013 Free Software Foundation, Inc.
67 + This file is part of the GNU C Library.
69 + The GNU C Library is free software; you can redistribute it and/or
70 + modify it under the terms of the GNU Lesser General Public
71 + License as published by the Free Software Foundation; either
72 + version 2.1 of the License, or (at your option) any later version.
74 + The GNU C Library is distributed in the hope that it will be useful,
75 + but WITHOUT ANY WARRANTY; without even the implied warranty of
76 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
77 + Lesser General Public License for more details.
79 + You should have received a copy of the GNU Lesser General Public
80 + License along with the GNU C Library; if not, see
81 + <http://www.gnu.org/licenses/>. */
85 +#include <bits/libc-vdso.h>
92 + int r = INLINE_VSYSCALL (getcpu, 3, &cpu, NULL, NULL);
94 + return r == -1 ? r : cpu;