* [GIT PULL 0/3] perf/urgent fixes
@ 2016-08-18 20:40 Arnaldo Carvalho de Melo
2016-08-18 20:40 ` [PATCH 1/3] perf unwind: Use addr_location::addr instead of ip for entries Arnaldo Carvalho de Melo
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-08-18 20:40 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
Alexey Brodkin, Brian Sweeney, Clark Williams, David Ahern,
Jiri Olsa, Josh Poimboeuf, linux-snps-arc, Milian Wolff,
Namhyung Kim, Peter Zijlstra, Petri Gynther, Vineet Gupta,
Wang Nan, Arnaldo Carvalho de Melo
Hi Ingo,
Please consider pulling,
- Arnaldo
Build stats at the end of this message.
The following changes since commit 3cace81ea5bb0b3f2b97cab8e2c8e1fae2feb7ed:
Merge tag 'perf-urgent-for-mingo-20160815' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent (2016-08-16 20:08:56 +0200)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-urgent-for-mingo-20160818
for you to fetch changes up to c53412ee8c7ec31373a4176ff7f3a6b79296c05c:
perf evsel: Do not access outside hw cache name arrays (2016-08-18 16:39:46 -0300)
----------------------------------------------------------------
perf/urgent fixes:
- Do not access outside hw cache name arrays (Arnaldo Carvalho de Melo)
- Use addr_location::addr instead of ip for entries when unwinding using
DWARF CFI, fixing the "srcline" information for userspace application
callchains (Milian Wolff)
- Reinstate strlcpy() header guard with __UCLIBC__, fixing the build
with uclibc, detected when building for the ARC architecture (Vineet Gupta)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
----------------------------------------------------------------
Arnaldo Carvalho de Melo (1):
perf evsel: Do not access outside hw cache name arrays
Milian Wolff (1):
perf unwind: Use addr_location::addr instead of ip for entries
Vineet Gupta (1):
tools lib: Reinstate strlcpy() header guard with __UCLIBC__
tools/include/linux/string.h | 6 +++++-
tools/perf/util/evsel.c | 6 +++---
tools/perf/util/unwind-libdw.c | 2 +-
tools/perf/util/unwind-libunwind-local.c | 2 +-
4 files changed, 10 insertions(+), 6 deletions(-)
Build stats, now only android-ndk doesn't build with NO_LIBELF=1, as it
doesn't even have libelf to cross build with, and the non-cross builds
build objtool, uClibc and an ARC architecture cross build image are in
the works:
# time dm
1 77.199181517 alpine:3.4: Ok
2 30.215940343 android-ndk:r12b-arm: Ok
3 80.593965325 archlinux:latest: Ok
4 45.102186377 centos:5: Ok
5 67.078635441 centos:6: Ok
6 73.582617061 centos:7: Ok
7 65.462644128 debian:7: Ok
8 69.919139691 debian:8: Ok
9 77.192563446 debian:experimental: Ok
10 80.651363745 fedora:20: Ok
11 85.566954259 fedora:21: Ok
12 87.547437162 fedora:22: Ok
13 94.866327046 fedora:23: Ok
14 93.829320269 fedora:24: Ok
15 94.860933711 fedora:rawhide: Ok
16 88.890456556 mageia:5: Ok
17 85.622890293 opensuse:13.2: Ok
18 87.232034972 opensuse:42.1: Ok
19 94.807172866 opensuse:tumbleweed: Ok
20 72.189153053 ubuntu:12.04.5: Ok
21 86.275708891 ubuntu:14.04.4: Ok
22 90.743742216 ubuntu:15.10: Ok
23 86.931085419 ubuntu:16.04: Ok
24 67.823595709 ubuntu:16.04-x-arm: Ok
25 62.985390761 ubuntu:16.04-x-arm64: Ok
26 64.727635984 ubuntu:16.04-x-powerpc64: Ok
27 63.208264990 ubuntu:16.04-x-powerpc64el: Ok
28 64.685772233 ubuntu:16.04-x-s390: Ok
29 85.089091168 ubuntu:16.10: Ok
2224.88s
real 37m6.200s
user 0m1.830s
sys 0m2.653s
#
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] perf unwind: Use addr_location::addr instead of ip for entries
2016-08-18 20:40 [GIT PULL 0/3] perf/urgent fixes Arnaldo Carvalho de Melo
@ 2016-08-18 20:40 ` Arnaldo Carvalho de Melo
2016-08-18 20:40 ` [PATCH 2/3] tools lib: Reinstate strlcpy() header guard with __UCLIBC__ Arnaldo Carvalho de Melo
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-08-18 20:40 UTC (permalink / raw)
To: Ingo Molnar; +Cc: linux-kernel, Milian Wolff, Arnaldo Carvalho de Melo
From: Milian Wolff <milian.wolff@kdab.com>
This fixes the srcline translation for call chains of user space
applications.
Before we got:
perf report --stdio --no-children -s sym,srcline -g address
8.92% [.] main mandelbrot.h:41
|
|--3.70%--main +8390240
| __libc_start_main +139950056726769
| _start +8388650
|
|--2.74%--main +8390189
|
--2.08%--main +8390296
__libc_start_main +139950056726769
_start +8388650
7.59% [.] main complex:1326
|
|--4.79%--main +8390203
| __libc_start_main +139950056726769
| _start +8388650
|
--2.80%--main +8390219
7.12% [.] __muldc3 libgcc2.c:1945
|
|--3.76%--__muldc3 +139950060519490
| main +8390224
| __libc_start_main +139950056726769
| _start +8388650
|
--3.32%--__muldc3 +139950060519512
main +8390224
With this patch applied, we instead get:
perf report --stdio --no-children -s sym,srcline -g address
8.92% [.] main mandelbrot.h:41
|
|--3.70%--main mandelbrot.h:41
| __libc_start_main +241
| _start +4194346
|
|--2.74%--main mandelbrot.h:41
|
--2.08%--main mandelbrot.h:41
__libc_start_main +241
_start +4194346
7.59% [.] main complex:1326
|
|--4.79%--main complex:1326
| __libc_start_main +241
| _start +4194346
|
--2.80%--main complex:1326
7.12% [.] __muldc3 libgcc2.c:1945
|
|--3.76%--__muldc3 libgcc2.c:1945
| main mandelbrot.h:39
| __libc_start_main +241
| _start +4194346
|
--3.32%--__muldc3 libgcc2.c:1945
main mandelbrot.h:39
Suggested-and-Acked-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Milian Wolff <milian.wolff@kdab.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
LPU-Reference: 20160816153926.11288-1-milian.wolff@kdab.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/unwind-libdw.c | 2 +-
tools/perf/util/unwind-libunwind-local.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index cf5e250bc78e..783a53fb7a4e 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -66,7 +66,7 @@ static int entry(u64 ip, struct unwind_info *ui)
if (__report_module(&al, ip, ui))
return -1;
- e->ip = ip;
+ e->ip = al.addr;
e->map = al.map;
e->sym = al.sym;
diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
index 97c0f8fc5561..20c2e5743903 100644
--- a/tools/perf/util/unwind-libunwind-local.c
+++ b/tools/perf/util/unwind-libunwind-local.c
@@ -542,7 +542,7 @@ static int entry(u64 ip, struct thread *thread,
thread__find_addr_location(thread, PERF_RECORD_MISC_USER,
MAP__FUNCTION, ip, &al);
- e.ip = ip;
+ e.ip = al.addr;
e.map = al.map;
e.sym = al.sym;
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] tools lib: Reinstate strlcpy() header guard with __UCLIBC__
2016-08-18 20:40 [GIT PULL 0/3] perf/urgent fixes Arnaldo Carvalho de Melo
2016-08-18 20:40 ` [PATCH 1/3] perf unwind: Use addr_location::addr instead of ip for entries Arnaldo Carvalho de Melo
@ 2016-08-18 20:40 ` Arnaldo Carvalho de Melo
2016-08-18 20:40 ` [PATCH 3/3] perf evsel: Do not access outside hw cache name arrays Arnaldo Carvalho de Melo
2016-08-18 20:51 ` [GIT PULL 0/3] perf/urgent fixes Ingo Molnar
3 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-08-18 20:40 UTC (permalink / raw)
To: Ingo Molnar
Cc: linux-kernel, Vineet Gupta, Vineet Gupta, Adrian Hunter,
Alexey Brodkin, David Ahern, Jiri Olsa, Josh Poimboeuf,
Namhyung Kim, Peter Zijlstra, Petri Gynther, Wang Nan,
linux-snps-arc, Arnaldo Carvalho de Melo
From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
perf tools build in recent kernels spews splat when cross compiling with uClibc:
| CC util/alias.o
| In file included from tools/perf/util/../ui/../util/cache.h:8:0,
| from tools/perf/util/../ui/helpline.h:7,
| from tools/perf/util/debug.h:8,
| from arch/../util/cpumap.h:9,
| from arch/../util/env.h:5,
| from arch/common.h:4,
| from arch/common.c:3:
| tools/include/linux/string.h:12:15: warning: redundant redeclaration of ‘strlcpy’ [-Wredundant-decls]
| extern size_t strlcpy(char *dest, const char *src, size_t size);
^
This is after commit 61a6445e463a31 ("tools lib: Guard the strlcpy() header with
__GLIBC__").
The problem is uClibc also defines __GLIBC__ for exported headers for
applications. So add that specific check to not trip for uClibc.
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Petri Gynther <pgynther@google.com>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: linux-snps-arc@lists.infradead.org
Link: http://lkml.kernel.org/r/1471537703-16439-1-git-send-email-vgupta@synopsys.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/include/linux/string.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/include/linux/string.h b/tools/include/linux/string.h
index b96879477311..f436d2420a18 100644
--- a/tools/include/linux/string.h
+++ b/tools/include/linux/string.h
@@ -8,7 +8,11 @@ void *memdup(const void *src, size_t len);
int strtobool(const char *s, bool *res);
-#ifdef __GLIBC__
+/*
+ * glibc based builds needs the extern while uClibc doesn't.
+ * However uClibc headers also define __GLIBC__ hence the hack below
+ */
+#if defined(__GLIBC__) && !defined(__UCLIBC__)
extern size_t strlcpy(char *dest, const char *src, size_t size);
#endif
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] perf evsel: Do not access outside hw cache name arrays
2016-08-18 20:40 [GIT PULL 0/3] perf/urgent fixes Arnaldo Carvalho de Melo
2016-08-18 20:40 ` [PATCH 1/3] perf unwind: Use addr_location::addr instead of ip for entries Arnaldo Carvalho de Melo
2016-08-18 20:40 ` [PATCH 2/3] tools lib: Reinstate strlcpy() header guard with __UCLIBC__ Arnaldo Carvalho de Melo
@ 2016-08-18 20:40 ` Arnaldo Carvalho de Melo
2016-08-18 20:51 ` [GIT PULL 0/3] perf/urgent fixes Ingo Molnar
3 siblings, 0 replies; 5+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-08-18 20:40 UTC (permalink / raw)
To: Ingo Molnar; +Cc: linux-kernel, Arnaldo Carvalho de Melo, Jiri Olsa
From: Arnaldo Carvalho de Melo <acme@redhat.com>
We have to check if the values are >= *_MAX, not just >, fix it.
>From the bugzilla report:
''In file /tools/perf/util/evsel.c function __perf_evsel__hw_cache_name
it appears that there is a bug that reads beyond the end of the buffer.
The statement "if (type > PERF_COUNT_HW_CACHE_MAX)" allows type to be
equal to the maximum value. Later, when statement "if
(!perf_evsel__is_cache_op_valid(type, op))" is executed, the function
can access array perf_evsel__hw_cache_stat[type] beyond the end of the
buffer.
It appears to me that the statement "if (type > PERF_COUNT_HW_CACHE_MAX)"
should be "if (type >= PERF_COUNT_HW_CACHE_MAX)"
Bug found with Coverity and manual code review. No attempts were made to
execute the code with a maximum type value.''
Committer note:
Testing it:
$ perf record -e $(echo $(perf list cache | cut -d \[ -f1) | sed 's/ /,/g') usleep 1
[ perf record: Woken up 16 times to write data ]
[ perf record: Captured and wrote 0.023 MB perf.data (34 samples) ]
$ perf evlist
L1-dcache-load-misses
L1-dcache-loads
L1-dcache-stores
L1-icache-load-misses
LLC-load-misses
LLC-loads
LLC-store-misses
LLC-stores
branch-load-misses
branch-loads
dTLB-load-misses
dTLB-loads
dTLB-store-misses
dTLB-stores
iTLB-load-misses
iTLB-loads
node-load-misses
node-loads
node-store-misses
node-stores
$ perf list cache
List of pre-defined events (to be used in -e):
L1-dcache-load-misses [Hardware cache event]
L1-dcache-loads [Hardware cache event]
L1-dcache-stores [Hardware cache event]
L1-icache-load-misses [Hardware cache event]
LLC-load-misses [Hardware cache event]
LLC-loads [Hardware cache event]
LLC-store-misses [Hardware cache event]
LLC-stores [Hardware cache event]
branch-load-misses [Hardware cache event]
branch-loads [Hardware cache event]
dTLB-load-misses [Hardware cache event]
dTLB-loads [Hardware cache event]
dTLB-store-misses [Hardware cache event]
dTLB-stores [Hardware cache event]
iTLB-load-misses [Hardware cache event]
iTLB-loads [Hardware cache event]
node-load-misses [Hardware cache event]
node-loads [Hardware cache event]
node-store-misses [Hardware cache event]
node-stores [Hardware cache event]
$
Reported-by: Brian Sweeney <bsweeney@lgsinnovations.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=153351
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/evsel.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index d9b80ef881cd..21fd573106ed 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -507,17 +507,17 @@ static int __perf_evsel__hw_cache_name(u64 config, char *bf, size_t size)
u8 op, result, type = (config >> 0) & 0xff;
const char *err = "unknown-ext-hardware-cache-type";
- if (type > PERF_COUNT_HW_CACHE_MAX)
+ if (type >= PERF_COUNT_HW_CACHE_MAX)
goto out_err;
op = (config >> 8) & 0xff;
err = "unknown-ext-hardware-cache-op";
- if (op > PERF_COUNT_HW_CACHE_OP_MAX)
+ if (op >= PERF_COUNT_HW_CACHE_OP_MAX)
goto out_err;
result = (config >> 16) & 0xff;
err = "unknown-ext-hardware-cache-result";
- if (result > PERF_COUNT_HW_CACHE_RESULT_MAX)
+ if (result >= PERF_COUNT_HW_CACHE_RESULT_MAX)
goto out_err;
err = "invalid-cache";
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [GIT PULL 0/3] perf/urgent fixes
2016-08-18 20:40 [GIT PULL 0/3] perf/urgent fixes Arnaldo Carvalho de Melo
` (2 preceding siblings ...)
2016-08-18 20:40 ` [PATCH 3/3] perf evsel: Do not access outside hw cache name arrays Arnaldo Carvalho de Melo
@ 2016-08-18 20:51 ` Ingo Molnar
3 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2016-08-18 20:51 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo
Cc: linux-kernel, Adrian Hunter, Alexey Brodkin, Brian Sweeney,
Clark Williams, David Ahern, Jiri Olsa, Josh Poimboeuf,
linux-snps-arc, Milian Wolff, Namhyung Kim, Peter Zijlstra,
Petri Gynther, Vineet Gupta, Wang Nan, Arnaldo Carvalho de Melo
* Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> Hi Ingo,
>
> Please consider pulling,
>
> - Arnaldo
>
> Build stats at the end of this message.
>
> The following changes since commit 3cace81ea5bb0b3f2b97cab8e2c8e1fae2feb7ed:
>
> Merge tag 'perf-urgent-for-mingo-20160815' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent (2016-08-16 20:08:56 +0200)
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-urgent-for-mingo-20160818
>
> for you to fetch changes up to c53412ee8c7ec31373a4176ff7f3a6b79296c05c:
>
> perf evsel: Do not access outside hw cache name arrays (2016-08-18 16:39:46 -0300)
>
> ----------------------------------------------------------------
> perf/urgent fixes:
>
> - Do not access outside hw cache name arrays (Arnaldo Carvalho de Melo)
>
> - Use addr_location::addr instead of ip for entries when unwinding using
> DWARF CFI, fixing the "srcline" information for userspace application
> callchains (Milian Wolff)
>
> - Reinstate strlcpy() header guard with __UCLIBC__, fixing the build
> with uclibc, detected when building for the ARC architecture (Vineet Gupta)
>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> ----------------------------------------------------------------
> Arnaldo Carvalho de Melo (1):
> perf evsel: Do not access outside hw cache name arrays
>
> Milian Wolff (1):
> perf unwind: Use addr_location::addr instead of ip for entries
>
> Vineet Gupta (1):
> tools lib: Reinstate strlcpy() header guard with __UCLIBC__
>
> tools/include/linux/string.h | 6 +++++-
> tools/perf/util/evsel.c | 6 +++---
> tools/perf/util/unwind-libdw.c | 2 +-
> tools/perf/util/unwind-libunwind-local.c | 2 +-
> 4 files changed, 10 insertions(+), 6 deletions(-)
>
> Build stats, now only android-ndk doesn't build with NO_LIBELF=1, as it
> doesn't even have libelf to cross build with, and the non-cross builds
> build objtool, uClibc and an ARC architecture cross build image are in
> the works:
>
> # time dm
> 1 77.199181517 alpine:3.4: Ok
> 2 30.215940343 android-ndk:r12b-arm: Ok
> 3 80.593965325 archlinux:latest: Ok
> 4 45.102186377 centos:5: Ok
> 5 67.078635441 centos:6: Ok
> 6 73.582617061 centos:7: Ok
> 7 65.462644128 debian:7: Ok
> 8 69.919139691 debian:8: Ok
> 9 77.192563446 debian:experimental: Ok
> 10 80.651363745 fedora:20: Ok
> 11 85.566954259 fedora:21: Ok
> 12 87.547437162 fedora:22: Ok
> 13 94.866327046 fedora:23: Ok
> 14 93.829320269 fedora:24: Ok
> 15 94.860933711 fedora:rawhide: Ok
> 16 88.890456556 mageia:5: Ok
> 17 85.622890293 opensuse:13.2: Ok
> 18 87.232034972 opensuse:42.1: Ok
> 19 94.807172866 opensuse:tumbleweed: Ok
> 20 72.189153053 ubuntu:12.04.5: Ok
> 21 86.275708891 ubuntu:14.04.4: Ok
> 22 90.743742216 ubuntu:15.10: Ok
> 23 86.931085419 ubuntu:16.04: Ok
> 24 67.823595709 ubuntu:16.04-x-arm: Ok
> 25 62.985390761 ubuntu:16.04-x-arm64: Ok
> 26 64.727635984 ubuntu:16.04-x-powerpc64: Ok
> 27 63.208264990 ubuntu:16.04-x-powerpc64el: Ok
> 28 64.685772233 ubuntu:16.04-x-s390: Ok
> 29 85.089091168 ubuntu:16.10: Ok
> 2224.88s
>
> real 37m6.200s
> user 0m1.830s
> sys 0m2.653s
> #
Pulled, thanks a lot Arnaldo!
Ingo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-08-19 3:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-18 20:40 [GIT PULL 0/3] perf/urgent fixes Arnaldo Carvalho de Melo
2016-08-18 20:40 ` [PATCH 1/3] perf unwind: Use addr_location::addr instead of ip for entries Arnaldo Carvalho de Melo
2016-08-18 20:40 ` [PATCH 2/3] tools lib: Reinstate strlcpy() header guard with __UCLIBC__ Arnaldo Carvalho de Melo
2016-08-18 20:40 ` [PATCH 3/3] perf evsel: Do not access outside hw cache name arrays Arnaldo Carvalho de Melo
2016-08-18 20:51 ` [GIT PULL 0/3] perf/urgent fixes Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox