perf tools: Introduce weak alternative to sched_getcpu()
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: c7007e983682b31d91e9ad7c3e85c49ffcc3651f Gitweb: http://git.kernel.org/tip/c7007e983682b31d91e9ad7c3e85c49ffcc3651f Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Tue, 12 Jul 2016 10:29:31 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 12 Jul 2016 15:20:34 -0300
perf tools: Introduce weak alternative to sched_getcpu()
Which is just a wrapper for sys_getcpu and is not present in at least musl libc.
Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/arch/x86/include/asm/unistd_32.h | 3 +++ tools/arch/x86/include/asm/unistd_64.h | 3 +++ tools/perf/util/cloexec.c | 14 ++++++++++---- tools/perf/util/util.h | 4 ++++ 4 files changed, 20 insertions(+), 4 deletions(-)
tools/arch/x86/include/asm/unistd_32.h +3 -0
@@ -7,3 +7,6 @@#ifndef __NR_gettid# define __NR_gettid 224#endif +#ifndef __NR_getcpu +# define __NR_getcpu 318 +#endif
tools/arch/x86/include/asm/unistd_64.h +3 -0
@@ -7,3 +7,6 @@#ifndef __NR_gettid# define __NR_gettid 186#endif +#ifndef __NR_getcpu +# define __NR_getcpu 309 +#endif
tools/perf/util/cloexec.c +10 -4
@@ -4,18 +4,24 @@#include "cloexec.h" #include "asm/bug.h" #include "debug.h" +#include <unistd.h> +#include <asm/unistd.h> +#include <sys/syscall.h> static unsigned long flag =PERF_FLAG_FD_CLOEXEC ; -#ifdef __GLIBC_PREREQ -#if !__GLIBC_PREREQ (2 ,6 )int __weak sched_getcpu (void ) { +#ifdef __NR_getcpu +unsigned cpu; +int err =syscall (__NR_getcpu, &cpu,NULL ,NULL ); +if (!err) +return cpu; +#else errno =ENOSYS ; +#endif return -1 ; } -#endif -#endif static int perf_flag_probe (void ) {
tools/perf/util/util.h +4 -0
@@ -361,4 +361,8 @@ void print_binary(unsigned char *data, size_t len, size_t bytes_per_line, print_binary_t printer, void *extra); +#ifndef __GLIBC__ +extern int sched_getcpu (void ); +#endif +#endif /* GIT_COMPAT_UTIL_H */