All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Vineet Gupta <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: peterz@infradead.org, jolsa@kernel.org, mingo@kernel.org,
	Alexey.Brodkin@synopsys.com, tglx@linutronix.de, acme@redhat.com,
	vgupta@synopsys.com, namhyung@kernel.org,
	linux-kernel@vger.kernel.org, Vineet.Gupta1@synopsys.com,
	hpa@zytor.com
Subject: [tip:perf/core] perf tools: Provide stub for missing pthread_attr_setaffinity_np
Date: Fri, 30 Jan 2015 10:31:46 -0800	[thread overview]
Message-ID: <tip-459a3df76c99124fd222586be7f10f862547e7a9@git.kernel.org> (raw)
In-Reply-To: <1421156604-30603-6-git-send-email-vgupta@synopsys.com>

Commit-ID:  459a3df76c99124fd222586be7f10f862547e7a9
Gitweb:     http://git.kernel.org/tip/459a3df76c99124fd222586be7f10f862547e7a9
Author:     Vineet Gupta <Vineet.Gupta1@synopsys.com>
AuthorDate: Tue, 13 Jan 2015 19:13:24 +0530
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Wed, 28 Jan 2015 12:43:32 -0300

perf tools: Provide stub for missing pthread_attr_setaffinity_np

uClibc Linuxthreads.old doesn't support the pthread_attr_setaffinity_np()
functioo:

   ----------------->8-----------------------
  CC       bench/futex-hash.o
  CC       bench/futex-wake.o
bench/futex-hash.c: In function 'bench_futex_hash':
bench/futex-hash.c:161:3: error: implicit declaration of function
'pthread_attr_setaffinity_np' [-Werror=implicit-function-declaration]
   ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cpu_set_t),
&cpu);
   ^
bench/futex-hash.c:161:3: error: nested extern declaration of
'pthread_attr_setaffinity_np' [-Werror=nested-externs]
   ----------------->8-----------------------

So introduce a test to check that and if not available provide a stub.

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1421156604-30603-6-git-send-email-vgupta@synopsys.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/bench/futex.h                                   | 13 +++++++++++++
 tools/perf/config/Makefile                                 |  6 ++++++
 tools/perf/config/feature-checks/Makefile                  |  4 ++++
 tools/perf/config/feature-checks/test-all.c                |  5 +++++
 .../feature-checks/test-pthread-attr-setaffinity-np.c      | 14 ++++++++++++++
 5 files changed, 42 insertions(+)

diff --git a/tools/perf/bench/futex.h b/tools/perf/bench/futex.h
index 71f2844..7ed22ff 100644
--- a/tools/perf/bench/futex.h
+++ b/tools/perf/bench/futex.h
@@ -68,4 +68,17 @@ futex_cmp_requeue(u_int32_t *uaddr, u_int32_t val, u_int32_t *uaddr2, int nr_wak
 		 val, opflags);
 }
 
+#ifndef HAVE_PTHREAD_ATTR_SETAFFINITY_NP
+#include <pthread.h>
+static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr,
+					      size_t cpusetsize,
+					      cpu_set_t *cpuset)
+{
+	attr = attr;
+	cpusetsize = cpusetsize;
+	cpuset = cpuset;
+	return 0;
+}
+#endif
+
 #endif /* _FUTEX_H */
diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile
index 648e31f..cc22408 100644
--- a/tools/perf/config/Makefile
+++ b/tools/perf/config/Makefile
@@ -198,6 +198,7 @@ CORE_FEATURE_TESTS =			\
 	libpython-version		\
 	libslang			\
 	libunwind			\
+	pthread-attr-setaffinity-np	\
 	stackprotector-all		\
 	timerfd				\
 	libdw-dwarf-unwind		\
@@ -226,6 +227,7 @@ VF_FEATURE_TESTS =			\
 	libelf-getphdrnum		\
 	libelf-mmap			\
 	libpython-version		\
+	pthread-attr-setaffinity-np	\
 	stackprotector-all		\
 	timerfd				\
 	libunwind-debug-frame		\
@@ -301,6 +303,10 @@ ifeq ($(feature-sync-compare-and-swap), 1)
   CFLAGS += -DHAVE_SYNC_COMPARE_AND_SWAP_SUPPORT
 endif
 
+ifeq ($(feature-pthread-attr-setaffinity-np), 1)
+  CFLAGS += -DHAVE_PTHREAD_ATTR_SETAFFINITY_NP
+endif
+
 ifndef NO_BIONIC
   $(call feature_check,bionic)
   ifeq ($(feature-bionic), 1)
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 53f19b5..42ac05a 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -25,6 +25,7 @@ FILES=					\
 	test-libslang.bin		\
 	test-libunwind.bin		\
 	test-libunwind-debug-frame.bin	\
+	test-pthread-attr-setaffinity-np.bin	\
 	test-stackprotector-all.bin	\
 	test-timerfd.bin		\
 	test-libdw-dwarf-unwind.bin	\
@@ -47,6 +48,9 @@ test-all.bin:
 test-hello.bin:
 	$(BUILD)
 
+test-pthread-attr-setaffinity-np.bin:
+	$(BUILD) -Werror -lpthread
+
 test-stackprotector-all.bin:
 	$(BUILD) -Werror -fstack-protector-all
 
diff --git a/tools/perf/config/feature-checks/test-all.c b/tools/perf/config/feature-checks/test-all.c
index 652e009..6d4d093 100644
--- a/tools/perf/config/feature-checks/test-all.c
+++ b/tools/perf/config/feature-checks/test-all.c
@@ -97,6 +97,10 @@
 # include "test-zlib.c"
 #undef main
 
+#define main main_test_pthread_attr_setaffinity_np
+# include "test-pthread_attr_setaffinity_np.c"
+#undef main
+
 int main(int argc, char *argv[])
 {
 	main_test_libpython();
@@ -121,6 +125,7 @@ int main(int argc, char *argv[])
 	main_test_libdw_dwarf_unwind();
 	main_test_sync_compare_and_swap(argc, argv);
 	main_test_zlib();
+	main_test_pthread_attr_setaffinity_np();
 
 	return 0;
 }
diff --git a/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c b/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
new file mode 100644
index 0000000..0a0d3ec
--- /dev/null
+++ b/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
@@ -0,0 +1,14 @@
+#include <stdint.h>
+#include <pthread.h>
+
+int main(void)
+{
+	int ret = 0;
+	pthread_attr_t thread_attr;
+
+	pthread_attr_init(&thread_attr);
+	/* don't care abt exact args, just the API itself in libpthread */
+	ret = pthread_attr_setaffinity_np(&thread_attr, 0, NULL);
+
+	return ret;
+}

  reply	other threads:[~2015-01-30 18:32 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-13 13:43 [PATCH v3 0/5] Perf tool fixes for ARC + uClibc Vineet Gupta
2015-01-13 13:43 ` Vineet Gupta
2015-01-13 13:43 ` [PATCH v3 1/5] perf tools: [uclibc] fix statfs.f_type data type mismatch build error Vineet Gupta
2015-01-13 13:43   ` Vineet Gupta
2015-01-13 13:43 ` [PATCH v3 2/5] perf tools: [uclibc] Elide strlcpy warning Vineet Gupta
2015-01-13 13:43   ` Vineet Gupta
2015-01-17 10:12   ` [tip:perf/urgent] perf tools: Elide strlcpy warning with uclibc tip-bot for Vineet Gupta
2015-01-13 13:43 ` [PATCH v3 3/5] perf tools: [uclibc] Avoid build splat for syscall numbers Vineet Gupta
2015-01-13 13:43   ` Vineet Gupta
2015-01-17 10:12   ` [tip:perf/urgent] perf tools: Avoid build splat for syscall numbers with uclibc tip-bot for Vineet Gupta
2015-01-13 13:43 ` [PATCH v3 4/5] perf tools: [uclibc] don't rely on glibc malloc working for sz 0 Vineet Gupta
2015-01-13 13:43   ` Vineet Gupta
2015-01-30 18:31   ` [tip:perf/core] perf evsel: Don't rely on " tip-bot for Vineet Gupta
2015-01-13 13:43 ` [PATCH v3 5/5] perf tools: [uclibc] provide stub for pthread_attr_setaffinity_np Vineet Gupta
2015-01-13 13:43   ` Vineet Gupta
2015-01-30 18:31   ` tip-bot for Vineet Gupta [this message]
2015-01-14 12:00 ` [PATCH v3 0/5] Perf tool fixes for ARC + uClibc Jiri Olsa
2015-01-14 13:59   ` Arnaldo Carvalho de Melo
2015-01-19  4:35     ` Vineet Gupta
2015-01-19  4:35       ` Vineet Gupta
2015-01-19 13:58       ` Arnaldo Carvalho de Melo
2015-01-27 10:29         ` Vineet Gupta
2015-01-27 10:29           ` Vineet Gupta
2015-01-27 14:29           ` Arnaldo Carvalho de Melo

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=tip-459a3df76c99124fd222586be7f10f862547e7a9@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=Alexey.Brodkin@synopsys.com \
    --cc=Vineet.Gupta1@synopsys.com \
    --cc=acme@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=vgupta@synopsys.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.