perf/urgent fixes
Subsystems (2)
Arnaldo Carvalho de Melo
maintainerHi 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)
----------------------------------------------------------------
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
#
Arnaldo Carvalho de Melo
maintainerPATCH 1/3 perf unwind: Use addr_location::addr instead of ip for entries
From: Milian Wolff <[email protected]>
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 +8390224With 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:39LPU-Reference: [email protected]
--- tools/perf/util/unwind-libdw.c | 2 +- tools/perf/util/unwind-libunwind-local.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/unwind-libdw.c +1 -1
@@ -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;
tools/perf/util/unwind-libunwind-local.c +1 -1
@@ -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;
Signature · 1 line
2.7.4
Quoted 87 lines · 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/linuxinto 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.gittags/perf-urgent-for-mingo-20160818for 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::addrinstead 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 at redhat.com>----------------------------------------------------------------
Arnaldo Carvalho de Melo (1):
perf evsel: Do not access outside hw cache name arraysMilian Wolff (1):
perf unwind: Useaddr_location::addrinstead of ip for entriesVineet Gupta (1):
tools lib: Reinstatestrlcpy()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
Quoted 4 lines
real 37m6.200s
user 0m1.830s
sys 0m2.653s
#
Pulled, thanks a lot Arnaldo!
Ingo
Arnaldo Carvalho de Melo
maintainerPATCH 2/3 tools lib: Reinstate strlcpy() header guard with __UCLIBC__
In reply to Arnaldo Carvalho de MeloFrom: Vineet Gupta <[email protected]>
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.
--- tools/include/linux/string.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tools/include/linux/string.h +5 -1
@@ -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
Signature · 1 line
2.7.4
Arnaldo Carvalho de Melo
maintainerPATCH 3/3 perf evsel: Do not access outside hw cache name arrays
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
We have to check if the values are >= *_MAX, not just >, fix it.
Quoted 1 line
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]$
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=153351
--- tools/perf/util/evsel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/util/evsel.c +3 -3
@@ -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" ;
Signature · 1 line
2.7.4