]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
perf tools: Introduce weak alternative to sched_getcpu()
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 12 Jul 2016 13:29:31 +0000 (10:29 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 12 Jul 2016 18:20:34 +0000 (15:20 -0300)
Which is just a wrapper for sys_getcpu and is not present in at least
musl libc.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-kblef7svmhr0g93kkx78envg@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/arch/x86/include/asm/unistd_32.h
tools/arch/x86/include/asm/unistd_64.h
tools/perf/util/cloexec.c
tools/perf/util/util.h

index cf33ab09273df6669036b2fc58ee9fcee79974f2..88b3f8c8920cac566838d1443e40d49b52e612df 100644 (file)
@@ -7,3 +7,6 @@
 #ifndef __NR_gettid
 # define __NR_gettid 224
 #endif
+#ifndef __NR_getcpu
+# define __NR_getcpu 318
+#endif
index 2c9835695b56e06c4dca0b3962164935e59ddfc8..fbdb70ee8837ef1ec34b9aff174faf9efe87de07 100644 (file)
@@ -7,3 +7,6 @@
 #ifndef __NR_gettid
 # define __NR_gettid 186
 #endif
+#ifndef __NR_getcpu
+# define __NR_getcpu 309
+#endif
index fde772db1d5c0852f95b089d3ee5d2221a8907d6..f0dcd0ee0afaa0505470ca382a9d597a5e88fb3a 100644 (file)
@@ -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)
 {
index 2370cfb902b29e37e051ac5fb0df99aeae8bcf0a..d8d41ef8da576ed4aba668aa9c72514045691fad 100644 (file)
@@ -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 */