mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Holasek <pholasek@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Jiri Olsa <jolsa@redhat.com>, Petr Holasek <pholasek@redhat.com>
Subject: [PATCH] perf tools: rework of handling lack of sched_getcpu in old glibc
Date: Tue, 19 May 2015 15:20:47 +0200	[thread overview]
Message-ID: <1432041647-19981-1-git-send-email-pholasek@redhat.com> (raw)

Commit e1e455f4f4d3 ("perf tools: Work around lack of sched_getcpu in
glibc < 2.6.") introduced weak function sched_getcpu() which should
be overridden by sched_getcpu() provided by glibc >= 2.6. Unfortunately,
the weak function was linked to sched_getcpu() used in perf bench numa
and made the benchmark heavily relying on this function unusable.

This patch alternates weak function magic for preprocessor defines.

Signed-off-by: Petr Holasek <pholasek@redhat.com>
---
 tools/perf/util/cloexec.c | 13 +++++++++++--
 tools/perf/util/cloexec.h |  6 ------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c
index 85b5238..23b8aa9 100644
--- a/tools/perf/util/cloexec.c
+++ b/tools/perf/util/cloexec.c
@@ -7,11 +7,20 @@
 
 static unsigned long flag = PERF_FLAG_FD_CLOEXEC;
 
-int __weak sched_getcpu(void)
+#ifdef __GLIBC_PREREQ
+#if !__GLIBC_PREREQ(2, 6)
+static int do_sched_getcpu(void)
 {
 	errno = ENOSYS;
 	return -1;
 }
+#else
+static int do_sched_getcpu(void)
+{
+	return sched_getcpu();
+}
+#endif
+#endif
 
 static int perf_flag_probe(void)
 {
@@ -27,7 +36,7 @@ static int perf_flag_probe(void)
 	pid_t pid = -1;
 	char sbuf[STRERR_BUFSIZE];
 
-	cpu = sched_getcpu();
+	cpu = do_sched_getcpu();
 	if (cpu < 0)
 		cpu = 0;
 
diff --git a/tools/perf/util/cloexec.h b/tools/perf/util/cloexec.h
index 68888c2..94a5a7d 100644
--- a/tools/perf/util/cloexec.h
+++ b/tools/perf/util/cloexec.h
@@ -3,10 +3,4 @@
 
 unsigned long perf_event_open_cloexec_flag(void);
 
-#ifdef __GLIBC_PREREQ
-#if !__GLIBC_PREREQ(2, 6)
-extern int sched_getcpu(void) __THROW;
-#endif
-#endif
-
 #endif /* __PERF_CLOEXEC_H */
-- 
2.1.0


             reply	other threads:[~2015-05-19 13:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-19 13:20 Petr Holasek [this message]
2015-05-19 13:49 ` Arnaldo Carvalho de Melo
2015-05-19 15:16   ` Petr Holasek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432041647-19981-1-git-send-email-pholasek@redhat.com \
    --to=pholasek@redhat.com \
    --cc=acme@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®