* [PATCH 0/5] Perf fixes for ARC + uClibc
@ 2015-01-06 13:52 ` Vineet Gupta
0 siblings, 0 replies; 21+ messages in thread
From: Vineet Gupta @ 2015-01-06 13:52 UTC (permalink / raw)
To: acme, peterz
Cc: jolsa, mingo, linux-kernel, linux-perf-users, bp, linux-arch,
Alexey.Brodkin, Vineet Gupta
Hi,
This series based off linux-next of 20150105 allows us to build/use perf
for ARC with uClibc based userland.
* 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.
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 +++++
tools/perf/perf-sys.h | 1 -
tools/perf/util/cache.h | 2 ++
tools/perf/util/header.c | 2 +-
11 files changed, 33 insertions(+), 6 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 0/5] Perf fixes for ARC + uClibc
@ 2015-01-06 13:52 ` Vineet Gupta
0 siblings, 0 replies; 21+ messages in thread
From: Vineet Gupta @ 2015-01-06 13:52 UTC (permalink / raw)
To: acme, peterz
Cc: jolsa, mingo, linux-kernel, linux-perf-users, bp, linux-arch,
Alexey.Brodkin, Vineet Gupta
Hi,
This series based off linux-next of 20150105 allows us to build/use perf
for ARC with uClibc based userland.
* 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.
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 +++++
tools/perf/perf-sys.h | 1 -
tools/perf/util/cache.h | 2 ++
tools/perf/util/header.c | 2 +-
11 files changed, 33 insertions(+), 6 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 1/5] perf tools: [uclibc] fix statfs.f_type data type mismatch build error
2015-01-06 13:52 ` Vineet Gupta
@ 2015-01-06 13:52 ` Vineet Gupta
-1 siblings, 0 replies; 21+ messages in thread
From: Vineet Gupta @ 2015-01-06 13:52 UTC (permalink / raw)
To: acme, peterz
Cc: jolsa, mingo, linux-kernel, linux-perf-users, bp, linux-arch,
Alexey.Brodkin, Cody P Schafer, Vineet Gupta
From: Alexey Brodkin <abrodkin@synopsys.com>
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---------------
Cc: Borislav Petkov <bp@suse.de>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Cody P Schafer <dev@codyps.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: linux-perf-users@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
---
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
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
tools/lib/api/fs/debugfs.c | 2 +-
tools/lib/api/fs/fs.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c
index a74fba6d7743..93aa4cd2416f 100644
--- a/tools/lib/api/fs/debugfs.c
+++ b/tools/lib/api/fs/debugfs.c
@@ -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;
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 65d9be3f9887..15e64921ea84 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -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;
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 1/5] perf tools: [uclibc] fix statfs.f_type data type mismatch build error
@ 2015-01-06 13:52 ` Vineet Gupta
0 siblings, 0 replies; 21+ messages in thread
From: Vineet Gupta @ 2015-01-06 13:52 UTC (permalink / raw)
To: acme, peterz
Cc: jolsa, mingo, linux-kernel, linux-perf-users, bp, linux-arch,
Alexey.Brodkin, Cody P Schafer, Vineet Gupta
From: Alexey Brodkin <abrodkin@synopsys.com>
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---------------
Cc: Borislav Petkov <bp@suse.de>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Cody P Schafer <dev@codyps.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: linux-perf-users@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
---
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
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
tools/lib/api/fs/debugfs.c | 2 +-
tools/lib/api/fs/fs.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c
index a74fba6d7743..93aa4cd2416f 100644
--- a/tools/lib/api/fs/debugfs.c
+++ b/tools/lib/api/fs/debugfs.c
@@ -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;
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 65d9be3f9887..15e64921ea84 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -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;
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 2/5] perf tools: [uclibc] Elide strlcpy warning
2015-01-06 13:52 ` Vineet Gupta
@ 2015-01-06 13:52 ` Vineet Gupta
-1 siblings, 0 replies; 21+ messages in thread
From: Vineet Gupta @ 2015-01-06 13:52 UTC (permalink / raw)
To: acme, peterz
Cc: jolsa, mingo, linux-kernel, linux-perf-users, bp, linux-arch,
Alexey.Brodkin, 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------------------
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
tools/perf/util/cache.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index 5cf9e1b5989d..d04d770d90f6 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -71,7 +71,9 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2
extern 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 */
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 2/5] perf tools: [uclibc] Elide strlcpy warning
@ 2015-01-06 13:52 ` Vineet Gupta
0 siblings, 0 replies; 21+ messages in thread
From: Vineet Gupta @ 2015-01-06 13:52 UTC (permalink / raw)
To: acme, peterz
Cc: jolsa, mingo, linux-kernel, linux-perf-users, bp, linux-arch,
Alexey.Brodkin, 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------------------
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
tools/perf/util/cache.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index 5cf9e1b5989d..d04d770d90f6 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -71,7 +71,9 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2
extern 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 */
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 3/5] perf tools: [uclibc] Avoid build splat for syscall numbers
2015-01-06 13:52 ` Vineet Gupta
@ 2015-01-06 13:52 ` Vineet Gupta
-1 siblings, 0 replies; 21+ messages in thread
From: Vineet Gupta @ 2015-01-06 13:52 UTC (permalink / raw)
To: acme, peterz
Cc: jolsa, mingo, linux-kernel, linux-perf-users, bp, linux-arch,
Alexey.Brodkin, 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 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-------------------
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
tools/perf/bench/sched-pipe.c | 1 -
tools/perf/builtin-top.c | 1 -
tools/perf/perf-sys.h | 1 -
3 files changed, 3 deletions(-)
diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c
index 07a8d7646a15..59b1af5b9447 100644
--- a/tools/perf/bench/sched-pipe.c
+++ b/tools/perf/bench/sched-pipe.c
@@ -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>
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 0aa7747ff139..233ffff1b31b 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -66,7 +66,6 @@
#include <sys/utsname.h>
#include <sys/mman.h>
-#include <linux/unistd.h>
#include <linux/types.h>
static volatile int done;
diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h
index 3183809ff6d9..7b7cb7396b69 100644
--- a/tools/perf/perf-sys.h
+++ b/tools/perf/perf-sys.h
@@ -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")
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 3/5] perf tools: [uclibc] Avoid build splat for syscall numbers
@ 2015-01-06 13:52 ` Vineet Gupta
0 siblings, 0 replies; 21+ messages in thread
From: Vineet Gupta @ 2015-01-06 13:52 UTC (permalink / raw)
To: acme, peterz
Cc: jolsa, mingo, linux-kernel, linux-perf-users, bp, linux-arch,
Alexey.Brodkin, 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 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-------------------
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
tools/perf/bench/sched-pipe.c | 1 -
tools/perf/builtin-top.c | 1 -
tools/perf/perf-sys.h | 1 -
3 files changed, 3 deletions(-)
diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c
index 07a8d7646a15..59b1af5b9447 100644
--- a/tools/perf/bench/sched-pipe.c
+++ b/tools/perf/bench/sched-pipe.c
@@ -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>
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 0aa7747ff139..233ffff1b31b 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -66,7 +66,6 @@
#include <sys/utsname.h>
#include <sys/mman.h>
-#include <linux/unistd.h>
#include <linux/types.h>
static volatile int done;
diff --git a/tools/perf/perf-sys.h b/tools/perf/perf-sys.h
index 3183809ff6d9..7b7cb7396b69 100644
--- a/tools/perf/perf-sys.h
+++ b/tools/perf/perf-sys.h
@@ -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")
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 4/5] perf tools: [uclibc] don't rely on glibc malloc working for sz 0
2015-01-06 13:52 ` Vineet Gupta
@ 2015-01-06 13:52 ` Vineet Gupta
-1 siblings, 0 replies; 21+ messages in thread
From: Vineet Gupta @ 2015-01-06 13:52 UTC (permalink / raw)
To: acme, peterz
Cc: jolsa, mingo, linux-kernel, linux-perf-users, bp, linux-arch,
Alexey.Brodkin, Vineet Gupta
When 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 <------
}
}
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
| 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--git a/tools/perf/util/header.c b/tools/perf/util/header.c
index b20e40c74468..43671068ce75 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2532,7 +2532,7 @@ int perf_session__read_header(struct perf_session *session)
*/
perf_evlist__add(session->evlist, evsel);
- nr_ids = f_attr.ids.size / sizeof(u64);
+ nr_ids = f_attr.ids.size / sizeof(u64) ? : 1;
/*
* We don't have the cpu and thread maps on the header, so
* for allocating the perf_sample_id table we fake 1 cpu and
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 4/5] perf tools: [uclibc] don't rely on glibc malloc working for sz 0
@ 2015-01-06 13:52 ` Vineet Gupta
0 siblings, 0 replies; 21+ messages in thread
From: Vineet Gupta @ 2015-01-06 13:52 UTC (permalink / raw)
To: acme, peterz
Cc: jolsa, mingo, linux-kernel, linux-perf-users, bp, linux-arch,
Alexey.Brodkin, Vineet Gupta
When 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 <------
}
}
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
| 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--git a/tools/perf/util/header.c b/tools/perf/util/header.c
index b20e40c74468..43671068ce75 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2532,7 +2532,7 @@ int perf_session__read_header(struct perf_session *session)
*/
perf_evlist__add(session->evlist, evsel);
- nr_ids = f_attr.ids.size / sizeof(u64);
+ nr_ids = f_attr.ids.size / sizeof(u64) ? : 1;
/*
* We don't have the cpu and thread maps on the header, so
* for allocating the perf_sample_id table we fake 1 cpu and
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 5/5] perf tools: [uclibc] provide stub for pthread_attr_setaffinity_np
2015-01-06 13:52 ` Vineet Gupta
@ 2015-01-06 13:52 ` Vineet Gupta
-1 siblings, 0 replies; 21+ messages in thread
From: Vineet Gupta @ 2015-01-06 13:52 UTC (permalink / raw)
To: acme, peterz
Cc: jolsa, mingo, linux-kernel, linux-perf-users, bp, linux-arch,
Alexey.Brodkin, Vineet Gupta
uClibc Linuxthreads.old doesnt support pthread_attr_setaffinity_np()
call
----------------->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-----------------------
Signed-off-by: Vineet Gupta <vgupta@synopsys.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 +++++
4 files changed, 28 insertions(+)
diff --git a/tools/perf/bench/futex.h b/tools/perf/bench/futex.h
index 71f2844cf97f..7ed22ff1e1ac 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 5d4b039fe1ed..6b59662136fa 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 53f19b5dbc37..e9b99bb29348 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
+
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 652e0098eba6..6d4d09323922 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;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 5/5] perf tools: [uclibc] provide stub for pthread_attr_setaffinity_np
@ 2015-01-06 13:52 ` Vineet Gupta
0 siblings, 0 replies; 21+ messages in thread
From: Vineet Gupta @ 2015-01-06 13:52 UTC (permalink / raw)
To: acme, peterz
Cc: jolsa, mingo, linux-kernel, linux-perf-users, bp, linux-arch,
Alexey.Brodkin, Vineet Gupta
uClibc Linuxthreads.old doesnt support pthread_attr_setaffinity_np()
call
----------------->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-----------------------
Signed-off-by: Vineet Gupta <vgupta@synopsys.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 +++++
4 files changed, 28 insertions(+)
diff --git a/tools/perf/bench/futex.h b/tools/perf/bench/futex.h
index 71f2844cf97f..7ed22ff1e1ac 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 5d4b039fe1ed..6b59662136fa 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 53f19b5dbc37..e9b99bb29348 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
+
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 652e0098eba6..6d4d09323922 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;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 0/5] Perf fixes for ARC + uClibc
2015-01-06 13:52 ` Vineet Gupta
` (5 preceding siblings ...)
(?)
@ 2015-01-06 15:13 ` Arnaldo Carvalho de Melo
2015-01-07 5:16 ` Vineet Gupta
2015-01-07 7:38 ` Vineet Gupta
-1 siblings, 2 replies; 21+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-01-06 15:13 UTC (permalink / raw)
To: Vineet Gupta
Cc: peterz, jolsa, mingo, linux-kernel, linux-perf-users, bp,
linux-arch, Alexey.Brodkin
Em Tue, Jan 06, 2015 at 07:22:10PM +0530, Vineet Gupta escreveu:
> Hi,
>
> This series based off linux-next of 20150105 allows us to build/use perf
> for ARC with uClibc based userland.
Do you have some ready made ARC VM image with devel tools I could use with qemu?
- Arnaldo
> * 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.
>
> 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 +++++
> tools/perf/perf-sys.h | 1 -
> tools/perf/util/cache.h | 2 ++
> tools/perf/util/header.c | 2 +-
> 11 files changed, 33 insertions(+), 6 deletions(-)
>
> --
> 1.9.1
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 0/5] Perf fixes for ARC + uClibc
2015-01-06 15:13 ` [PATCH 0/5] Perf fixes for ARC + uClibc Arnaldo Carvalho de Melo
@ 2015-01-07 5:16 ` Vineet Gupta
2015-01-07 7:38 ` Vineet Gupta
1 sibling, 0 replies; 21+ messages in thread
From: Vineet Gupta @ 2015-01-07 5:16 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: Francois Bedard, peterz, jolsa, mingo, linux-kernel,
linux-perf-users, bp, linux-arch, Alexey.Brodkin
On Tuesday 06 January 2015 08:43 PM, Arnaldo Carvalho de Melo wrote:
Em Tue, Jan 06, 2015 at 07:22:10PM +0530, Vineet Gupta escreveu:
> Hi,
>
> This series based off linux-next of 20150105 allows us to build/use perf
> for ARC with uClibc based userland.
Do you have some ready made ARC VM image with devel tools I could use with qemu?
- Arnaldo
Nope we don't have a QEMU port or plans for it. We have a non FOSS Instruction set simulator - and an upcoming tools release might have a free / lite version of it. I need to check with higher powers to possibly provide u a VM equipped with that !
Thx,
-Vineet
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 0/5] Perf fixes for ARC + uClibc
2015-01-06 15:13 ` [PATCH 0/5] Perf fixes for ARC + uClibc Arnaldo Carvalho de Melo
2015-01-07 5:16 ` Vineet Gupta
@ 2015-01-07 7:38 ` Vineet Gupta
2015-01-09 18:47 ` Alexey Brodkin
1 sibling, 1 reply; 21+ messages in thread
From: Vineet Gupta @ 2015-01-07 7:38 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: peterz, jolsa, mingo, linux-kernel, linux-perf-users, bp,
linux-arch, Alexey.Brodkin
On Tuesday 06 January 2015 08:43 PM, Arnaldo Carvalho de Melo wrote:
Em Tue, Jan 06, 2015 at 07:22:10PM +0530, Vineet Gupta escreveu:
> Hi,
>
> This series based off linux-next of 20150105 allows us to build/use perf
> for ARC with uClibc based userland.
Do you have some ready made ARC VM image with devel tools I could use with qemu?
- Arnaldo
FWIW, most of the issues I posted fixes for can be reproduced with building perf with ARC buildroot !
git://github.com:foss-for-synopsys-dwc-arc-processors/buildroot.git
Thx,
-Vineet
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 4/5] perf tools: [uclibc] don't rely on glibc malloc working for sz 0
2015-01-06 13:52 ` Vineet Gupta
(?)
@ 2015-01-08 7:51 ` Namhyung Kim
2015-01-10 10:16 ` Vineet Gupta
-1 siblings, 1 reply; 21+ messages in thread
From: Namhyung Kim @ 2015-01-08 7:51 UTC (permalink / raw)
To: Vineet Gupta
Cc: acme, peterz, jolsa, mingo, linux-kernel, linux-perf-users, bp,
linux-arch, Alexey.Brodkin
Hi Vineet,
On Tue, Jan 06, 2015 at 07:22:14PM +0530, Vineet Gupta wrote:
> When 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 <------
> }
> }
Hmm.. okay. I think we don't need to allocate the id arrays when size
is 0. So perf_event__process_attr() will have the same problem IMHO.
How about this?
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 1e90c8557ede..1d826d63bc20 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -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;
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 5/5] perf tools: [uclibc] provide stub for pthread_attr_setaffinity_np
2015-01-06 13:52 ` Vineet Gupta
(?)
@ 2015-01-08 7:56 ` Namhyung Kim
2015-01-10 10:30 ` Vineet Gupta
-1 siblings, 1 reply; 21+ messages in thread
From: Namhyung Kim @ 2015-01-08 7:56 UTC (permalink / raw)
To: Vineet Gupta
Cc: acme, peterz, jolsa, mingo, linux-kernel, linux-perf-users, bp,
linux-arch, Alexey.Brodkin
On Tue, Jan 06, 2015 at 07:22:15PM +0530, Vineet Gupta wrote:
> uClibc Linuxthreads.old doesnt support pthread_attr_setaffinity_np()
> call
>
> ----------------->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-----------------------
>
> Signed-off-by: Vineet Gupta <vgupta@synopsys.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 +++++
> 4 files changed, 28 insertions(+)
It seems that you fotgot to add the real test file
(test-pthread_attr_setaffinity_np.c?) here..
Thanks,
Namhyung
>
> diff --git a/tools/perf/bench/futex.h b/tools/perf/bench/futex.h
> index 71f2844cf97f..7ed22ff1e1ac 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 5d4b039fe1ed..6b59662136fa 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 53f19b5dbc37..e9b99bb29348 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
> +
> 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 652e0098eba6..6d4d09323922 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;
> }
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 0/5] Perf fixes for ARC + uClibc
2015-01-07 7:38 ` Vineet Gupta
@ 2015-01-09 18:47 ` Alexey Brodkin
0 siblings, 0 replies; 21+ messages in thread
From: Alexey Brodkin @ 2015-01-09 18:47 UTC (permalink / raw)
To: acme
Cc: mingo, peterz, linux-kernel, bp, jolsa, linux-perf-users,
Vineet Gupta, linux-arch
Hi Arnaldo,
On Wed, 2015-01-07 at 07:38 +0000, Vineet Gupta wrote:
> On Tuesday 06 January 2015 08:43 PM, Arnaldo Carvalho de Melo wrote:
>
> > Em Tue, Jan 06, 2015 at 07:22:10PM +0530, Vineet Gupta escreveu:
> > > > Hi,
> > > >
> > > > This series based off linux-next of 20150105 allows us to build/use perf
> > > > for ARC with uClibc based userland.
> > Do you have some ready made ARC VM image with devel tools I could use with qemu?
> >
> > - Arnaldo
> >
>
> FWIW, most of the issues I posted fixes for can be reproduced with
> building perf with ARC buildroot !
>
> git://github.com:foss-for-synopsys-dwc-arc-processors/buildroot.git
To reproduce described build problems (covered in patches 1, 2, 3, 5) you may indeed use Buildroot.
Just get the most recent release from here http://buildroot.uclibc.org/downloads/buildroot-2014.11.tar.gz
and use load following configuration in "menuconfig":
--->---
BR2_arcle=y
BR2_TOOLCHAIN_BUILDROOT_LARGEFILE=y
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_DEFCONFIG="fpga"
BR2_PACKAGE_PERF=y
BR2_TARGET_ROOTFS_INITRAMFS=y
--->---
Then say "make" and you'll see the problem.
If you experience any problems trying to follow my advice please let me
know and I'll try to help you.
-Alexey
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 4/5] perf tools: [uclibc] don't rely on glibc malloc working for sz 0
2015-01-08 7:51 ` Namhyung Kim
@ 2015-01-10 10:16 ` Vineet Gupta
2015-01-10 10:44 ` Namhyung Kim
0 siblings, 1 reply; 21+ messages in thread
From: Vineet Gupta @ 2015-01-10 10:16 UTC (permalink / raw)
To: Namhyung Kim
Cc: acme, peterz, jolsa, mingo, linux-kernel, linux-perf-users, bp,
linux-arch, Alexey.Brodkin
On Thursday 08 January 2015 01:23 PM, Namhyung Kim wrote:
> Hi Vineet,
>
> On Tue, Jan 06, 2015 at 07:22:14PM +0530, Vineet Gupta wrote:
>> When 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 <------
>> }
>> }
> Hmm.. okay. I think we don't need to allocate the id arrays when size
> is 0. So perf_event__process_attr() will have the same problem IMHO.
> How about this?
>
>
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 1e90c8557ede..1d826d63bc20 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -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;
Fine by me as I'm not too familiar with perf tools internals.
So I need to spin a v2 for this or would you rather create a patch with me as
Reported-by:
-Vineet
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 5/5] perf tools: [uclibc] provide stub for pthread_attr_setaffinity_np
2015-01-08 7:56 ` Namhyung Kim
@ 2015-01-10 10:30 ` Vineet Gupta
0 siblings, 0 replies; 21+ messages in thread
From: Vineet Gupta @ 2015-01-10 10:30 UTC (permalink / raw)
To: Namhyung Kim
Cc: acme, peterz, jolsa, mingo, linux-kernel, linux-perf-users, bp,
linux-arch, Alexey.Brodkin
Hi Namhyung,
On Thursday 08 January 2015 01:28 PM, Namhyung Kim wrote:
> On Tue, Jan 06, 2015 at 07:22:15PM +0530, Vineet Gupta wrote:
>> > uClibc Linuxthreads.old doesnt support pthread_attr_setaffinity_np()
>> > call
>> >
>> > ----------------->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-----------------------
>> >
>> > Signed-off-by: Vineet Gupta <vgupta@synopsys.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 +++++
>> > 4 files changed, 28 insertions(+)
> It seems that you fotgot to add the real test file
> (test-pthread_attr_setaffinity_np.c?) here..
Indeed, apologies for the snafu. I'll include it in v2 for the series.
Any thoughts on rest of patches for the series.
Thanks for the careful review so far.
-Vineet
>
> Thanks,
> Namhyung
>
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 4/5] perf tools: [uclibc] don't rely on glibc malloc working for sz 0
2015-01-10 10:16 ` Vineet Gupta
@ 2015-01-10 10:44 ` Namhyung Kim
0 siblings, 0 replies; 21+ messages in thread
From: Namhyung Kim @ 2015-01-10 10:44 UTC (permalink / raw)
To: Vineet Gupta
Cc: acme, peterz, jolsa, mingo, linux-kernel, linux-perf-users, bp,
linux-arch, Alexey.Brodkin
On Sat, Jan 10, 2015 at 10:16:06AM +0000, Vineet Gupta wrote:
> On Thursday 08 January 2015 01:23 PM, Namhyung Kim wrote:
> > Hmm.. okay. I think we don't need to allocate the id arrays when size
> > is 0. So perf_event__process_attr() will have the same problem IMHO.
> > How about this?
> >
> >
> > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> > index 1e90c8557ede..1d826d63bc20 100644
> > --- a/tools/perf/util/evsel.c
> > +++ b/tools/perf/util/evsel.c
> > @@ -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;
>
> Fine by me as I'm not too familiar with perf tools internals.
> So I need to spin a v2 for this or would you rather create a patch with me as
> Reported-by:
Please include this in your v2 and adds me as Suggested-by:
Thanks,
Namhyung
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2015-01-10 10:45 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-06 13:52 [PATCH 0/5] Perf fixes for ARC + uClibc Vineet Gupta
2015-01-06 13:52 ` Vineet Gupta
2015-01-06 13:52 ` [PATCH 1/5] perf tools: [uclibc] fix statfs.f_type data type mismatch build error Vineet Gupta
2015-01-06 13:52 ` Vineet Gupta
2015-01-06 13:52 ` [PATCH 2/5] perf tools: [uclibc] Elide strlcpy warning Vineet Gupta
2015-01-06 13:52 ` Vineet Gupta
2015-01-06 13:52 ` [PATCH 3/5] perf tools: [uclibc] Avoid build splat for syscall numbers Vineet Gupta
2015-01-06 13:52 ` Vineet Gupta
2015-01-06 13:52 ` [PATCH 4/5] perf tools: [uclibc] don't rely on glibc malloc working for sz 0 Vineet Gupta
2015-01-06 13:52 ` Vineet Gupta
2015-01-08 7:51 ` Namhyung Kim
2015-01-10 10:16 ` Vineet Gupta
2015-01-10 10:44 ` Namhyung Kim
2015-01-06 13:52 ` [PATCH 5/5] perf tools: [uclibc] provide stub for pthread_attr_setaffinity_np Vineet Gupta
2015-01-06 13:52 ` Vineet Gupta
2015-01-08 7:56 ` Namhyung Kim
2015-01-10 10:30 ` Vineet Gupta
2015-01-06 15:13 ` [PATCH 0/5] Perf fixes for ARC + uClibc Arnaldo Carvalho de Melo
2015-01-07 5:16 ` Vineet Gupta
2015-01-07 7:38 ` Vineet Gupta
2015-01-09 18:47 ` Alexey Brodkin
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.