From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752161AbcGMHSU (ORCPT ); Wed, 13 Jul 2016 03:18:20 -0400 Received: from terminus.zytor.com ([198.137.202.10]:41506 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751368AbcGMHSM (ORCPT ); Wed, 13 Jul 2016 03:18:12 -0400 Date: Wed, 13 Jul 2016 00:18:02 -0700 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: acme@redhat.com, jolsa@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org, adrian.hunter@intel.com, mingo@kernel.org, wangnan0@huawei.com, tglx@linutronix.de, dsahern@gmail.com, namhyung@kernel.org Reply-To: mingo@kernel.org, adrian.hunter@intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org, acme@redhat.com, jolsa@kernel.org, dsahern@gmail.com, namhyung@kernel.org, wangnan0@huawei.com, tglx@linutronix.de To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Introduce weak alternative to sched_getcpu() Git-Commit-ID: c7007e983682b31d91e9ad7c3e85c49ffcc3651f X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: c7007e983682b31d91e9ad7c3e85c49ffcc3651f Gitweb: http://git.kernel.org/tip/c7007e983682b31d91e9ad7c3e85c49ffcc3651f Author: Arnaldo Carvalho de Melo AuthorDate: Tue, 12 Jul 2016 10:29:31 -0300 Committer: Arnaldo Carvalho de Melo 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 Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-kblef7svmhr0g93kkx78envg@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- 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(-) diff --git a/tools/arch/x86/include/asm/unistd_32.h b/tools/arch/x86/include/asm/unistd_32.h index cf33ab0..88b3f8c 100644 --- a/tools/arch/x86/include/asm/unistd_32.h +++ b/tools/arch/x86/include/asm/unistd_32.h @@ -7,3 +7,6 @@ #ifndef __NR_gettid # define __NR_gettid 224 #endif +#ifndef __NR_getcpu +# define __NR_getcpu 318 +#endif diff --git a/tools/arch/x86/include/asm/unistd_64.h b/tools/arch/x86/include/asm/unistd_64.h index 2c98356..fbdb70e 100644 --- a/tools/arch/x86/include/asm/unistd_64.h +++ b/tools/arch/x86/include/asm/unistd_64.h @@ -7,3 +7,6 @@ #ifndef __NR_gettid # define __NR_gettid 186 #endif +#ifndef __NR_getcpu +# define __NR_getcpu 309 +#endif diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c index fde772d..f0dcd0e 100644 --- a/tools/perf/util/cloexec.c +++ b/tools/perf/util/cloexec.c @@ -4,18 +4,24 @@ #include "cloexec.h" #include "asm/bug.h" #include "debug.h" +#include +#include +#include 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) { diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 2370cfb..d8d41ef 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -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 */