Perf tool fixes for ARC + uClibc
Subsystems (3)
v2 cover Perf tool fixes for ARC + uClibc
Hi,
This series based off linux-next of 20150105 allows us to build/use perf for ARC with uClibc based userland.
v2: Change since v1 [1]
* [1-3]/5 : no changes
* 4/5 : Make perf_evsel__alloc_id agnostic of zero threads [Namhyung Kim]
* 5/5 : Add missing test file
v1:
* 1/5 is really a resend of old patch posted by Alexey a while back
* 2/5 is uClibc build spew seen on ARM as well
* 3/5 likewise
* 4/5 is uClibc config specific
* 5/5 is uClibc pthread library flavour specific
It adds a stub for pthread_attr_setaffinity_np
I can rework it to disable the futex tests altogether if people think that is cleaner
Please review and consider applying.
W/o these perf doesn't build and/or work for ARC.
[1] http://www.spinics.net/linux/lists/kernel/msg1897268.html
Thx,
-Vineet
Alexey Brodkin (1):
perf tools: [uclibc] fix statfs.f_type data type mismatch build error
Vineet Gupta (4):
perf tools: [uclibc] Elide strlcpy warning
perf tools: [uclibc] Avoid build splat for syscall numbers perf tools: [uclibc] don't rely on glibc malloc working for sz 0 perf tools: [uclibc] provide stub for pthread_attr_setaffinity_np
tools/lib/api/fs/debugfs.c | 2 +- tools/lib/api/fs/fs.c | 2 +- tools/perf/bench/futex.h | 13 +++++++++++++ tools/perf/bench/sched-pipe.c | 1 - tools/perf/builtin-top.c | 1 - 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 ++++++++++++++ tools/perf/perf-sys.h | 1 - tools/perf/util/cache.h | 2 ++ tools/perf/util/evsel.c | 3 +++ 12 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
Signature · 1 line
1.9.1
PATCH v2 1/5 perf tools: [uclibc] fix statfs.f_type data type mismatch build error
From: Alexey Brodkin <[email protected]>
ARC Linux uses the no legacy syscalls abi and corresponding uClibc headers statfs defines f_type to be U32 which causes perf build breakage
http://git.uclibc.org/uClibc/tree/libc/sysdeps/linux/common-generic/bits/statfs.h
----------->8---------------
CC fs/fs.ofs/fs.c: In function 'fs__valid_mount':fs/fs.c:82:24: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
else if (st_fs.f_type != magic)
^
cc1: all warnings being treated as errors
----------->8---------------
---
v3: Changes since v2 [2]
* Made Changelog a bit more concise, no code changes [vgupta]
v2: Changes since v1 [1]
* Added type cast to DEBUGFS_MAGIC in "debugfs.c" [Arnaldo]
* Added verbose explanation of root cause
[2] https://lkml.org/lkml/2014/9/16/296
[1] https://lkml.org/lkml/2014/8/13/529
--- tools/lib/api/fs/debugfs.c | 2 +- tools/lib/api/fs/fs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/lib/api/fs/debugfs.c +1 -1
@@ -67,7 +67,7 @@ int debugfs_valid_mountpoint(const char *debugfs)if (statfs (debugfs, &st_fs) <0 )return -ENOENT ; -else if (st_fs.f_type != (long )DEBUGFS_MAGIC ) +else if ((long ) st_fs.f_type != (long )DEBUGFS_MAGIC )return -ENOENT ;return 0 ;
tools/lib/api/fs/fs.c +1 -1
@@ -79,7 +79,7 @@ static int fs__valid_mount(const char *fs, long magic)if (statfs (fs, &st_fs) <0 )return -ENOENT ; -else if (st_fs.f_type != magic) +else if ((long ) st_fs.f_type != magic)return -ENOENT ;return 0 ;
Signature · 1 line
1.9.1
Re: [PATCH v2 1/5] perf tools: [uclibc] fix statfs.f_type data type mismatch build error
Quoted 17 lines · Vineet Gupta
From: Alexey Brodkin <[email protected]>
ARC Linux uses the no legacy syscalls abi and corresponding uClibc headers statfs defines
f_typeto be U32 which causes perf build breakagehttp://git.uclibc.org/uClibc/tree/libc/sysdeps/linux/common-generic/bits/statfs.h
----------->8---------------
CCfs/fs.ofs/fs.c: In function 'fs__valid_mount':fs/fs.c:82:24: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
else if (st_fs.f_type != magic)^cc1: all warnings being treated as errors
----------->8---------------
Quoted 7 lines
Cc Borislav Petkov <[email protected]>Cc Jiri Olsa <[email protected]>Cc Cody P Schafer <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Signed-off-by Alexey Brodkin <[email protected]>
thanks,
jirka
Quoted 47 lines
---
v3: Changes since v2 [2]
* Made Changelog a bit more concise, no code changes [vgupta]v2: Changes since v1 [1]
* Added type cast toDEBUGFS_MAGICin "debugfs.c" [Arnaldo]
* Added verbose explanation of root cause[2] https://lkml.org/lkml/2014/9/16/296
[1] https://lkml.org/lkml/2014/8/13/529Signed-off-by Vineet Gupta <[email protected]>--- tools/lib/api/fs/debugfs.c | 2 +- tools/lib/api/fs/fs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)tools/lib/api/fs/debugfs.c +1
-1@@ -67,7 +67,7 @@ int debugfs_valid_mountpoint(const char *debugfs)if (statfs (debugfs, &st_fs) <0 )return -ENOENT ; -else if (st_fs.f_type != (long )DEBUGFS_MAGIC ) +else if ((long ) st_fs.f_type != (long )DEBUGFS_MAGIC )return -ENOENT ;return 0 ;tools/lib/api/fs/fs.c +1
-1@@ -79,7 +79,7 @@ static int fs__valid_mount(const char *fs, long magic)if (statfs (fs, &st_fs) <0 )return -ENOENT ; -else if (st_fs.f_type != magic) +else if ((long ) st_fs.f_type != magic)return -ENOENT ;return 0 ;Signature · 1 line
1.9.1
Arnaldo Carvalho de Melo
AppliedRe: [PATCH v2 1/5] perf tools: [uclibc] fix statfs.f_type data type mismatch build error
Em Mon, Jan 12, 2015 at 12:05:22PM +0100, Jiri Olsa escreveu:
Quoted 26 lines · Vineet Gupta
Quoted 17 lines
From: Alexey Brodkin <[email protected]>
ARC Linux uses the no legacy syscalls abi and corresponding uClibc headers statfs defines
f_typeto be U32 which causes perf build breakagehttp://git.uclibc.org/uClibc/tree/libc/sysdeps/linux/common-generic/bits/statfs.h
----------->8---------------
CCfs/fs.ofs/fs.c: In function 'fs__valid_mount':fs/fs.c:82:24: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
else if (st_fs.f_type != magic)^cc1: all warnings being treated as errors
----------->8---------------Quoted 7 lines
Cc Borislav Petkov <[email protected]>Cc Jiri Olsa <[email protected]>Cc Cody P Schafer <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Signed-off-by Alexey Brodkin <[email protected]>
Quoted 1 line
Acked-by Jiri Olsa <[email protected]>
Thanks, applied, but please do not start lines in the changelog comment with ---, that breaks some patch applying scripts. I fixed it up this time.
- Arnaldo
Vineet Gupta
AppliedRe: [PATCH v2 1/5] perf tools: [uclibc] fix statfs.f_type data type mismatch build error
On Tuesday 13 January 2015 07:18 AM, Arnaldo Carvalho de Melo wrote:
Em Mon, Jan 12, 2015 at 12:05:22PM +0100, Jiri Olsa escreveu:
Quoted 30 lines · Vineet Gupta
Quoted 19 lines
From: Alexey Brodkin <[email protected]><mailto:[email protected]>
ARC Linux uses the no legacy syscalls abi and corresponding uClibc headers statfs defines
f_typeto be U32 which causes perf build breakagehttp://git.uclibc.org/uClibc/tree/libc/sysdeps/linux/common-generic/bits/statfs.h
----------->8---------------
CCfs/fs.ofs/fs.c: In function 'fs__valid_mount':fs/fs.c:82:24: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
else if (st_fs.f_type != magic)^cc1: all warnings being treated as errors
----------->8---------------Quoted 7 lines
Cc Borislav Petkov <[email protected]><mailto:[email protected]>Cc Jiri Olsa <[email protected]><mailto:[email protected]>Cc Cody P Schafer <[email protected]><mailto:[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]><mailto:[email protected]>Cc [email protected]<mailto:[email protected]>Cc [email protected]<mailto:[email protected]>
Quoted 1 line
Thanks, applied, but please do not start lines in the changelog comment with ---, that breaks some patch applying scripts. I fixed it up this time.
Thx. I've udpated the changelogs so scissor lines start at column 3 with leading whitespace, is that OK or do you want me to remove those lines altogether. Also do u want me to drop this patch from v3 of series as I have some fixups for other patches.
Thx,
-Vineet
- Arnaldo
tip-bot for Alexey Brodkin
merge bot[tip:perf/urgent] perf tools: Fix statfs.f_type data type mismatch build error with uclibc
In reply to Vineet Guptaperf tools: Fix statfs.f_type data type mismatch build error with uclibc
Commit-ID: db1806edcfef007d9594435a331dcf7e7f1b8fac Gitweb: http://git.kernel.org/tip/db1806edcfef007d9594435a331dcf7e7f1b8fac Author: Alexey Brodkin <[email protected]> AuthorDate: Sat, 10 Jan 2015 16:40:50 +0530 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 16 Jan 2015 17:49:29 -0300
perf tools: Fix statfs.f_type data type mismatch build error with uclibc
ARC Linux uses the no legacy syscalls abi and corresponding uClibc headers statfs defines f_type to be U32 which causes perf build breakage
http://git.uclibc.org/uClibc/tree/libc/sysdeps/linux/common-generic/bits/statfs.h
----------->8---------------
CC fs/fs.o
fs/fs.c: In function 'fs__valid_mount':
fs/fs.c:82:24: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
else if (st_fs.f_type != magic)
^ cc1: all warnings being treated as errors
----------->8---------------
--- tools/lib/api/fs/debugfs.c | 2 +- tools/lib/api/fs/fs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/lib/api/fs/debugfs.c +1 -1
@@ -67,7 +67,7 @@ int debugfs_valid_mountpoint(const char *debugfs)if (statfs (debugfs, &st_fs) <0 )return -ENOENT ; -else if (st_fs.f_type != (long )DEBUGFS_MAGIC ) +else if ((long )st_fs.f_type != (long )DEBUGFS_MAGIC )return -ENOENT ;return 0 ;
tools/lib/api/fs/fs.c +1 -1
@@ -79,7 +79,7 @@ static int fs__valid_mount(const char *fs, long magic)if (statfs (fs, &st_fs) <0 )return -ENOENT ; -else if (st_fs.f_type != magic) +else if ((long )st_fs.f_type != magic)return -ENOENT ;return 0 ;
PATCH v2 2/5 perf tools: [uclibc] Elide strlcpy warning
In reply to Vineet Gupta----------------->8------------------
CC bench/sched-pipe.o
In file included from builtin-annotate.c:13:0:util/cache.h:76:15: warning: redundant redeclaration of 'strlcpy' [-Wredundant-decls]
extern size_t strlcpy(char *dest, const char *src, size_t size);
^In file included from util/util.h:55:0,
from builtin.h:4,
from builtin-annotate.c:8:~/vineetg/arc/gnu/INSTALL_1412-arc-2014.12-rc1/arc-snps-linux-uclibc/sysroot/usr/include/string.h:396:15:
note: previous declaration of 'strlcpy' was here
extern size_t strlcpy(char *__restrict dst, const char *__restrict src,
----------------->8------------------
--- tools/perf/util/cache.h | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/cache.h +2 -0
@@ -71,7 +71,9 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2extern char *perf_pathdup (const char *fmt, ...) __attribute__((format (printf,1 ,2 ))); +#ifndef __UCLIBC__/* Matches the libc/libbsd function attribute so we declare this unconditionally: */ extern size_t strlcpy (char *dest,const char *src,size_t size); +#endif #endif /* __PERF_CACHE_H */
Signature · 1 line
1.9.1
PATCH v2 3/5 perf tools: [uclibc] Avoid build splat for syscall numbers
In reply to Vineet GuptaThis is due to duplicated unistd inclusion (via uClibc headers + kernel headers) Also seen on ARM uClibc based tools
------- ARC build ---------->8-------------
CC util/evlist.o
In file included from ~/arc/k.org/arch/arc/include/uapi/asm/unistd.h:25:0,
from util/../perf-sys.h:10,
from util/../perf.h:15,
from util/event.h:7,
from util/event.c:3:~/arc/k.org/include/uapi/asm-generic/unistd.h:906:0:
warning: "__NR_fcntl64" redefined [enabled by default]
#define __NR_fcntl64 __NR3264_fcntl
^
In file included from ~/arc/gnu/INSTALL_1412-arc-2014.12-rc1/arc-snps-linux-uclibc/sysroot/usr/include/sys/syscall.h:24:0,
from util/../perf-sys.h:6,
----------------->8-------------------
------- ARM build ---------->8-------------
CC FPIC plugin_scsi.o
In file included from util/../perf-sys.h:9:0,
from util/../perf.h:15,
from util/cache.h:7,
from perf.c:12:~/arc/k.org/arch/arm/include/uapi/asm/unistd.h:28:0:
warning: "__NR_restart_syscall" redefined [enabled by default]
In file included from ~/buildroot/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/sys/syscall.h:25:0,
from util/../perf-sys.h:6,
from util/../perf.h:15,
from util/cache.h:7,
from perf.c:12:~/buildroot/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/bits/sysnum.h:17:0:
note: this is the location of the previous definition ----------------->8-------------------
--- tools/perf/bench/sched-pipe.c | 1 - tools/perf/builtin-top.c | 1 - tools/perf/perf-sys.h | 1 - 3 files changed, 3 deletions(-)
tools/perf/bench/sched-pipe.c +0 -1
@@ -19,7 +19,6 @@#include <stdlib.h> #include <signal.h> #include <sys/wait.h> -#include <linux/unistd.h> #include <string.h> #include <errno.h> #include <assert.h>
tools/perf/builtin-top.c +0 -1
@@ -66,7 +66,6 @@#include <sys/utsname.h> #include <sys/mman.h> -#include <linux/unistd.h> #include <linux/types.h> static volatile int done;
tools/perf/perf-sys.h +0 -1
@@ -6,7 +6,6 @@#include <sys/syscall.h> #include <linux/types.h> #include <linux/perf_event.h> -#include <asm/unistd.h> #if defined(__i386__)#define mb () asm volatile("lock; addl $0,0(%%esp)" ::: "memory")
Signature · 1 line
1.9.1
Re: [PATCH v2 3/5] perf tools: [uclibc] Avoid build splat for syscall numbers
Quoted 32 lines · Vineet Gupta
This is due to duplicated unistd inclusion (via uClibc headers + kernel headers) Also seen on ARM uClibc based tools
------- ARC build ---------->8-------------
CC
util/evlist.o
In file included from~/arc/k.org/arch/arc/include/uapi/asm/unistd.h:25:0,from util/../perf-sys.h:10, from util/../perf.h:15, from util/event.h:7, from util/event.c:3:
~/arc/k.org/include/uapi/asm-generic/unistd.h:906:0:
warning: "__NR_fcntl64" redefined [enabled by default]
#define__NR_fcntl64__NR3264_fcntl
^
In file included from~/arc/gnu/INSTALL_1412-arc-2014.12-rc1/arc-snps-linux-uclibc/sysroot/usr/include/sys/syscall.h:24:0,from util/../perf-sys.h:6,----------------->8-------------------
------- ARM build ---------->8-------------
CC FPIC plugin_scsi.o
In file included fromutil/../perf-sys.h:9:0,from util/../perf.h:15, from util/cache.h:7, from perf.c:12:
~/arc/k.org/arch/arm/include/uapi/asm/unistd.h:28:0:
warning: "__NR_restart_syscall" redefined [enabled by default]
In file included from~/buildroot/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/sys/syscall.h:25:0,
Quoted 7 lines
from util/../perf-sys.h:6, from util/../perf.h:15, from util/cache.h:7, from perf.c:12:
~/buildroot/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/bits/sysnum.h:17:0:
note: this is the location of the previous definition ----------------->8-------------------
Could you please point out what's the right logic for including those headers?
I've always thought that just adding:
#include <linux/unistd.h>
should be safe no matter what.. feels like bug in one of those header files? (uClibc headers & kernel headers)
thanks for info,
jirka
Re: [PATCH v2 3/5] perf tools: [uclibc] Avoid build splat for syscall numbers
Hi Jiri,
Quoted 40 lines · Jiri Olsa
Quoted 32 lines · Vineet Gupta
This is due to duplicated unistd inclusion (via uClibc headers + kernel headers) Also seen on ARM uClibc based tools
------- ARC build ---------->8-------------
CC
util/evlist.o
In file included from~/arc/k.org/arch/arc/include/uapi/asm/unistd.h:25:0,from util/../perf-sys.h:10, from util/../perf.h:15, from util/event.h:7, from util/event.c:3:
~/arc/k.org/include/uapi/asm-generic/unistd.h:906:0:
warning: "__NR_fcntl64" redefined [enabled by default]
#define__NR_fcntl64__NR3264_fcntl
^
In file included from~/arc/gnu/INSTALL_1412-arc-2014.12-rc1/arc-snps-linux-uclibc/sysroot/usr/include/sys/syscall.h:24:0,from util/../perf-sys.h:6,----------------->8-------------------
------- ARM build ---------->8-------------
CC FPIC plugin_scsi.o
In file included fromutil/../perf-sys.h:9:0,from util/../perf.h:15, from util/cache.h:7, from perf.c:12:
~/arc/k.org/arch/arm/include/uapi/asm/unistd.h:28:0:
warning: "__NR_restart_syscall" redefined [enabled by default]
In file included from~/buildroot/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/sys/syscall.h:25:0,Quoted 7 lines
from util/../perf-sys.h:6, from util/../perf.h:15, from util/cache.h:7, from perf.c:12:
~/buildroot/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/bits/sysnum.h:17:0:
note: this is the location of the previous definition ----------------->8-------------------
Quoted 1 line
Could you please point out what's the right logic for including those headers?
I'm not sure why you were including <linux/unistd.h> in first place. Vanilla <unistd.h> shd suffice for the functions exported by that file. OTOH, if the intent was to get SYS_xxx or NR_xxx, then per syscall man page, <sys/syscall.h> is the recommended way.
I just tried a small test program which uses __NR_restart_syscall for both x86 (glibc) and ARC (uClibc) and including <sys/syscall.h> seems to work.
Also replacing <linux/unistd.h> with <sys/syscall.h> in the first 2 hunks of this patch equally fixes my perf build splat. The 3rd one (perf-sys.h) already includes <sys/syscall.h> so no change required there.
I'll send out a v3 to same effect.
Quoted 7 lines
I've always thought that just adding:
#include <linux/unistd.h>should be safe no matter what.. feels like bug in one of those header files? (uClibc headers & kernel headers)
Well the design of asm-generic/unistd.h (no legacy syscalls ABI) which ARC uses does require duplicate inclusion of asm/unistd.h so a simple guard in header is not sufficient (and actually caused me embarrassing grief when I naively submitted that into mainline some time last year)
Thx,
-Vineet
Quoted 3 lines
thanks for info,
jirka
PATCH v2 4/5 perf tools: [uclibc] don't rely on glibc malloc working for sz 0
In reply to Vineet GuptaWhen running perf on ARC (uClibc based userspace), ran into this issue ------------->8----------------
[ARCLinux]$ ./perf record ls
bin etc perf sys
debug init perf.data tmp
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.001 MB perf.data (~24 samples) ]
[ARCLinux]$ ./perf report
incompatible file format (rerun with -v to learn more)
------------->8----------------
The problem happens in the following call stack when zalloc is called with size zero
glibc default / uClibc with MALLOC_GLIBC_COMPAT are OK, but not if that config option is not enabled.
cmd_report
perf_session__new perf_session__open perf_session__read_header read_attr(fd, header, &f_attr) nr_ids = f_attr.ids.size / sizeof(u64); <-- 0 perf_evsel__alloc_id(vsel, 1, nr_ids) zalloc(ncpus * nthreads * sizeof(u64)) <-- 0
header.c: read_attr()
(gdb) p *f_attr
$17 = {
attr = {
type = 0,
size = 96,
config = 0,
{
sample_period = 4000,
sample_freq = 4000
},
...
ids = {
offset = 104,
size = 0 <------ }
}
--- tools/perf/util/evsel.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/evsel.c +3 -0
@@ -797,6 +797,9 @@ int perf_evsel__enable(struct perf_evsel *evsel, int ncpus, int nthreads)int perf_evsel__alloc_id (struct perf_evsel *evsel,int ncpus,int nthreads) { +if (ncpus ==0 || nthreads ==0 ) +return 0 ; +if (evsel->system_wide) nthreads =1 ;
Signature · 1 line
1.9.1
PATCH v2 5/5 perf tools: [uclibc] provide stub for pthread_attr_setaffinity_np
In reply to Vineet GuptauClibc Linuxthreads.old doesnt support pthread_attr_setaffinity_np() call
----------------->8-----------------------
CC bench/futex-hash.o
CC bench/futex-wake.obench/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-----------------------
--- 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(+) create mode 100644 tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
tools/perf/bench/futex.h +13 -0
@@ -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 */
tools/perf/config/Makefile +6 -0
@@ -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)
tools/perf/config/feature-checks/Makefile +4 -0
@@ -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 + test-stackprotector-all.bin: $(BUILD) -Werror -fstack-protector-all
tools/perf/config/feature-checks/test-all.c +5 -0
@@ -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 ; }
tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c new file +14 -0
@@ -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; +}
Signature · 1 line
1.9.1
Re: [PATCH v2 5/5] perf tools: [uclibc] provide stub for pthread_attr_setaffinity_np
On Sat, Jan 10, 2015 at 04:40:54PM +0530, Vineet Gupta wrote:
SNIP
Quoted 40 lines
(quoted diff) +6
-0@@ -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)tools/perf/config/feature-checks/Makefile +1
-0@@ -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 \
tools/perf/config/feature-checks/Makefile test-all.bin: · line 52
Quoted 5 lines
tools/perf/config/feature-checks/Makefile +2
-0@@ -47,6 +48,9 @@ test-all.bin: test-hello.bin: $(BUILD) +test-pthread-attr-setaffinity-np.bin: + $(BUILD) -Werror
this does not works for me unless I add -lpthread (check patch below) is it possible you pushed that through LDFLAGS?
otherwise I'm getting following error:
---
In file included from bench/futex-hash.c:17:0:
bench/futex.h:73:19: error: conflicting types for ‘pthread_attr_setaffinity_np’
static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr,
^
In file included from bench/futex.h:72:0,
from bench/futex-hash.c:17:
/usr/include/pthread.h:407:12: note: previous declaration of ‘pthread_attr_setaffinity_np’ was here
extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
^
make[1]: *** [bench/futex-hash.o] Error 1
make[1]: *** Waiting for unfinished jobs....
In file included from bench/futex-wake.c:17:0:
bench/futex.h:73:19: error: conflicting types for ‘pthread_attr_setaffinity_np’
static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr,
^
In file included from bench/futex.h:72:0,
from bench/futex-wake.c:17:
/usr/include/pthread.h:407:12: note: previous declaration of ‘pthread_attr_setaffinity_np’ was here
extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
^
make[1]: *** [bench/futex-wake.o] Error 1
In file included from bench/futex-requeue.c:17:0:
bench/futex.h:73:19: error: conflicting types for ‘pthread_attr_setaffinity_np’
static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr,
^
In file included from bench/futex.h:72:0,
from bench/futex-requeue.c:17:
/usr/include/pthread.h:407:12: note: previous declaration of ‘pthread_attr_setaffinity_np’ was here
extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
^
make[1]: *** [bench/futex-requeue.o] Error 1
make: *** [all] Error 2
---
my system is x86_64 on F20
thanks,
jirka
tools/perf/config/feature-checks/Makefile +1 -1
@@ -49,7 +49,7 @@ test-hello.bin: $(BUILD) test-pthread-attr-setaffinity-np.bin: - $(BUILD) -Werror + $(BUILD) -Werror -lpthread test-stackprotector-all.bin: $(BUILD) -Werror -fstack-protector-all
Re: [PATCH v2 5/5] perf tools: [uclibc] provide stub for pthread_attr_setaffinity_np
Hi Jiri,
Quoted 43 lines · Jiri Olsa
On Sat, Jan 10, 2015 at 04:40:54PM +0530, Vineet Gupta wrote:
SNIP
Review test-all.bin: · line 52
Quoted 9 lines
[SNIP]
(quoted diff) +2
-0test-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) -Werrorthis does not works for me unless I add -lpthread (check patch below) is it possible you pushed that through LDFLAGS?
otherwise I'm getting following error:
---
In file included frombench/futex-hash.c:17:0:
bench/futex.h:73:19: error: conflicting types for ‘pthread_attr_setaffinity_np’
static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr,
[snip]^ In file included from bench/futex.h:72:0, from bench/futex-requeue.c:17: /usr/include/pthread.h:407:12: note: previous declaration of ‘pthread_attr_setaffinity_np’ was here extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr, ^ make[1]: *** [bench/futex-requeue.o] Error 1 make: *** [all] Error 2 ---my system is
x86_64on F20thanks,
jirkatools/perf/config/feature-checks/Makefile +0
-0
tools/perf/config/feature-checks/Makefile test-hello.bin: · line 55
Quoted 8 lines
tools/perf/config/feature-checks/Makefile +1
-1@@ -49,7 +49,7 @@ test-hello.bin: $(BUILD) test-pthread-attr-setaffinity-np.bin: - $(BUILD) -Werror + $(BUILD) -Werror -lpthread test-stackprotector-all.bin: $(BUILD) -Werror -fstack-protector-all
Right - that fix is indeed needed to make it pass. Thing is, with my uClibc config it always fails - so I couldn't make it fail because of this reason :-)
I'll add that hunk in v3.
Thx,
-Vineet