perf: Assorted fixes
Jiri Olsa
reviewercover perf: Assorted fixes
hi,
sending assorted general fixes that queued
up in my other branches.
Also available in here:
https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/fixes
thanks,
jirka
--- include/uapi/linux/perf_event.h | 10 +++++--- kernel/events/callchain.c | 15 ------------ kernel/events/core.c | 54 +++++++++++++++++++++++++++++------------ kernel/events/internal.h | 4 ---- tools/perf/Documentation/perf-report.txt | 8 +++++++ tools/perf/Documentation/perf-script.txt | 23 +++++++++++++++++- tools/perf/Makefile.config | 2 +- tools/perf/Makefile.perf | 2 +- tools/perf/builtin-report.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- tools/perf/builtin-script.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- tools/perf/util/event.c | 8 +++++++ tools/perf/util/event.h | 1 + tools/perf/util/evsel.c | 2 ++ tools/perf/util/session.c | 6 +++-- tools/perf/util/tool.h | 1 + 15 files changed, 342 insertions(+), 54 deletions(-)
Jiri Olsa
reviewerPATCH 1/12 perf tools: Enable LIBBABELTRACE by default
There's no reason anymore to treat babel trace in a special way, because a) we no longer display its state b) the needed babeltrace library is now out and well adopted among distros.
--- tools/perf/Makefile.config | 2 +- tools/perf/Makefile.perf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/Makefile.config +1 -1
@@ -780,7 +780,7 @@ else NO_PERF_READ_VDSOX32 := 1 endif -ifdef LIBBABELTRACE +ifndef NO_LIBBABELTRACE $(call feature_check,libbabeltrace) ifeq ($(feature-libbabeltrace), 1) CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
tools/perf/Makefile.perf +1 -1
@@ -77,7 +77,7 @@ include ../scripts/utilities.mak # # Define NO_ZLIB if you do not want to support compressed kernel modules # -# Define LIBBABELTRACE if you DO want libbabeltrace support +# Define NO_LIBBABELTRACE if you do not want libbabeltrace support # for CTF data format. # # Define NO_LZMA if you do not want to support compressed (xz) kernel modules
Signature · 1 line
2.13.6
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 01/12] perf tools: Enable LIBBABELTRACE by default
Em Sun, Jan 07, 2018 at 05:03:45PM +0100, Jiri Olsa escreveu:
Quoted 3 lines
There's no reason anymore to treat babel trace in a special way, because a) we no longer display its state b) the needed babeltrace library is now out and well adopted among distros.
Humm, after I applied this I got:
[acme@jouet perf]$ perf
perf: error while loading shared libraries: libbabeltrace-ctf.so.2: cannot open shared object file: No such file or directory [acme@jouet perf]$
So it detects it somehow, builds with it, then fails to find it in the LD_LIBRARY_PATH somehow?
- Arnaldo
Quoted 35 lines
Signed-off-by Jiri Olsa <[email protected]>--- tools/perf/Makefile.config | 2 +- tools/perf/Makefile.perf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)tools/perf/Makefile.config +1
-1@@ -780,7 +780,7 @@ else NO_PERF_READ_VDSOX32 := 1 endif -ifdef LIBBABELTRACE +ifndef NO_LIBBABELTRACE $(call feature_check,libbabeltrace) ifeq ($(feature-libbabeltrace), 1) CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)tools/perf/Makefile.perf +1
-1@@ -77,7 +77,7 @@ include ../scripts/utilities.mak # # Define NO_ZLIB if you do not want to support compressed kernel modules # -# Define LIBBABELTRACE if you DO want libbabeltrace support +# Define NO_LIBBABELTRACE if you do not want libbabeltrace support # for CTF data format. # # Define NO_LZMA if you do not want to support compressed (xz) kernel modulesSignature · 1 line
2.13.6
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 01/12] perf tools: Enable LIBBABELTRACE by default
Em Mon, Jan 08, 2018 at 12:17:09PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 5 lines
Em Sun, Jan 07, 2018 at 05:03:45PM +0100, Jiri Olsa escreveu:
Quoted 3 lines
There's no reason anymore to treat babel trace in a special way, because a) we no longer display its state b) the needed babeltrace library is now out and well adopted among distros.
Quoted 8 lines
Humm, after I applied this I got:
[acme@jouet perf]$ perf
perf: error while loading shared libraries: libbabeltrace-ctf.so.2: cannot open shared object file: No such file or directory [acme@jouet perf]$So it detects it somehow, builds with it, then fails to find it in the
LD_LIBRARY_PATHsomehow?
[acme@jouet perf]$ ldd ~/bin/perf | grep babel
libbabeltrace-ctf.so.2 => not found
[acme@jouet perf]$
[acme@jouet perf]$ tail -5 /tmp/build/perf/feature/test-libbabeltrace.d
/usr/local/include/babeltrace/ctf-ir/visitor.h \
/usr/local/include/babeltrace/values.h \
/usr/local/include/babeltrace/ref.h \
/usr/local/include/babeltrace/graph/notification.h \
/usr/local/include/babeltrace/ctf-ir/stream-class.h
[acme@jouet perf]$
so I don't have it in LD_LIBRARY_PATH:
[acme@jouet perf]$ export LD_LIBRARY_PATH=/usr/local/lib/ [acme@jouet perf]$ ldd ~/bin/perf | grep babel
libbabeltrace-ctf.so.2 => /usr/local/lib/libbabeltrace-ctf.so.2 (0x00007f6322e83000)
[acme@jouet perf]$ perf stat -e cycles sleep 1
Performance counter stats for 'sleep 1':
384,636 cycles:u
1.001294682 seconds time elapsed[acme@jouet perf]$
Will try removing this local install and use what is in fedora27 instead...
Quoted 37 lines
- Arnaldo
Quoted 35 lines
Signed-off-by Jiri Olsa <[email protected]>--- tools/perf/Makefile.config | 2 +- tools/perf/Makefile.perf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)tools/perf/Makefile.config +1
-1@@ -780,7 +780,7 @@ else NO_PERF_READ_VDSOX32 := 1 endif -ifdef LIBBABELTRACE +ifndef NO_LIBBABELTRACE $(call feature_check,libbabeltrace) ifeq ($(feature-libbabeltrace), 1) CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)tools/perf/Makefile.perf +1
-1@@ -77,7 +77,7 @@ include ../scripts/utilities.mak # # Define NO_ZLIB if you do not want to support compressed kernel modules # -# Define LIBBABELTRACE if you DO want libbabeltrace support +# Define NO_LIBBABELTRACE if you do not want libbabeltrace support # for CTF data format. # # Define NO_LZMA if you do not want to support compressed (xz) kernel modulesSignature · 1 line
2.13.6
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 01/12] perf tools: Enable LIBBABELTRACE by default
Em Mon, Jan 08, 2018 at 12:20:37PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 36 lines
Em Mon, Jan 08, 2018 at 12:17:09PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 5 lines
Em Sun, Jan 07, 2018 at 05:03:45PM +0100, Jiri Olsa escreveu:
Quoted 3 lines
There's no reason anymore to treat babel trace in a special way, because a) we no longer display its state b) the needed babeltrace library is now out and well adopted among distros.
Quoted 8 lines
Humm, after I applied this I got:
[acme@jouet perf]$ perf
perf: error while loading shared libraries: libbabeltrace-ctf.so.2: cannot open shared object file: No such file or directory [acme@jouet perf]$So it detects it somehow, builds with it, then fails to find it in the
LD_LIBRARY_PATHsomehow?[acme@jouet perf]$ ldd ~/bin/perf | grep babel
libbabeltrace-ctf.so.2 => not found
[acme@jouet perf]$[acme@jouet perf]$ tail -5
/tmp/build/perf/feature/test-libbabeltrace.d
/usr/local/include/babeltrace/ctf-ir/visitor.h\
/usr/local/include/babeltrace/values.h\
/usr/local/include/babeltrace/ref.h\
/usr/local/include/babeltrace/graph/notification.h\
/usr/local/include/babeltrace/ctf-ir/stream-class.h
[acme@jouet perf]$so I don't have it in
LD_LIBRARY_PATH:[acme@jouet perf]$ export LD_LIBRARY_PATH=/usr/local/lib/ [acme@jouet perf]$ ldd ~/bin/perf | grep babel
libbabeltrace-ctf.so.2 => /usr/local/lib/libbabeltrace-ctf.so.2 (0x00007f6322e83000)[acme@jouet perf]$ perf stat -e cycles sleep 1
Performance counter stats for 'sleep 1':
Quoted 8 lines
384,636 cycles:u 1.001294682 seconds time elapsed[acme@jouet perf]$
Will try removing this local install and use what is in fedora27 instead...
Works:
[acme@jouet perf]$ ldd ~/bin/perf | grep babel
libbabeltrace-ctf.so.1 => /lib64/libbabeltrace-ctf.so.1 (0x00007fcb688d0000) libbabeltrace.so.1 => /lib64/libbabeltrace.so.1 (0x00007fcb67e92000)
[acme@jouet perf]$ rpm -q libbabeltrace-devel
libbabeltrace-devel-1.5.3-1.fc27.x86_64
[acme@jouet perf]$
But then, if we show:
Auto-detecting system features:
... dwarf: [ on ] ... dwarf_getlocations: [ on ] ... glibc: [ on ] ... gtk2: [ on ] ... libaudit: [ on ] ... libbfd: [ on ] ... libelf: [ on ] ... libnuma: [ on ] ... numa_num_possible_cpus: [ on ] ... libperl: [ on ] ... libpython: [ on ] ... libslang: [ on ] ... libcrypto: [ on ] ... libunwind: [ on ] ... libdw-dwarf-unwind: [ on ] ... zlib: [ on ] ... lzma: [ on ] ... get_cpuid: [ on ] ... bpf: [ on ]
Shoudln't we tell the user that babeltrace was linked too?
- Arnaldo
Re: [PATCH 01/12] perf tools: Enable LIBBABELTRACE by default
On Mon, Jan 08, 2018 at 12:24:33PM -0300, Arnaldo Carvalho de Melo wrote:
SNIP
Quoted 33 lines
Works:
[acme@jouet perf]$ ldd ~/bin/perf | grep babel
libbabeltrace-ctf.so.1 => /lib64/libbabeltrace-ctf.so.1 (0x00007fcb688d0000) libbabeltrace.so.1 => /lib64/libbabeltrace.so.1 (0x00007fcb67e92000)[acme@jouet perf]$ rpm -q libbabeltrace-devel
libbabeltrace-devel-1.5.3-1.fc27.x86_64
[acme@jouet perf]$But then, if we show:
Auto-detecting system features:
... dwarf: [ on ] ... dwarf_getlocations: [ on ] ... glibc: [ on ] ... gtk2: [ on ] ... libaudit: [ on ] ... libbfd: [ on ] ... libelf: [ on ] ... libnuma: [ on ] ... numa_num_possible_cpus: [ on ] ... libperl: [ on ] ... libpython: [ on ] ... libslang: [ on ] ... libcrypto: [ on ] ... libunwind: [ on ] ... libdw-dwarf-unwind: [ on ] ... zlib: [ on ] ... lzma: [ on ] ... get_cpuid: [ on ] ... bpf: [ on ]
Quoted 1 line
Shoudln't we tell the user that babeltrace was linked too?
the logic is just to simply display the state of features which we provide in FEATURE_DISPLAY variable, which is believed to be common and important enough to display status about
maybe we could display it with 'make VF=1' output?
jirka
Re: [PATCH 01/12] perf tools: Enable LIBBABELTRACE by default
Quoted 37 lines · Jiri Olsa
On Mon, Jan 08, 2018 at 12:24:33PM -0300, Arnaldo Carvalho de Melo wrote:
SNIP
Quoted 33 lines
Works:
[acme@jouet perf]$ ldd ~/bin/perf | grep babel
libbabeltrace-ctf.so.1 => /lib64/libbabeltrace-ctf.so.1 (0x00007fcb688d0000) libbabeltrace.so.1 => /lib64/libbabeltrace.so.1 (0x00007fcb67e92000)[acme@jouet perf]$ rpm -q libbabeltrace-devel
libbabeltrace-devel-1.5.3-1.fc27.x86_64
[acme@jouet perf]$But then, if we show:
Auto-detecting system features:
... dwarf: [ on ] ... dwarf_getlocations: [ on ] ... glibc: [ on ] ... gtk2: [ on ] ... libaudit: [ on ] ... libbfd: [ on ] ... libelf: [ on ] ... libnuma: [ on ] ... numa_num_possible_cpus: [ on ] ... libperl: [ on ] ... libpython: [ on ] ... libslang: [ on ] ... libcrypto: [ on ] ... libunwind: [ on ] ... libdw-dwarf-unwind: [ on ] ... zlib: [ on ] ... lzma: [ on ] ... get_cpuid: [ on ] ... bpf: [ on ]
Quoted 8 lines
Quoted 1 line
Shoudln't we tell the user that babeltrace was linked too?
the logic is just to simply display the state of features which we provide in
FEATURE_DISPLAYvariable, which is believed to be common and important enough to display status aboutmaybe we could display it with 'make VF=1' output?
like in patch attached ;-)
[jolsa@krava perf]$ make VF=1
BUILD: Doing 'make -j4' parallel build
Warning: Kernel ABI header at 'tools/include/uapi/linux/perf_event.h' differs from latest version at 'include/uapi/linux/perf_event.h'
Auto-detecting system features:
... dwarf: [ on ]
... dwarf_getlocations: [ on ]
... glibc: [ on ]
... gtk2: [ on ]
... libaudit: [ on ]
... libbfd: [ on ]
... libelf: [ on ]
... libnuma: [ on ]
... numa_num_possible_cpus: [ on ]
... libperl: [ on ]
... libpython: [ on ]
... libslang: [ on ]
... libcrypto: [ on ]
... libunwind: [ OFF ]
... libdw-dwarf-unwind: [ on ]
... zlib: [ on ]
... lzma: [ on ]
... get_cpuid: [ on ]
... bpf: [ on ]
... backtrace: [ on ]
... fortify-source: [ on ]
... sync-compare-and-swap: [ on ]
... gtk2-infobar: [ on ]
... libelf-getphdrnum: [ on ]
... libelf-gelf_getnote: [ on ]
... libelf-getshdrstrndx: [ on ]
... libelf-mmap: [ on ]
... libpython-version: [ on ]
... libunwind-x86: [ OFF ]
... libunwind-x86_64: [ OFF ]
... libunwind-arm: [ OFF ]
... libunwind-aarch64: [ OFF ]
... pthread-attr-setaffinity-np: [ on ]
... pthread-barrier: [ on ]
... stackprotector-all: [ on ]
... timerfd: [ on ]
... sched_getcpu: [ on ]
... sdt: [ on ]
... setns: [ on ]
Makefile.config:459: No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR
... bionic: [ OFF ]
... compile-32: [ on ]
... compile-x32: [ OFF ]
... cplus-demangle: [ on ]
... hello: [ OFF ]
... libbabeltrace: [ on ]
... liberty: [ on ]
... liberty-z: [ on ]
... libunwind-debug-frame: [ OFF ]
... libunwind-debug-frame-arm: [ OFF ]
... libunwind-debug-frame-aarch64: [ OFF ]
... prefix: /home/jolsa
... bindir: /home/jolsa/bin
... libdir: /home/jolsa/lib64
... sysconfdir: /home/jolsa/etc
... LIBUNWIND_DIR:
... LIBDW_DIR:
... JDIR: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-1.b12.fc26.x86_64
... DWARF post unwind library: libdw
jirka
---
tools/perf/Makefile.config +4 -0
@@ -947,6 +947,10 @@ define print_var_code endef ifeq ($(VF),1) + # Display EXTRA features which are detected manualy + # from here with feature_check call and thus cannot + # be partof global state output. + $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),)) $(call print_var,prefix) $(call print_var,bindir) $(call print_var,libdir)
PATCH 1/1 perf build: Display EXTRA features for VF=1 build
Quoted 40 lines · Jiri Olsa
Quoted 39 lines · Jiri Olsa
On Mon, Jan 08, 2018 at 12:24:33PM -0300, Arnaldo Carvalho de Melo wrote:
SNIP
Quoted 34 lines
Works:
[acme@jouet perf]$ ldd ~/bin/perf | grep babel
libbabeltrace-ctf.so.1 => /lib64/libbabeltrace-ctf.so.1 (0x00007fcb688d0000) libbabeltrace.so.1 => /lib64/libbabeltrace.so.1 (0x00007fcb67e92000)[acme@jouet perf]$ rpm -q libbabeltrace-devel
libbabeltrace-devel-1.5.3-1.fc27.x86_64
[acme@jouet perf]$But then, if we show:
Auto-detecting system features:
... dwarf: [ on ] ... dwarf_getlocations: [ on ] ... glibc: [ on ] ... gtk2: [ on ] ... libaudit: [ on ] ... libbfd: [ on ] ... libelf: [ on ] ... libnuma: [ on ] ... numa_num_possible_cpus: [ on ] ... libperl: [ on ] ... libpython: [ on ] ... libslang: [ on ] ... libcrypto: [ on ] ... libunwind: [ on ] ... libdw-dwarf-unwind: [ on ] ... zlib: [ on ] ... lzma: [ on ] ... get_cpuid: [ on ] ... bpf: [ on ]Shoudln't we tell the user that babeltrace was linked too?
Quoted 8 lines
Quoted 6 lines
the logic is just to simply display the state of features which we provide in
FEATURE_DISPLAYvariable, which is believed to be common and important enough to display status aboutmaybe we could display it with 'make VF=1' output?
like in patch attached ;-)
with changelog
thanks,
jirka
---
Display state of the rest of the features (FEATURE_TESTS_EXTRA) for 'make VF=1' build. These features are detected manually by perf's Makefile.config so they can't be displayed with the main list, but only after we're done in Makefile.config.
$ make VF=1
BUILD: Doing 'make -j4' parallel buildAuto-detecting system features:
... dwarf: [ on ] ... dwarf_getlocations: [ on ] ... glibc: [ on ] ... gtk2: [ on ]
SNIP
... timerfd: [ on ] ... sched_getcpu: [ on ] ... sdt: [ on ] ... setns: [ on ]
extra features:
... bionic: [ OFF ]
... compile-32: [ on ]
... compile-x32: [ OFF ]
... cplus-demangle: [ on ]
... hello: [ OFF ]
... libbabeltrace: [ on ] ... liberty: [ on ] ... liberty-z: [ on ]
... libunwind-debug-frame: [ OFF ]
... libunwind-debug-frame-arm: [ OFF ]
... libunwind-debug-frame-aarch64: [ OFF ]
SNIP
--- tools/perf/Makefile.config | 4 ++++ 1 file changed, 4 insertions(+)
tools/perf/Makefile.config +4 -0
@@ -947,6 +947,10 @@ define print_var_code endef ifeq ($(VF),1) + # Display EXTRA features which are detected manualy + # from here with feature_check call and thus cannot + # be partof global state output. + $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),)) $(call print_var,prefix) $(call print_var,bindir) $(call print_var,libdir)
Signature · 1 line
2.13.6
Re: [PATCH] perf build: Display EXTRA features for VF=1 build
Quoted 46 lines · Jiri Olsa
Quoted 45 lines · Jiri Olsa
Quoted 44 lines · Jiri Olsa
On Mon, Jan 08, 2018 at 12:24:33PM -0300, Arnaldo Carvalho de Melo wrote:
SNIP
Quoted 33 lines
Works:
[acme@jouet perf]$ ldd ~/bin/perf | grep babel
libbabeltrace-ctf.so.1 => /lib64/libbabeltrace-ctf.so.1 (0x00007fcb688d0000) libbabeltrace.so.1 => /lib64/libbabeltrace.so.1 (0x00007fcb67e92000)[acme@jouet perf]$ rpm -q libbabeltrace-devel
libbabeltrace-devel-1.5.3-1.fc27.x86_64
[acme@jouet perf]$But then, if we show:
Auto-detecting system features:
... dwarf: [ on ] ... dwarf_getlocations: [ on ] ... glibc: [ on ] ... gtk2: [ on ] ... libaudit: [ on ] ... libbfd: [ on ] ... libelf: [ on ] ... libnuma: [ on ] ... numa_num_possible_cpus: [ on ] ... libperl: [ on ] ... libpython: [ on ] ... libslang: [ on ] ... libcrypto: [ on ] ... libunwind: [ on ] ... libdw-dwarf-unwind: [ on ] ... zlib: [ on ] ... lzma: [ on ] ... get_cpuid: [ on ] ... bpf: [ on ]Quoted 1 line
Shoudln't we tell the user that babeltrace was linked too?
the logic is just to simply display the state of features which we provide in
FEATURE_DISPLAYvariable, which is believed to be common and important enough to display status about
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
maybe we could display it with 'make VF=1' output?
like in patch attached ;-)
with changelog
thanks,
jirka
Arnaldo,
could you please check this one?
thanks,
jirka
Quoted 63 lines
---
Display state of the rest of the features (FEATURE_TESTS_EXTRA) for 'make VF=1' build. These features are detected manually by perf's Makefile.config so they can't be displayed with the main list, but only after we're done in Makefile.config.$ make VF=1 BUILD: Doing 'make -j4' parallel buildAuto-detecting system features:
... dwarf: [ on ] ... dwarf_getlocations: [ on ] ... glibc: [ on ] ... gtk2: [ on ]SNIP
... timerfd: [ on ] ... sched_getcpu: [ on ] ... sdt: [ on ] ... setns: [ on ]extra features:
... bionic: [ OFF ]
... compile-32: [ on ]
... compile-x32: [ OFF ]
... cplus-demangle: [ on ]
... hello: [ OFF ]... libbabeltrace: [ on ] ... liberty: [ on ] ... liberty-z: [ on ]... libunwind-debug-frame: [ OFF ]
... libunwind-debug-frame-arm: [ OFF ]
... libunwind-debug-frame-aarch64: [ OFF ]SNIP
Signed-off-by Jiri Olsa <[email protected]>--- tools/perf/Makefile.config | 4 ++++ 1 file changed, 4 insertions(+)tools/perf/Makefile.config +4
-0@@ -947,6 +947,10 @@ define print_var_code endef ifeq ($(VF),1) + # Display EXTRA features which are detected manualy + # from here with feature_check call and thus cannot + # be partof global state output. + $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),)) $(call print_var,prefix) $(call print_var,bindir) $(call print_var,libdir)Signature · 1 line
2.13.6
Re: [PATCH] perf build: Display EXTRA features for VF=1 build
Em Fri, Jan 19, 2018 at 11:15:24AM +0100, Jiri Olsa escreveu:
Quoted 11 lines · Jiri Olsa
Quoted 9 lines · Jiri Olsa
Quoted 8 lines · Jiri Olsa
Quoted 7 lines · Arnaldo Carvalho de Melo
Quoted 1 line
Shoudln't we tell the user that babeltrace was linked too?
the logic is just to simply display the state of features which we provide in
FEATURE_DISPLAYvariable, which is believed to be common and important enough to display status about
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
maybe we could display it with 'make VF=1' output?
like in patch attached ;-)
with changelog
Arnaldo,
could you please check this one?
Applied.
- Arnaldo
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf build: Display EXTRA features for VF=1 build
In reply to Jiri Olsaperf build: Display EXTRA features for VF=1 build
Commit-ID: 99402e0683ecea11db44fd1c59a65b4eb3bd2672 Gitweb: https://git.kernel.org/tip/99402e0683ecea11db44fd1c59a65b4eb3bd2672 Author: Jiri Olsa <[email protected]> AuthorDate: Tue, 9 Jan 2018 10:26:46 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 23 Jan 2018 09:51:36 -0300
perf build: Display EXTRA features for VF=1 build
Display the state of the rest of the features (FEATURE_TESTS_EXTRA) on a 'make VF=1' build. These features are detected manually by perf's Makefile.config so they can't be displayed with the main list, but only after we're done in Makefile.config.
$ make VF=1
BUILD: Doing 'make -j4' parallel buildAuto-detecting system features:
... dwarf: [ on ] ... dwarf_getlocations: [ on ] ... glibc: [ on ] ... gtk2: [ on ]
SNIP
... timerfd: [ on ] ... sched_getcpu: [ on ] ... sdt: [ on ] ... setns: [ on ]
extra features:
... bionic: [ OFF ]
... compile-32: [ on ]
... compile-x32: [ OFF ]
... cplus-demangle: [ on ]
... hello: [ OFF ]
... libbabeltrace: [ on ] ... liberty: [ on ] ... liberty-z: [ on ]
... libunwind-debug-frame: [ OFF ]
... libunwind-debug-frame-arm: [ OFF ]
... libunwind-debug-frame-aarch64: [ OFF ]
SNIP
--- tools/perf/Makefile.config | 4 ++++ 1 file changed, 4 insertions(+)
tools/perf/Makefile.config +4 -0
@@ -947,6 +947,10 @@ define print_var_code endef ifeq ($(VF),1) + # Display EXTRA features which are detected manualy + # from here with feature_check call and thus cannot + # be partof global state output. + $(foreach feat,$(FEATURE_TESTS_EXTRA),$(call feature_print_status,$(feat),)) $(call print_var,prefix) $(call print_var,bindir) $(call print_var,libdir)
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Enable LIBBABELTRACE by default
In reply to Jiri Olsaperf tools: Enable LIBBABELTRACE by default
Commit-ID: 24787afbcd0127859394eb9230659ee6d5dc4644 Gitweb: https://git.kernel.org/tip/24787afbcd0127859394eb9230659ee6d5dc4644 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Jan 2018 17:03:45 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 8 Jan 2018 12:10:21 -0300
perf tools: Enable LIBBABELTRACE by default
There's no reason anymore to treat babel trace in a special way, because
a) we no longer display its state b) the needed babeltrace library is now out and well adopted among distros.
--- tools/perf/Makefile.config | 2 +- tools/perf/Makefile.perf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/Makefile.config +1 -1
@@ -780,7 +780,7 @@ else NO_PERF_READ_VDSOX32 := 1 endif -ifdef LIBBABELTRACE +ifndef NO_LIBBABELTRACE $(call feature_check,libbabeltrace) ifeq ($(feature-libbabeltrace), 1) CFLAGS += -DHAVE_LIBBABELTRACE_SUPPORT $(LIBBABELTRACE_CFLAGS)
tools/perf/Makefile.perf +1 -1
@@ -77,7 +77,7 @@ include ../scripts/utilities.mak # # Define NO_ZLIB if you do not want to support compressed kernel modules # -# Define LIBBABELTRACE if you DO want libbabeltrace support +# Define NO_LIBBABELTRACE if you do not want libbabeltrace support # for CTF data format. # # Define NO_LZMA if you do not want to support compressed (xz) kernel modules
Jiri Olsa
reviewerPATCH 2/12 perf tools: Display perf_event_attr::namespaces debug info
In reply to Jiri OlsaDisplay namespaces bit in -vv debug display:
$ perf record -vv --namespaces ...
...
perf_event_attr:
size 112
...
namespaces 1--- tools/perf/util/evsel.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/evsel.c +1 -0
@@ -1577,6 +1577,7 @@ int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr,PRINT_ATTRf (use_clockid, p_unsigned);PRINT_ATTRf (context_switch, p_unsigned);PRINT_ATTRf (write_backward, p_unsigned); +PRINT_ATTRf (namespaces, p_unsigned);PRINT_ATTRn ("{ wakeup_events, wakeup_watermark }" , wakeup_events, p_unsigned);PRINT_ATTRf (bp_type, p_unsigned);
Signature · 1 line
2.13.6
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Display perf_event_attr::namespaces debug info
perf tools: Display perf_event_attr::namespaces debug info
Commit-ID: db9fc765e8f4d0144d13cdfa4be32d81eae01710 Gitweb: https://git.kernel.org/tip/db9fc765e8f4d0144d13cdfa4be32d81eae01710 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Jan 2018 17:03:46 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 8 Jan 2018 12:15:19 -0300
perf tools: Display perf_event_attr::namespaces debug info
Display namespaces bit in -vv debug display:
$ perf record -vv --namespaces ...
...
perf_event_attr:
size 112
...
namespaces 1--- tools/perf/util/evsel.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/evsel.c +1 -0
@@ -1577,6 +1577,7 @@ int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr,PRINT_ATTRf (use_clockid, p_unsigned);PRINT_ATTRf (context_switch, p_unsigned);PRINT_ATTRf (write_backward, p_unsigned); +PRINT_ATTRf (namespaces, p_unsigned);PRINT_ATTRn ("{ wakeup_events, wakeup_watermark }" , wakeup_events, p_unsigned);PRINT_ATTRf (bp_type, p_unsigned);
Jiri Olsa
reviewerPATCH 3/12 perf: Allocate context task_ctx_data for child event
In reply to Jiri OlsaCurrently we use perf_event_context::task_ctx_data to save and restore the LBR status when the task is scheduled out and in.
We don't allocate it for child contexts, which results in shorter task's LBR stack, because we don't save the history from previous run and start over every time we schedule the task in.
I made a test to generate samples with LBR call stack and got higher numbers on bigger chain depths:
before: after:
LBR call chain: nr: 1 60561 498127
LBR call chain: nr: 2 0 0
LBR call chain: nr: 3 107030 2172
LBR call chain: nr: 4 466685 62758
LBR call chain: nr: 5 2307319 878046
LBR call chain: nr: 6 48713 495218
LBR call chain: nr: 7 1040 4551
LBR call chain: nr: 8 481 172 LBR call chain: nr: 9 878 120 LBR call chain: nr: 10 2377 6698 LBR call chain: nr: 11 28830 151487 LBR call chain: nr: 12 29347 339867 LBR call chain: nr: 13 4 22 LBR call chain: nr: 14 3 53
--- kernel/events/core.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
kernel/events/core.c +14 -0
@@ -10703,6 +10703,19 @@ inherit_event(struct perf_event *parent_event,if (IS_ERR (child_event))return child_event; + +if ((child_event->attach_state &PERF_ATTACH_TASK_DATA ) && + !child_ctx->task_ctx_data) { +struct pmu *pmu = child_event->pmu; + + child_ctx->task_ctx_data =kzalloc (pmu->task_ctx_size, +GFP_KERNEL ); +if (!child_ctx->task_ctx_data) { +free_event (child_event); +return NULL ; + } + } +/* * is_orphaned_event() and list_add_tail(&parent_event->child_list) * must be under the same lock in order to serialize against
@@ -10713,6 +10726,7 @@ inherit_event(struct perf_event *parent_event,if (is_orphaned_event (parent_event) || !atomic_long_inc_not_zero (&parent_event->refcount)) {mutex_unlock (&parent_event->child_mutex); +/* task_ctx_data is freed with child_ctx */ free_event (child_event);return NULL ; }
Signature · 1 line
2.13.6
Re: [PATCH 03/12] perf: Allocate context task_ctx_data for child event
Quoted 20 lines · Jiri Olsa
Currently we use
perf_event_context::task_ctx_datato save and restore the LBR status when the task is scheduled out and in.We don't allocate it for child contexts, which results in shorter task's LBR stack, because we don't save the history from previous run and start over every time we schedule the task in.
I made a test to generate samples with LBR call stack and got higher numbers on bigger chain depths:
before: after:
LBR call chain: nr: 1 60561 498127
LBR call chain: nr: 2 0 0
LBR call chain: nr: 3 107030 2172
LBR call chain: nr: 4 466685 62758
LBR call chain: nr: 5 2307319 878046
LBR call chain: nr: 6 48713 495218
LBR call chain: nr: 7 1040 4551
Quoted 7 lines
LBR call chain: nr: 8 481 172 LBR call chain: nr: 9 878 120 LBR call chain: nr: 10 2377 6698 LBR call chain: nr: 11 28830 151487 LBR call chain: nr: 12 29347 339867 LBR call chain: nr: 13 4 22 LBR call chain: nr: 14 3 53
Quoted 41 lines
Cc Andi Kleen <[email protected]>Signed-off-by Jiri Olsa <[email protected]>--- kernel/events/core.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)kernel/events/core.c +14
-0@@ -10703,6 +10703,19 @@ inherit_event(struct perf_event *parent_event,if (IS_ERR (child_event))return child_event; + +if ((child_event->attach_state &PERF_ATTACH_TASK_DATA ) && + !child_ctx->task_ctx_data) { +struct pmu *pmu = child_event->pmu; + + child_ctx->task_ctx_data =kzalloc (pmu->task_ctx_size, +GFP_KERNEL ); +if (!child_ctx->task_ctx_data) { +free_event (child_event); +return NULL ; + } + } +/* * is_orphaned_event() and list_add_tail(&parent_event->child_list) * must be under the same lock in order to serialize against @@ -10713,6 +10726,7 @@ inherit_event(struct perf_event *parent_event,if (is_orphaned_event (parent_event) || !atomic_long_inc_not_zero (&parent_event->refcount)) {mutex_unlock (&parent_event->child_mutex); +/* task_ctx_data is freed with child_ctx */ free_event (child_event);return NULL ; }Signature · 1 line
2.13.6
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf: Allocate context task_ctx_data for child event
In reply to Jiri Olsaperf: Allocate context task_ctx_data for child event
Commit-ID: 313ccb96159489eabdbdcf4deb34e7fbac17557d Gitweb: https://git.kernel.org/tip/313ccb96159489eabdbdcf4deb34e7fbac17557d Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Jan 2018 17:03:47 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 8 Jan 2018 12:26:46 -0300
perf: Allocate context task_ctx_data for child event
Currently we use perf_event_context::task_ctx_data to save and restore the LBR status when the task is scheduled out and in.
We don't allocate it for child contexts, which results in shorter task's LBR stack, because we don't save the history from previous run and start over every time we schedule the task in.
I made a test to generate samples with LBR call stack and got higher numbers on bigger chain depths:
before: after:
LBR call chain: nr: 1 60561 498127
LBR call chain: nr: 2 0 0
LBR call chain: nr: 3 107030 2172
LBR call chain: nr: 4 466685 62758
LBR call chain: nr: 5 2307319 878046
LBR call chain: nr: 6 48713 495218
LBR call chain: nr: 7 1040 4551
LBR call chain: nr: 8 481 172 LBR call chain: nr: 9 878 120 LBR call chain: nr: 10 2377 6698 LBR call chain: nr: 11 28830 151487 LBR call chain: nr: 12 29347 339867 LBR call chain: nr: 13 4 22 LBR call chain: nr: 14 3 53
--- kernel/events/core.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
kernel/events/core.c +14 -0
@@ -10703,6 +10703,19 @@ inherit_event(struct perf_event *parent_event,if (IS_ERR (child_event))return child_event; + +if ((child_event->attach_state &PERF_ATTACH_TASK_DATA ) && + !child_ctx->task_ctx_data) { +struct pmu *pmu = child_event->pmu; + + child_ctx->task_ctx_data =kzalloc (pmu->task_ctx_size, +GFP_KERNEL ); +if (!child_ctx->task_ctx_data) { +free_event (child_event); +return NULL ; + } + } +/* * is_orphaned_event() and list_add_tail(&parent_event->child_list) * must be under the same lock in order to serialize against
@@ -10713,6 +10726,7 @@ inherit_event(struct perf_event *parent_event,if (is_orphaned_event (parent_event) || !atomic_long_inc_not_zero (&parent_event->refcount)) {mutex_unlock (&parent_event->child_mutex); +/* task_ctx_data is freed with child_ctx */ free_event (child_event);return NULL ; }
Jiri Olsa
reviewerPATCH 4/12 perf: Add sample_id to PERF_RECORD_ITRACE_START event comment
In reply to Jiri OlsaAdding missing sample_id line into PERF_RECORD_ITRACE_START event comment.
--- include/uapi/linux/perf_event.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/perf_event.h +1 -0
@@ -864,6 +864,7 @@ enum perf_event_type {* struct perf_event_header header; * u32 pid; * u32 tid; +* struct sample_id sample_id; * }; */ PERF_RECORD_ITRACE_START = 12,
Signature · 1 line
2.13.6
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf: Add sample_id to PERF_RECORD_ITRACE_START event comment
perf: Add sample_id to PERF_RECORD_ITRACE_START event comment
Commit-ID: 81df978c49379481716aef591de77313c286d747 Gitweb: https://git.kernel.org/tip/81df978c49379481716aef591de77313c286d747 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Jan 2018 17:03:48 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 8 Jan 2018 12:32:25 -0300
perf: Add sample_id to PERF_RECORD_ITRACE_START event comment
Adding missing sample_id line into PERF_RECORD_ITRACE_START event comment.
--- include/uapi/linux/perf_event.h | 1 + tools/include/uapi/linux/perf_event.h | 1 + 2 files changed, 2 insertions(+)
include/uapi/linux/perf_event.h +1 -0
@@ -864,6 +864,7 @@ enum perf_event_type {* struct perf_event_header header; * u32 pid; * u32 tid; +* struct sample_id sample_id; * }; */ PERF_RECORD_ITRACE_START = 12,
tools/include/uapi/linux/perf_event.h +1 -0
@@ -864,6 +864,7 @@ enum perf_event_type {* struct perf_event_header header; * u32 pid; * u32 tid; +* struct sample_id sample_id; * }; */ PERF_RECORD_ITRACE_START = 12,
Jiri Olsa
reviewerPATCH 5/12 perf: Make perf_callchain function static
In reply to Jiri OlsaAnd moving it into core.c, because there's no caller of this function other than the one in core.c
--- kernel/events/callchain.c | 15 --------------- kernel/events/core.c | 16 ++++++++++++++++ kernel/events/internal.h | 4 ---- 3 files changed, 16 insertions(+), 19 deletions(-)
kernel/events/callchain.c +0 -15
@@ -179,21 +179,6 @@ put_callchain_entry(int rctx) }struct perf_callchain_entry * -perf_callchain (struct perf_event *event,struct pt_regs *regs) -{ -bool kernel = !event->attr.exclude_callchain_kernel; -bool user = !event->attr.exclude_callchain_user; -/* Disallow cross-task user callchains. */ -bool crosstask = event->ctx->task && event->ctx->task != current; -const u32 max_stack = event->attr.sample_max_stack; - -if (!kernel && !user) -return NULL ; - -return get_perf_callchain (regs,0 , kernel, user, max_stack, crosstask, true); -} - -struct perf_callchain_entry *get_perf_callchain (struct pt_regs *regs,u32 init_nr,bool kernel,bool user,u32 max_stack,bool crosstask,bool add_mark) {
kernel/events/core.c +16 -0
@@ -5980,6 +5980,22 @@ static u64 perf_virt_to_phys(u64 virt)return phys_addr; } +static struct perf_callchain_entry * +perf_callchain (struct perf_event *event,struct pt_regs *regs) +{ +bool kernel = !event->attr.exclude_callchain_kernel; +bool user = !event->attr.exclude_callchain_user; +/* Disallow cross-task user callchains. */ +bool crosstask = event->ctx->task && event->ctx->task != current; +const u32 max_stack = event->attr.sample_max_stack; + +if (!kernel && !user) +return NULL ; + +return get_perf_callchain (regs,0 , kernel, user, + max_stack, crosstask, true); +} + void perf_prepare_sample(struct perf_event_header *header, struct perf_sample_data *data, struct perf_event *event,
kernel/events/internal.h +0 -4
@@ -201,10 +201,6 @@ arch_perf_out_copy_user(void *dst, const void *src, unsigned long n) DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user) -/* Callchain handling */ -extern struct perf_callchain_entry * -perf_callchain (struct perf_event *event,struct pt_regs *regs); -static inline int get_recursion_context (int *recursion) {int rctx;
Signature · 1 line
2.13.6
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf: Make perf_callchain function static
perf: Make perf_callchain function static
Commit-ID: 8cf7e0e22414f5acf85ecb7cd0d4482e6c9696ae Gitweb: https://git.kernel.org/tip/8cf7e0e22414f5acf85ecb7cd0d4482e6c9696ae Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Jan 2018 17:03:49 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 8 Jan 2018 12:33:01 -0300
perf: Make perf_callchain function static
And move it to core.c, because there's no caller of this function other than the one in core.c
--- kernel/events/callchain.c | 15 --------------- kernel/events/core.c | 16 ++++++++++++++++ kernel/events/internal.h | 4 ---- 3 files changed, 16 insertions(+), 19 deletions(-)
kernel/events/callchain.c +0 -15
@@ -179,21 +179,6 @@ put_callchain_entry(int rctx) }struct perf_callchain_entry * -perf_callchain (struct perf_event *event,struct pt_regs *regs) -{ -bool kernel = !event->attr.exclude_callchain_kernel; -bool user = !event->attr.exclude_callchain_user; -/* Disallow cross-task user callchains. */ -bool crosstask = event->ctx->task && event->ctx->task != current; -const u32 max_stack = event->attr.sample_max_stack; - -if (!kernel && !user) -return NULL ; - -return get_perf_callchain (regs,0 , kernel, user, max_stack, crosstask, true); -} - -struct perf_callchain_entry *get_perf_callchain (struct pt_regs *regs,u32 init_nr,bool kernel,bool user,u32 max_stack,bool crosstask,bool add_mark) {
kernel/events/core.c +16 -0
@@ -5980,6 +5980,22 @@ static u64 perf_virt_to_phys(u64 virt)return phys_addr; } +static struct perf_callchain_entry * +perf_callchain (struct perf_event *event,struct pt_regs *regs) +{ +bool kernel = !event->attr.exclude_callchain_kernel; +bool user = !event->attr.exclude_callchain_user; +/* Disallow cross-task user callchains. */ +bool crosstask = event->ctx->task && event->ctx->task != current; +const u32 max_stack = event->attr.sample_max_stack; + +if (!kernel && !user) +return NULL ; + +return get_perf_callchain (regs,0 , kernel, user, + max_stack, crosstask, true); +} + void perf_prepare_sample(struct perf_event_header *header, struct perf_sample_data *data, struct perf_event *event,
kernel/events/internal.h +0 -4
@@ -201,10 +201,6 @@ arch_perf_out_copy_user(void *dst, const void *src, unsigned long n) DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user) -/* Callchain handling */ -extern struct perf_callchain_entry * -perf_callchain (struct perf_event *event,struct pt_regs *regs); -static inline int get_recursion_context (int *recursion) {int rctx;
Jiri Olsa
reviewerPATCH 6/12 perf: Return empty callchain instead of NULL
In reply to Jiri OlsaIt simplifies the code a bit, because we dump the callchain even if it's empty. With 'empty' callchain we can remove all the NULL-checking code paths.
Original-patch-from: Peter Zijlstra <[email protected]>
--- kernel/events/core.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-)
kernel/events/core.c +12 -18
@@ -5815,19 +5815,11 @@ void perf_output_sample(struct perf_output_handle *handle,perf_output_read (handle, event);if (sample_type &PERF_SAMPLE_CALLCHAIN ) { -if (data->callchain) { -int size =1 ; - -if (data->callchain) - size += data->callchain->nr; - - size *=sizeof (u64); +int size =1 ; -__output_copy (handle, data->callchain, size); - }else { -u64 nr =0 ; -perf_output_put (handle, nr); - } + size += data->callchain->nr; + size *=sizeof (u64); +__output_copy (handle, data->callchain, size); }if (sample_type &PERF_SAMPLE_RAW ) {
@@ -5980,6 +5972,8 @@ static u64 perf_virt_to_phys(u64 virt)return phys_addr; } +static struct perf_callchain_entry __empty_callchain = { .nr =0 , }; +static struct perf_callchain_entry *perf_callchain (struct perf_event *event,struct pt_regs *regs) {
@@ -5988,12 +5982,14 @@ perf_callchain(struct perf_event *event, struct pt_regs *regs)/* Disallow cross-task user callchains. */ bool crosstask = event->ctx->task && event->ctx->task != current;const u32 max_stack = event->attr.sample_max_stack; +struct perf_callchain_entry *callchain;if (!kernel && !user) -return NULL ; +return &__empty_callchain; -return get_perf_callchain (regs,0 , kernel, user, - max_stack, crosstask, true); + callchain =get_perf_callchain (regs,0 , kernel, user, + max_stack, crosstask, true); +return callchain ?: &__empty_callchain; } void perf_prepare_sample(struct perf_event_header *header,
@@ -6018,9 +6014,7 @@ void perf_prepare_sample(struct perf_event_header *header,int size =1 ; data->callchain =perf_callchain (event, regs); - -if (data->callchain) - size += data->callchain->nr; + size += data->callchain->nr; header->size += size *sizeof (u64); }
Signature · 1 line
2.13.6
Re: [PATCH 06/12] perf: Return empty callchain instead of NULL
Quoted 3 lines · Jiri Olsa
It simplifies the code a bit, because we dump the callchain even if it's empty. With 'empty' callchain we can remove all the NULL-checking code paths.
Quoted 77 lines
Original-patch-from: Peter Zijlstra <[email protected]>
Signed-off-by Jiri Olsa <[email protected]>--- kernel/events/core.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-)kernel/events/core.c +12
-18@@ -5815,19 +5815,11 @@ void perf_output_sample(struct perf_output_handle *handle,perf_output_read (handle, event);if (sample_type &PERF_SAMPLE_CALLCHAIN ) { -if (data->callchain) { -int size =1 ; - -if (data->callchain) - size += data->callchain->nr; - - size *=sizeof (u64); +int size =1 ; -__output_copy (handle, data->callchain, size); - }else { -u64 nr =0 ; -perf_output_put (handle, nr); - } + size += data->callchain->nr; + size *=sizeof (u64); +__output_copy (handle, data->callchain, size); }if (sample_type &PERF_SAMPLE_RAW ) {@@ -5980,6 +5972,8 @@ static u64 perf_virt_to_phys(u64 virt)return phys_addr; } +static struct perf_callchain_entry __empty_callchain = { .nr =0 , }; +static struct perf_callchain_entry *perf_callchain (struct perf_event *event,struct pt_regs *regs) {@@ -5988,12 +5982,14 @@ perf_callchain(struct perf_event *event, struct pt_regs *regs)/* Disallow cross-task user callchains. */ bool crosstask = event->ctx->task && event->ctx->task != current;const u32 max_stack = event->attr.sample_max_stack; +struct perf_callchain_entry *callchain;if (!kernel && !user) -return NULL ; +return &__empty_callchain; -return get_perf_callchain (regs,0 , kernel, user, - max_stack, crosstask, true); + callchain =get_perf_callchain (regs,0 , kernel, user, + max_stack, crosstask, true); +return callchain ?: &__empty_callchain; } void perf_prepare_sample(struct perf_event_header *header,@@ -6018,9 +6014,7 @@ void perf_prepare_sample(struct perf_event_header *header,int size =1 ; data->callchain =perf_callchain (event, regs); - -if (data->callchain) - size += data->callchain->nr; + size += data->callchain->nr; header->size += size *sizeof (u64); }Signature · 1 line
2.13.6
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf: Return empty callchain instead of NULL
In reply to Jiri Olsaperf: Return empty callchain instead of NULL
Commit-ID: 99e818cc88889a2fa2f483b91b372c47b94b7c98 Gitweb: https://git.kernel.org/tip/99e818cc88889a2fa2f483b91b372c47b94b7c98 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Jan 2018 17:03:50 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 8 Jan 2018 12:35:01 -0300
perf: Return empty callchain instead of NULL
It simplifies the code a bit, because we dump the callchain
even if it's empty. With 'empty' callchain we can remove all the NULL-checking code paths.
Original-patch-from: Peter Zijlstra <[email protected]>
--- kernel/events/core.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-)
kernel/events/core.c +12 -18
@@ -5815,19 +5815,11 @@ void perf_output_sample(struct perf_output_handle *handle,perf_output_read (handle, event);if (sample_type &PERF_SAMPLE_CALLCHAIN ) { -if (data->callchain) { -int size =1 ; - -if (data->callchain) - size += data->callchain->nr; - - size *=sizeof (u64); +int size =1 ; -__output_copy (handle, data->callchain, size); - }else { -u64 nr =0 ; -perf_output_put (handle, nr); - } + size += data->callchain->nr; + size *=sizeof (u64); +__output_copy (handle, data->callchain, size); }if (sample_type &PERF_SAMPLE_RAW ) {
@@ -5980,6 +5972,8 @@ static u64 perf_virt_to_phys(u64 virt)return phys_addr; } +static struct perf_callchain_entry __empty_callchain = { .nr =0 , }; +static struct perf_callchain_entry *perf_callchain (struct perf_event *event,struct pt_regs *regs) {
@@ -5988,12 +5982,14 @@ perf_callchain(struct perf_event *event, struct pt_regs *regs)/* Disallow cross-task user callchains. */ bool crosstask = event->ctx->task && event->ctx->task != current;const u32 max_stack = event->attr.sample_max_stack; +struct perf_callchain_entry *callchain;if (!kernel && !user) -return NULL ; +return &__empty_callchain; -return get_perf_callchain (regs,0 , kernel, user, - max_stack, crosstask, true); + callchain =get_perf_callchain (regs,0 , kernel, user, + max_stack, crosstask, true); +return callchain ?: &__empty_callchain; } void perf_prepare_sample(struct perf_event_header *header,
@@ -6018,9 +6014,7 @@ void perf_prepare_sample(struct perf_event_header *header,int size =1 ; data->callchain =perf_callchain (event, regs); - -if (data->callchain) - size += data->callchain->nr; + size += data->callchain->nr; header->size += size *sizeof (u64); }
Jiri Olsa
reviewerPATCH 7/12 perf: Update PERF_RECORD_MISC_* comment for perf_event_header::misc bit 13
In reply to Jiri OlsaThe perf_event_header::misc bit 13 is shared on different events and next patch is adding yet another bit 13 user. Updating the comment to make it more structured and clear which events use bit 13.
--- include/uapi/linux/perf_event.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
include/uapi/linux/perf_event.h +6 -3
@@ -612,9 +612,12 @@ struct perf_event_mmap_page {*/ #define PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT (1 << 12)/* -* PERF_RECORD_MISC_MMAP_DATA and PERF_RECORD_MISC_COMM_EXEC are used on -* different events so can reuse the same bit position. -* Ditto PERF_RECORD_MISC_SWITCH_OUT. +* Following PERF_RECORD_MISC_* are used on different +* events, so can reuse the same bit position: +* +* PERF_RECORD_MISC_MMAP_DATA - PERF_RECORD_MMAP* events +* PERF_RECORD_MISC_COMM_EXEC - PERF_RECORD_COMM event +* PERF_RECORD_MISC_SWITCH_OUT - PERF_RECORD_SWITCH* events */ #define PERF_RECORD_MISC_MMAP_DATA (1 << 13)#define PERF_RECORD_MISC_COMM_EXEC (1 << 13)
Signature · 1 line
2.13.6
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf: Update PERF_RECORD_MISC_* comment for perf_event_header::misc bit 13
perf: Update PERF_RECORD_MISC_* comment for perf_event_header::misc bit 13
Commit-ID: 972c14884728bf5f69ec69cfb1beeec1a9cd29ee Gitweb: https://git.kernel.org/tip/972c14884728bf5f69ec69cfb1beeec1a9cd29ee Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Jan 2018 17:03:51 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 8 Jan 2018 12:37:54 -0300
perf: Update PERF_RECORD_MISC_* comment for perf_event_header::misc bit 13
The perf_event_header::misc bit 13 is shared on different events and next patch is adding yet another bit 13 user. Updating the comment to make it more structured and clear which events use bit 13.
--- include/uapi/linux/perf_event.h | 9 ++++++--- tools/include/uapi/linux/perf_event.h | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-)
include/uapi/linux/perf_event.h +6 -3
@@ -612,9 +612,12 @@ struct perf_event_mmap_page {*/ #define PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT (1 << 12)/* -* PERF_RECORD_MISC_MMAP_DATA and PERF_RECORD_MISC_COMM_EXEC are used on -* different events so can reuse the same bit position. -* Ditto PERF_RECORD_MISC_SWITCH_OUT. +* Following PERF_RECORD_MISC_* are used on different +* events, so can reuse the same bit position: +* +* PERF_RECORD_MISC_MMAP_DATA - PERF_RECORD_MMAP* events +* PERF_RECORD_MISC_COMM_EXEC - PERF_RECORD_COMM event +* PERF_RECORD_MISC_SWITCH_OUT - PERF_RECORD_SWITCH* events */ #define PERF_RECORD_MISC_MMAP_DATA (1 << 13)#define PERF_RECORD_MISC_COMM_EXEC (1 << 13)
tools/include/uapi/linux/perf_event.h +6 -3
@@ -612,9 +612,12 @@ struct perf_event_mmap_page {*/ #define PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT (1 << 12)/* -* PERF_RECORD_MISC_MMAP_DATA and PERF_RECORD_MISC_COMM_EXEC are used on -* different events so can reuse the same bit position. -* Ditto PERF_RECORD_MISC_SWITCH_OUT. +* Following PERF_RECORD_MISC_* are used on different +* events, so can reuse the same bit position: +* +* PERF_RECORD_MISC_MMAP_DATA - PERF_RECORD_MMAP* events +* PERF_RECORD_MISC_COMM_EXEC - PERF_RECORD_COMM event +* PERF_RECORD_MISC_SWITCH_OUT - PERF_RECORD_SWITCH* events */ #define PERF_RECORD_MISC_MMAP_DATA (1 << 13)#define PERF_RECORD_MISC_COMM_EXEC (1 << 13)
Jiri Olsa
reviewerPATCH 8/12 perf script: Add support to display sample misc field
In reply to Jiri OlsaAdding support to display sample misc field in form of letter for each bit:
# perf script -F +misc ... sched-messaging 1414 K 28690.636582: 4590 cycles ... sched-messaging 1407 U 28690.636600: 325620 cycles ... sched-messaging 1414 K 28690.636608: 19473 cycles ... misc field __________/
The misc bits are assigned to following letters:
PERF_RECORD_MISC_KERNEL K PERF_RECORD_MISC_USER U PERF_RECORD_MISC_HYPERVISOR H PERF_RECORD_MISC_GUEST_KERNEL G PERF_RECORD_MISC_GUEST_USER g PERF_RECORD_MISC_MMAP_DATA* M PERF_RECORD_MISC_COMM_EXEC E PERF_RECORD_MISC_SWITCH_OUT S
--- tools/perf/Documentation/perf-script.txt | 20 ++++++++- tools/perf/builtin-script.c | 74 +++++++++++++++++++++++++++----- tools/perf/util/event.h | 1 + tools/perf/util/evsel.c | 1 + 4 files changed, 84 insertions(+), 12 deletions(-)
tools/perf/Documentation/perf-script.txt +19 -1
@@ -117,7 +117,7 @@ OPTIONS Comma separated list of fields to print. Options are: comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, srcline, period, iregs, uregs, brstack, brstacksym, flags, bpf-output, brstackinsn, - brstackoff, callindent, insn, insnlen, synth, phys_addr, metric. + brstackoff, callindent, insn, insnlen, synth, phys_addr, metric, misc. Field list can be prepended with the type, trace, sw or hw, to indicate to which event type the field list applies. e.g., -F sw:comm,tid,time,ip,sym and -F trace:time,cpu,trace
@@ -225,6 +225,24 @@ OPTIONS that the metric computed is averaged over the whole sampling period, not just for the sample point. + For sample events it's possible to display misc field with -F +misc option, + following letters are displayed for each bit: + + PERF_RECORD_MISC_KERNEL K + PERF_RECORD_MISC_USER U + PERF_RECORD_MISC_HYPERVISOR H + PERF_RECORD_MISC_GUEST_KERNEL G + PERF_RECORD_MISC_GUEST_USER g + PERF_RECORD_MISC_MMAP_DATA* M + PERF_RECORD_MISC_COMM_EXEC E + PERF_RECORD_MISC_SWITCH_OUT S + + $ perf script -F +misc ... + sched-messaging 1414 K 28690.636582: 4590 cycles ... + sched-messaging 1407 U 28690.636600: 325620 cycles ... + sched-messaging 1414 K 28690.636608: 19473 cycles ... + misc field ___________/ + -k:: --vmlinux=<file>:: vmlinux pathname
tools/perf/builtin-script.c +63 -11
158 lines not on this page · raw message
tools/perf/util/event.h +1 -0
@@ -205,6 +205,7 @@ struct perf_sample {u32 flags;u16 insn_len;u8 cpumode; +u16 misc;char insn[MAX_INSN ];void *raw_data;struct ip_callchain *callchain;
tools/perf/util/evsel.c +1 -0
@@ -2042,6 +2042,7 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, data->stream_id = data->id = data->time =-1ULL ; data->period = evsel->attr.sample_period; data->cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ; + data->misc = event->header.misc; data->id =-1ULL ; data->data_src =PERF_MEM_DATA_SRC_NONE ;
Signature · 1 line
2.13.6
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf script: Add support to display sample misc field
perf script: Add support to display sample misc field
Commit-ID: 28a0b39877f5ed64ae9fadf95dddb90999309dee Gitweb: https://git.kernel.org/tip/28a0b39877f5ed64ae9fadf95dddb90999309dee Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Jan 2018 17:03:52 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 8 Jan 2018 12:39:50 -0300
perf script: Add support to display sample misc field
Adding support to display sample misc field in form of letter for each bit:
# perf script -F +misc ... sched-messaging 1414 K 28690.636582: 4590 cycles ... sched-messaging 1407 U 28690.636600: 325620 cycles ... sched-messaging 1414 K 28690.636608: 19473 cycles ... misc field __________/
The misc bits are assigned to following letters:
PERF_RECORD_MISC_KERNEL K PERF_RECORD_MISC_USER U PERF_RECORD_MISC_HYPERVISOR H PERF_RECORD_MISC_GUEST_KERNEL G PERF_RECORD_MISC_GUEST_USER g PERF_RECORD_MISC_MMAP_DATA* M PERF_RECORD_MISC_COMM_EXEC E PERF_RECORD_MISC_SWITCH_OUT S
--- tools/perf/Documentation/perf-script.txt | 20 ++++++++- tools/perf/builtin-script.c | 74 +++++++++++++++++++++++++++----- tools/perf/util/event.h | 1 + tools/perf/util/evsel.c | 1 + 4 files changed, 84 insertions(+), 12 deletions(-)
tools/perf/Documentation/perf-script.txt +19 -1
@@ -117,7 +117,7 @@ OPTIONS Comma separated list of fields to print. Options are: comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff, srcline, period, iregs, uregs, brstack, brstacksym, flags, bpf-output, brstackinsn, - brstackoff, callindent, insn, insnlen, synth, phys_addr, metric. + brstackoff, callindent, insn, insnlen, synth, phys_addr, metric, misc. Field list can be prepended with the type, trace, sw or hw, to indicate to which event type the field list applies. e.g., -F sw:comm,tid,time,ip,sym and -F trace:time,cpu,trace
@@ -225,6 +225,24 @@ OPTIONS that the metric computed is averaged over the whole sampling period, not just for the sample point. + For sample events it's possible to display misc field with -F +misc option, + following letters are displayed for each bit: + + PERF_RECORD_MISC_KERNEL K + PERF_RECORD_MISC_USER U + PERF_RECORD_MISC_HYPERVISOR H + PERF_RECORD_MISC_GUEST_KERNEL G + PERF_RECORD_MISC_GUEST_USER g + PERF_RECORD_MISC_MMAP_DATA* M + PERF_RECORD_MISC_COMM_EXEC E + PERF_RECORD_MISC_SWITCH_OUT S + + $ perf script -F +misc ... + sched-messaging 1414 K 28690.636582: 4590 cycles ... + sched-messaging 1407 U 28690.636600: 325620 cycles ... + sched-messaging 1414 K 28690.636608: 19473 cycles ... + misc field ___________/ + -k:: --vmlinux=<file>:: vmlinux pathname
tools/perf/builtin-script.c +63 -11
158 lines not on this page · raw message
tools/perf/util/event.h +1 -0
@@ -205,6 +205,7 @@ struct perf_sample {u32 flags;u16 insn_len;u8 cpumode; +u16 misc;char insn[MAX_INSN ];void *raw_data;struct ip_callchain *callchain;
tools/perf/util/evsel.c +1 -0
@@ -2042,6 +2042,7 @@ int perf_evsel__parse_sample(struct perf_evsel *evsel, union perf_event *event, data->stream_id = data->id = data->time =-1ULL ; data->period = evsel->attr.sample_period; data->cpumode = event->header.misc &PERF_RECORD_MISC_CPUMODE_MASK ; + data->misc = event->header.misc; data->id =-1ULL ; data->data_src =PERF_MEM_DATA_SRC_NONE ;
Jiri Olsa
reviewerPATCH 9/12 perf script: Add support to display lost events
In reply to Jiri OlsaAdding option to display lost events:
$ perf script --show-lost-events ... mplayer 13810 [002] 468011.402396: 100 cycles:ppp: ff.. mplayer 13810 [002] 468011.402396: PERF_RECORD_LOST lost 3880 mplayer 13810 [002] 468011.402397: 100 cycles:ppp: ff..
--- tools/perf/Documentation/perf-script.txt | 3 +++ tools/perf/builtin-script.c | 28 ++++++++++++++++++++++++++++ tools/perf/util/event.c | 8 ++++++++ 3 files changed, 39 insertions(+)
tools/perf/Documentation/perf-script.txt +3 -0
@@ -300,6 +300,9 @@ OPTIONS Display context switch events i.e. events of type PERF_RECORD_SWITCH or PERF_RECORD_SWITCH_CPU_WIDE. +--show-lost-events + Display lost events i.e. events of type PERF_RECORD_LOST. + --demangle:: Demangle symbol names to human readable form. It's enabled by default, disable with --no-demangle.
tools/perf/builtin-script.c +28 -0
@@ -1487,6 +1487,7 @@ struct perf_script {bool show_mmap_events;bool show_switch_events;bool show_namespace_events; +bool show_lost_events;bool allocated;bool per_event_dump;struct cpu_map *cpus;
@@ -2075,6 +2076,29 @@ static int process_switch_event(struct perf_tool *tool,return 0 ; } +static int +process_lost_event (struct perf_tool *tool, +union perf_event *event, +struct perf_sample *sample, +struct machine *machine) +{ + struct perf_script *script = container_of(tool, struct perf_script, tool); +struct perf_session *session = script->session; +struct perf_evsel *evsel =perf_evlist__id2evsel (session->evlist, sample->id); +struct thread *thread; + + thread =machine__findnew_thread (machine, sample->pid, + sample->tid); +if (thread ==NULL ) +return -1 ; + +perf_sample__fprintf_start (sample, thread, evsel, +PERF_RECORD_LOST , stdout); +perf_event__fprintf (event, stdout); +thread__put (thread); +return 0 ; +} +static void sig_handler (int sig__maybe_unused ) { session_done =1 ;
@@ -2169,6 +2193,8 @@ static int __cmd_script(struct perf_script *script) script->tool.context_switch = process_switch_event;if (script->show_namespace_events) script->tool.namespaces = process_namespaces_event; +if (script->show_lost_events) + script->tool.lost = process_lost_event;if (perf_script__setup_per_event_dump (script)) {pr_err ("Couldn't create the per event dump files\n" );
@@ -3105,6 +3131,8 @@ int cmd_script(int argc, const char **argv) "Show context switch events (if recorded)"),OPT_BOOLEAN ('\0' ,"show-namespace-events" , &script.show_namespace_events,"Show namespace events (if recorded)" ), +OPT_BOOLEAN ('\0' ,"show-lost-events" , &script.show_lost_events, +"Show lost events (if recorded)" ),OPT_BOOLEAN ('\0' ,"per-event-dump" , &script.per_event_dump,"Dump trace output to files named by the monitored events" ), OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
tools/perf/util/event.c +8 -0
@@ -1435,6 +1435,11 @@ size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp) event->context_switch.next_prev_tid); } +static size_t perf_event__fprintf_lost (union perf_event *event,FILE *fp) +{ +return fprintf (fp," lost %lu\n" , event->lost.lost); +} +size_t perf_event__fprintf (union perf_event *event,FILE *fp) { size_t ret = fprintf(fp, "PERF_RECORD_%s",
@@ -1467,6 +1472,9 @@ size_t perf_event__fprintf(union perf_event *event, FILE *fp)case PERF_RECORD_SWITCH_CPU_WIDE : ret +=perf_event__fprintf_switch (event, fp);break ; +case PERF_RECORD_LOST : + ret +=perf_event__fprintf_lost (event, fp); +break ;default : ret +=fprintf (fp,"\n" ); }
Signature · 1 line
2.13.6
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 09/12] perf script: Add support to display lost events
Em Sun, Jan 07, 2018 at 05:03:53PM +0100, Jiri Olsa escreveu:
tools/perf/util/event.c size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp) · line 1441
Quoted 5 lines
+++
b/tools/perf/util/event.ctools/perf/util/event.c +4
-0+static size_t perf_event__fprintf_lost (union perf_event *event,FILE *fp) +{ +return fprintf (fp," lost %lu\n" , event->lost.lost); +}
Had to make this:
return fprintf(fp, " lost %" PRIu64 "\n", event->lost.lost);
To fix this:
CC /tmp/build/perf/util/event.outil/event.c: In function 'perf_event__fprintf_lost':util/event.c:1440:21: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'u64 {aka long long unsigned int}' [-Werror=format=]
return fprintf(fp, " lost %lu\n", event->lost.lost);
^ CC /tmp/build/perf/builtin-script.o
CC /tmp/build/perf/builtin-kmem.o
cc1: all warnings being treated as errors
on these systems:
17 debian:experimental-x-mips : FAIL mips-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0 19 debian:experimental-x-mipsel: FAIL mipsel-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
25 fedora:24-x-ARC-uClibc : FAIL arc-linux-gcc (ARCompact ISA Linux uClibc toolchain 2017.09-rc2) 7.1.1 20170710 43 ubuntu:16.04-x-arm : FAIL arm-linux-gnueabihf-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 45 ubuntu:16.04-x-powerpc : FAIL powerpc-linux-gnu-gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
- Arnaldo
Re: [PATCH 09/12] perf script: Add support to display lost events
Quoted 10 lines · Arnaldo Carvalho de Melo
Em Sun, Jan 07, 2018 at 05:03:53PM +0100, Jiri Olsa escreveu:
tools/perf/util/event.c size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp) · line 1441
Quoted 5 lines
+++
b/tools/perf/util/event.ctools/perf/util/event.c +4
-0+static size_t perf_event__fprintf_lost (union perf_event *event,FILE *fp) +{ +return fprintf (fp," lost %lu\n" , event->lost.lost); +}Had to make this:
return fprintf(fp, " lost %" PRIu64 "\n", event->lost.lost);
right, thanks
jirka
Quoted 21 lines
To fix this:
CC
/tmp/build/perf/util/event.outil/event.c: In function 'perf_event__fprintf_lost':util/event.c:1440:21: error: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'u64 {aka long long unsigned int}' [-Werror=format=]return fprintf(fp, " lost %lu\n", event->lost.lost); ^CC
/tmp/build/perf/builtin-script.o
CC/tmp/build/perf/builtin-kmem.o
cc1: all warnings being treated as errorson these systems:
17 debian:experimental-x-mips : FAIL mips-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0 19 debian:experimental-x-mipsel: FAIL mipsel-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
25 fedora:24-x-ARC-uClibc : FAIL arc-linux-gcc (ARCompact ISA Linux uClibc toolchain 2017.09-rc2) 7.1.1 20170710 43 ubuntu:16.04-x-arm : FAIL arm-linux-gnueabihf-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609 45 ubuntu:16.04-x-powerpc : FAIL powerpc-linux-gnu-gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609- Arnaldo
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf script: Add support to display lost events
In reply to Jiri Olsaperf script: Add support to display lost events
Commit-ID: 3d7c27b6dbca4c90e7d921b45c2240e7c3cb92a2 Gitweb: https://git.kernel.org/tip/3d7c27b6dbca4c90e7d921b45c2240e7c3cb92a2 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Jan 2018 17:03:53 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 10 Jan 2018 12:00:39 -0300
perf script: Add support to display lost events
Adding option to display lost events:
$ perf script --show-lost-events ... mplayer 13810 [002] 468011.402396: 100 cycles:ppp: ff.. mplayer 13810 [002] 468011.402396: PERF_RECORD_LOST lost 3880 mplayer 13810 [002] 468011.402397: 100 cycles:ppp: ff..
--- tools/perf/Documentation/perf-script.txt | 3 +++ tools/perf/builtin-script.c | 28 ++++++++++++++++++++++++++++ tools/perf/util/event.c | 8 ++++++++ 3 files changed, 39 insertions(+)
tools/perf/Documentation/perf-script.txt +3 -0
@@ -300,6 +300,9 @@ OPTIONS Display context switch events i.e. events of type PERF_RECORD_SWITCH or PERF_RECORD_SWITCH_CPU_WIDE. +--show-lost-events + Display lost events i.e. events of type PERF_RECORD_LOST. + --demangle:: Demangle symbol names to human readable form. It's enabled by default, disable with --no-demangle.
tools/perf/builtin-script.c +28 -0
@@ -1489,6 +1489,7 @@ struct perf_script {bool show_mmap_events;bool show_switch_events;bool show_namespace_events; +bool show_lost_events;bool allocated;bool per_event_dump;struct cpu_map *cpus;
@@ -2080,6 +2081,29 @@ static int process_switch_event(struct perf_tool *tool,return 0 ; } +static int +process_lost_event (struct perf_tool *tool, +union perf_event *event, +struct perf_sample *sample, +struct machine *machine) +{ + struct perf_script *script = container_of(tool, struct perf_script, tool); +struct perf_session *session = script->session; +struct perf_evsel *evsel =perf_evlist__id2evsel (session->evlist, sample->id); +struct thread *thread; + + thread =machine__findnew_thread (machine, sample->pid, + sample->tid); +if (thread ==NULL ) +return -1 ; + +perf_sample__fprintf_start (sample, thread, evsel, +PERF_RECORD_LOST , stdout); +perf_event__fprintf (event, stdout); +thread__put (thread); +return 0 ; +} +static void sig_handler (int sig__maybe_unused ) { session_done =1 ;
@@ -2174,6 +2198,8 @@ static int __cmd_script(struct perf_script *script) script->tool.context_switch = process_switch_event;if (script->show_namespace_events) script->tool.namespaces = process_namespaces_event; +if (script->show_lost_events) + script->tool.lost = process_lost_event;if (perf_script__setup_per_event_dump (script)) {pr_err ("Couldn't create the per event dump files\n" );
@@ -3110,6 +3136,8 @@ int cmd_script(int argc, const char **argv) "Show context switch events (if recorded)"),OPT_BOOLEAN ('\0' ,"show-namespace-events" , &script.show_namespace_events,"Show namespace events (if recorded)" ), +OPT_BOOLEAN ('\0' ,"show-lost-events" , &script.show_lost_events, +"Show lost events (if recorded)" ),OPT_BOOLEAN ('\0' ,"per-event-dump" , &script.per_event_dump,"Dump trace output to files named by the monitored events" ), OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
tools/perf/util/event.c +8 -0
@@ -1435,6 +1435,11 @@ size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp) event->context_switch.next_prev_tid); } +static size_t perf_event__fprintf_lost (union perf_event *event,FILE *fp) +{ +return fprintf (fp," lost %" PRIu64"\n" , event->lost.lost); +} +size_t perf_event__fprintf (union perf_event *event,FILE *fp) { size_t ret = fprintf(fp, "PERF_RECORD_%s",
@@ -1467,6 +1472,9 @@ size_t perf_event__fprintf(union perf_event *event, FILE *fp)case PERF_RECORD_SWITCH_CPU_WIDE : ret +=perf_event__fprintf_switch (event, fp);break ; +case PERF_RECORD_LOST : + ret +=perf_event__fprintf_lost (event, fp); +break ;default : ret +=fprintf (fp,"\n" ); }
Jiri Olsa
reviewerPATCH 10/12 perf tools: Make the tool's warning messages optional
In reply to Jiri OlsaI want to display the pure events status coming in the next patch and the tool's warnings are superfluous in the output. Making it optional, enabled by default.
--- tools/perf/util/session.c | 6 ++++-- tools/perf/util/tool.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-)
tools/perf/util/session.c +4 -2
@@ -1773,7 +1773,8 @@ static int __perf_session__process_pipe_events(struct perf_session *session) err =perf_session__flush_thread_stacks (session); out_err:free (buf); -perf_session__warn_about_errors (session); +if (!tool->no_warn) +perf_session__warn_about_errors (session);ordered_events__free (&session->ordered_events);auxtrace__free_events (session);return err;
@@ -1929,7 +1930,8 @@ static int __perf_session__process_events(struct perf_session *session, err =perf_session__flush_thread_stacks (session); out_err:ui_progress__finish (); -perf_session__warn_about_errors (session); +if (!tool->no_warn) +perf_session__warn_about_errors (session);/* * We may switching perf.data output, make ordered_events * reusable.
tools/perf/util/tool.h +1 -0
@@ -76,6 +76,7 @@ struct perf_tool {bool ordered_events;bool ordering_requires_timestamps;bool namespace_events; +bool no_warn;enum show_feature_header show_feat_hdr; };
Signature · 1 line
2.13.6
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Make the tool's warning messages optional
perf tools: Make the tool's warning messages optional
Commit-ID: 075ca1ebb25e798e4072a1e3a482b829bb51afb2 Gitweb: https://git.kernel.org/tip/075ca1ebb25e798e4072a1e3a482b829bb51afb2 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Jan 2018 17:03:54 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 10 Jan 2018 12:00:55 -0300
perf tools: Make the tool's warning messages optional
I want to display the pure events status coming in the next patch and the tool's warnings are superfluous in the output. Making it optional, enabled by default.
--- tools/perf/util/session.c | 6 ++++-- tools/perf/util/tool.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-)
tools/perf/util/session.c +4 -2
@@ -1773,7 +1773,8 @@ done: err =perf_session__flush_thread_stacks (session); out_err:free (buf); -perf_session__warn_about_errors (session); +if (!tool->no_warn) +perf_session__warn_about_errors (session);ordered_events__free (&session->ordered_events);auxtrace__free_events (session);return err;
@@ -1929,7 +1930,8 @@ out: err =perf_session__flush_thread_stacks (session); out_err:ui_progress__finish (); -perf_session__warn_about_errors (session); +if (!tool->no_warn) +perf_session__warn_about_errors (session);/* * We may switching perf.data output, make ordered_events * reusable.
tools/perf/util/tool.h +1 -0
@@ -76,6 +76,7 @@ struct perf_tool {bool ordered_events;bool ordering_requires_timestamps;bool namespace_events; +bool no_warn;enum show_feature_header show_feat_hdr; };
Jiri Olsa
reviewerPATCH 11/12 perf report: Add --stat option to display quick data statistics
In reply to Jiri OlsaAdding --stat option to display quick data statistics of event numbers, without any further processing, like the one at the end of the perf report -D command.
$ perf report --stat
Aggregated stats:
TOTAL events: 4566
MMAP events: 113
LOST events: 19
COMM events: 3
FORK events: 400
SAMPLE events: 3315
MMAP2 events: 32
FINISHED_ROUND events: 681
THREAD_MAP events: 1
CPU_MAP events: 1
TIME_CONV events: 1
I found this useful when hunting lost events
for another change.
--- tools/perf/Documentation/perf-report.txt | 4 ++++ tools/perf/builtin-report.c | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-report.txt +4 -0
@@ -437,6 +437,10 @@ include::itrace.txt[] will be printed. Each entry is function name or file/line. Enabled by default, disable with --no-inline. +--stat:: + Display overall events statistics without any further processing. + (like the one at the end of the perf report -D command) + include::callchain-overhead-calculation.txt[] SEE ALSO
tools/perf/builtin-report.c +25 -1
@@ -60,6 +60,7 @@ struct report {bool show_threads;bool inverted_callchain;bool mem_mode; +bool stat_mode;bool header;bool header_only;bool nonany_branch_mode;
@@ -583,6 +584,20 @@ static void report__output_resort(struct report *rep)ui_progress__finish (); } +static void stat_setup (struct report *rep) +{ +memset (&rep->tool,0 ,sizeof (rep->tool)); + rep->tool.no_warn = true; +} + +static int stat_print (struct report *rep) +{ +struct perf_session *session = rep->session; + +perf_session__fprintf_nr_events (session, stdout); +return 0 ; +} +static int __cmd_report (struct report *rep) {int ret;
@@ -614,12 +629,18 @@ static int __cmd_report(struct report *rep)return ret; } +if (rep->stat_mode) +stat_setup (rep); + ret =perf_session__process_events (session);if (ret) {ui__error ("failed to process sample\n" );return ret; } +if (rep->stat_mode) +return stat_print (rep); +report__warn_kptr_restrict (rep);evlist__for_each_entry (session->evlist, pos)
@@ -776,6 +797,7 @@ int cmd_report(int argc, const char **argv)OPT_BOOLEAN ('q' ,"quiet" , &quiet,"Do not show any message" ),OPT_BOOLEAN ('D' ,"dump-raw-trace" , &dump_trace,"dump raw trace in ASCII" ), +OPT_BOOLEAN (0 ,"stat" , &report.stat_mode,"Display event stats" ),OPT_STRING ('k' ,"vmlinux" , &symbol_conf.vmlinux_name,"file" ,"vmlinux pathname" ), OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
@@ -1037,6 +1059,8 @@ int cmd_report(int argc, const char **argv) report.tool.show_feat_hdr =SHOW_FEAT_HEADER ;if (report.show_full_info) report.tool.show_feat_hdr =SHOW_FEAT_HEADER_FULL_INFO ; +if (report.stat_mode) + use_browser =0 ;if (strcmp (input_name,"-" ) !=0 )setup_browser (true);
@@ -1059,7 +1083,7 @@ int cmd_report(int argc, const char **argv) ret =0 ; goto error; } - }else if (use_browser ==0 && !quiet) { + }else if (use_browser ==0 && !quiet && !report.stat_mode) {fputs ("# To display the perf.data header info, please use --header/--header-only options.\n#\n" , stdout); }
Signature · 1 line
2.13.6
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf report: Add --stats option to display quick data statistics
perf report: Add --stats option to display quick data statistics
Commit-ID: a4a4d0a7a2b20f7880262de4f51685baaf693476 Gitweb: https://git.kernel.org/tip/a4a4d0a7a2b20f7880262de4f51685baaf693476 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Jan 2018 17:03:55 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 10 Jan 2018 12:00:56 -0300
perf report: Add --stats option to display quick data statistics
Add --stats option to display quick data statistics of event numbers, without any further processing, like the one at the end of the perf report -D command.
$ perf report --stat
Aggregated stats:
TOTAL events: 4566
MMAP events: 113
LOST events: 19
COMM events: 3
FORK events: 400
SAMPLE events: 3315
MMAP2 events: 32
FINISHED_ROUND events: 681
THREAD_MAP events: 1
CPU_MAP events: 1
TIME_CONV events: 1
I found this useful when hunting lost events for another change.
--- tools/perf/Documentation/perf-report.txt | 4 ++++ tools/perf/builtin-report.c | 26 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-report.txt +4 -0
@@ -457,6 +457,10 @@ include::itrace.txt[] will be printed. Each entry is function name or file/line. Enabled by default, disable with --no-inline. +--stats:: + Display overall events statistics without any further processing. + (like the one at the end of the perf report -D command) + include::callchain-overhead-calculation.txt[] SEE ALSO
tools/perf/builtin-report.c +25 -1
@@ -62,6 +62,7 @@ struct report {bool show_threads;bool inverted_callchain;bool mem_mode; +bool stats_mode;bool header;bool header_only;bool nonany_branch_mode;
@@ -588,6 +589,20 @@ static void report__output_resort(struct report *rep)ui_progress__finish (); } +static void stats_setup (struct report *rep) +{ +memset (&rep->tool,0 ,sizeof (rep->tool)); + rep->tool.no_warn = true; +} + +static int stats_print (struct report *rep) +{ +struct perf_session *session = rep->session; + +perf_session__fprintf_nr_events (session, stdout); +return 0 ; +} +static int __cmd_report (struct report *rep) {int ret;
@@ -619,12 +634,18 @@ static int __cmd_report(struct report *rep)return ret; } +if (rep->stats_mode) +stats_setup (rep); + ret =perf_session__process_events (session);if (ret) {ui__error ("failed to process sample\n" );return ret; } +if (rep->stats_mode) +return stats_print (rep); +report__warn_kptr_restrict (rep);evlist__for_each_entry (session->evlist, pos)
@@ -781,6 +802,7 @@ int cmd_report(int argc, const char **argv)OPT_BOOLEAN ('q' ,"quiet" , &quiet,"Do not show any message" ),OPT_BOOLEAN ('D' ,"dump-raw-trace" , &dump_trace,"dump raw trace in ASCII" ), +OPT_BOOLEAN (0 ,"stats" , &report.stats_mode,"Display event stats" ),OPT_STRING ('k' ,"vmlinux" , &symbol_conf.vmlinux_name,"file" ,"vmlinux pathname" ), OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
@@ -1042,6 +1064,8 @@ repeat: report.tool.show_feat_hdr =SHOW_FEAT_HEADER ;if (report.show_full_info) report.tool.show_feat_hdr =SHOW_FEAT_HEADER_FULL_INFO ; +if (report.stats_mode) + use_browser =0 ;if (strcmp (input_name,"-" ) !=0 )setup_browser (true);
@@ -1064,7 +1088,7 @@ repeat: ret =0 ; goto error; } - }else if (use_browser ==0 && !quiet) { + }else if (use_browser ==0 && !quiet && !report.stats_mode) {fputs ("# To display the perf.data header info, please use --header/--header-only options.\n#\n" , stdout); }
Jiri Olsa
reviewerPATCH 12/12 perf report: Add --task option to display monitored tasks
In reply to Jiri OlsaAdding --task option to display monitored tasks stored in perf.data. Displaying pid/tid/ppid plus the command string aligned to distinguish parent and child tasks.
$ perf record -a
...
$ perf report --task
# pid tid ppid comm
0 0 -1 |swapper
2 2 0 | kthreadd
14080 14080 2 | kworker/u17:1
4 4 2 | kworker/0:0H
6 6 2 | mm_percpu_wq
...
1 1 0 | systemd
23242 23242 1 | firefox
23242 23298 23242 | Cache2 I/O
23242 23304 23242 | GMPThread
...
1195 1195 1 | login
1611 1611 1195 | bash
1639 1639 1611 | startx
1663 1663 1639 | xinit
1673 1673 1663 | xmonad-x86_64-l
23939 23939 1673 | xterm
23941 23941 23939 | bash
23963 23963 23941 | mutt
24954 24954 23963 | offlineimap--- tools/perf/Documentation/perf-report.txt | 4 + tools/perf/builtin-report.c | 136 ++++++++++++++++++++++++++++++- 2 files changed, 138 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-report.txt +4 -0
@@ -441,6 +441,10 @@ include::itrace.txt[] Display overall events statistics without any further processing. (like the one at the end of the perf report -D command) +--task:: + Display monitored tasks stored in perf data. Displaying pid/tid/ppid + plus the command string aligned to distinguish parent and child tasks. + include::callchain-overhead-calculation.txt[] SEE ALSO
tools/perf/builtin-report.c +134 -2
185 lines not on this page · raw message
Signature · 1 line
2.13.6
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 12/12] perf report: Add --task option to display monitored tasks
Em Sun, Jan 07, 2018 at 05:03:56PM +0100, Jiri Olsa escreveu:
Quoted 3 lines
Adding --task option to display monitored tasks stored in perf.data. Displaying pid/tid/ppid plus the command string aligned to distinguish parent and child tasks.
I'm making this --tasks, plural, but then you can also use --task :-)
- Arnaldo
Quoted 246 lines
$ perf record -a ... $ perf report --task # pid tid ppid comm 0 0 -1 |swapper 2 2 0 | kthreadd 14080 14080 2 | kworker/u17:1 4 4 2 | kworker/0:0H 6 6 2 | mm_percpu_wq ... 1 1 0 | systemd 23242 23242 1 | firefox 23242 23298 23242 | Cache2 I/O 23242 23304 23242 | GMPThread ... 1195 1195 1 | login 1611 1611 1195 | bash 1639 1639 1611 | startx 1663 1663 1639 | xinit 1673 1673 1663 | xmonad-x86_64-l 23939 23939 1673 | xterm 23941 23941 23939 | bash 23963 23963 23941 | mutt 24954 24954 23963 | offlineimapSigned-off-by Jiri Olsa <[email protected]>--- tools/perf/Documentation/perf-report.txt | 4 + tools/perf/builtin-report.c | 136 ++++++++++++++++++++++++++++++- 2 files changed, 138 insertions(+), 2 deletions(-)tools/perf/Documentation/perf-report.txt +4
-0@@ -441,6 +441,10 @@ include::itrace.txt[] Display overall events statistics without any further processing. (like the one at the end of the perf report -D command) +--task:: + Display monitored tasks stored in perf data. Displaying pid/tid/ppid + plus the command string aligned to distinguish parent and child tasks. + include::callchain-overhead-calculation.txt[] SEE ALSOtools/perf/builtin-report.c +134
-2@@ -15,6 +15,7 @@#include "util/color.h" #include <linux/list.h> #include <linux/rbtree.h> +#include <linux/err.h> #include "util/symbol.h" #include "util/callchain.h" #include "util/values.h" @@ -61,6 +62,7 @@ struct report {bool inverted_callchain;bool mem_mode;bool stat_mode; +bool task_mode;bool header;bool header_only;bool nonany_branch_mode;@@ -598,6 +600,124 @@ static int stat_print(struct report *rep)return 0 ; } +static void task_setup (struct report *rep) +{ +memset (&rep->tool,0 ,sizeof (rep->tool)); + rep->tool.comm = perf_event__process_comm; + rep->tool.exit = perf_event__process_exit; + rep->tool.fork = perf_event__process_fork; + rep->tool.no_warn = true; +} + +struct task { +struct thread *thread; +struct list_head list; +struct list_head children; +}; + +static struct task *task_list (struct task *task,struct machine *machine) +{ +struct thread *parent_thread, *thread = task->thread; +struct task *parent_task; + +/* Already listed. */ +if (!list_empty (&task->list)) +return NULL ; + +/* Last one in the chain. */ +if (thread->ppid ==-1 ) +return task; + + parent_thread =machine__findnew_thread (machine,-1 , thread->ppid); +if (!parent_thread) +return ERR_PTR (-ENOMEM ); + + parent_task =thread__priv (parent_thread); +list_add_tail (&task->list, &parent_task->children); +return task_list (parent_task, machine); +} + +static void task__print_level (struct task *task,FILE *fp,int level) +{ +struct thread *thread = task->thread; +struct task *child; + +fprintf (fp," %8d %8d %8d |%*s%s\n" , + thread->pid_, thread->tid, thread->ppid, + level,"" ,thread__comm_str (thread)); + +if (!list_empty (&task->children)) { +list_for_each_entry (child, &task->children, list) +task__print_level (child, fp, level +1 ); + } +} + +static int task_print (struct report *rep,FILE *fp) +{ +struct perf_session *session = rep->session; +struct machine *machine = &session->machines.host; +struct task *tasks, *task; +unsigned int nr =0 , itask =0 , i; +struct rb_node *nd; +LIST_HEAD (list); + +/* +* No locking needed while accessing machine->threads, +* because --task is single threaded command. +*/ + +/* Count all the threads. */ +for (i =0 ; i <THREADS__TABLE_SIZE ; i++) + nr += machine->threads[i].nr; + + tasks =malloc (sizeof (*tasks) * nr); +if (!tasks) +return -ENOMEM ; + +for (i =0 ; i <THREADS__TABLE_SIZE ; i++) { +struct threads *threads = &machine->threads[i]; + +for (nd =rb_first (&threads->entries); nd; nd =rb_next (nd)) { + task = tasks + itask++; + + task->thread = rb_entry(nd, struct thread, rb_node); +INIT_LIST_HEAD (&task->children); +INIT_LIST_HEAD (&task->list); +thread__set_priv (task->thread, task); + } + } + +/* +* Iterate every task down to the unprocessed parent +* and link all in task children list. Task with no +* parent is added into 'list'. +*/ +for (itask =0 ; itask < nr; itask++) { + task = tasks + itask; + +if (!list_empty (&task->list)) +continue ; + + task =task_list (task, machine); +if (IS_ERR (task)) { +pr_err ("Error: failed to process tasks\n" ); +free (tasks); +return -ENOMEM ; + } + +if (task) +list_add_tail (&task->list, &list); + } + +fprintf (fp,"# %8s %8s %8s %s\n" ,"pid" ,"tid" ,"ppid" ,"comm" ); + +list_for_each_entry (task, &list, list) +task__print_level (task, fp,0 ); + +free (tasks); +return 0 ; +} +static int __cmd_report (struct report *rep) {int ret;@@ -632,6 +752,9 @@ static int __cmd_report(struct report *rep)if (rep->stat_mode)stat_setup (rep); +if (rep->task_mode) +task_setup (rep); + ret =perf_session__process_events (session);if (ret) {ui__error ("failed to process sample\n" );@@ -641,6 +764,9 @@ static int __cmd_report(struct report *rep)if (rep->stat_mode)return stat_print (rep); +if (rep->task_mode) +return task_print (rep, stdout); +report__warn_kptr_restrict (rep);evlist__for_each_entry (session->evlist, pos)@@ -798,6 +924,7 @@ int cmd_report(int argc, const char **argv)OPT_BOOLEAN ('D' ,"dump-raw-trace" , &dump_trace,"dump raw trace in ASCII" ),OPT_BOOLEAN (0 ,"stat" , &report.stat_mode,"Display event stats" ), +OPT_BOOLEAN (0 ,"task" , &report.task_mode,"Display recorded tasks" ),OPT_STRING ('k' ,"vmlinux" , &symbol_conf.vmlinux_name,"file" ,"vmlinux pathname" ), OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,@@ -1059,8 +1186,12 @@ int cmd_report(int argc, const char **argv) report.tool.show_feat_hdr =SHOW_FEAT_HEADER ;if (report.show_full_info) report.tool.show_feat_hdr =SHOW_FEAT_HEADER_FULL_INFO ; -if (report.stat_mode) +if (report.stat_mode || report.task_mode) use_browser =0 ; +if (report.stat_mode && report.task_mode) { +pr_err ("Error: --task and --stat options cannot be used together\n" ); + goto error; + }if (strcmp (input_name,"-" ) !=0 )setup_browser (true);@@ -1083,7 +1214,8 @@ int cmd_report(int argc, const char **argv) ret =0 ; goto error; } - }else if (use_browser ==0 && !quiet && !report.stat_mode) { + }else if (use_browser ==0 && !quiet && + !report.stat_mode && !report.task_mode) {fputs ("# To display the perf.data header info, please use --header/--header-only options.\n#\n" , stdout); }Signature · 1 line
2.13.6
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 12/12] perf report: Add --task option to display monitored tasks
Em Mon, Jan 08, 2018 at 12:55:34PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 6 lines
Em Sun, Jan 07, 2018 at 05:03:56PM +0100, Jiri Olsa escreveu:
Quoted 3 lines
Adding --task option to display monitored tasks stored in perf.data. Displaying pid/tid/ppid plus the command string aligned to distinguish parent and child tasks.
I'm making this --tasks, plural, but then you can also use --task :-)
And tested it, nice new feature! :-)
- Arnaldo
Quoted 248 lines
- Arnaldo
Quoted 246 lines
$ perf record -a ... $ perf report --task # pid tid ppid comm 0 0 -1 |swapper 2 2 0 | kthreadd 14080 14080 2 | kworker/u17:1 4 4 2 | kworker/0:0H 6 6 2 | mm_percpu_wq ... 1 1 0 | systemd 23242 23242 1 | firefox 23242 23298 23242 | Cache2 I/O 23242 23304 23242 | GMPThread ... 1195 1195 1 | login 1611 1611 1195 | bash 1639 1639 1611 | startx 1663 1663 1639 | xinit 1673 1673 1663 | xmonad-x86_64-l 23939 23939 1673 | xterm 23941 23941 23939 | bash 23963 23963 23941 | mutt 24954 24954 23963 | offlineimapSigned-off-by Jiri Olsa <[email protected]>--- tools/perf/Documentation/perf-report.txt | 4 + tools/perf/builtin-report.c | 136 ++++++++++++++++++++++++++++++- 2 files changed, 138 insertions(+), 2 deletions(-)tools/perf/Documentation/perf-report.txt +4
-0@@ -441,6 +441,10 @@ include::itrace.txt[] Display overall events statistics without any further processing. (like the one at the end of the perf report -D command) +--task:: + Display monitored tasks stored in perf data. Displaying pid/tid/ppid + plus the command string aligned to distinguish parent and child tasks. + include::callchain-overhead-calculation.txt[] SEE ALSOtools/perf/builtin-report.c +134
-2@@ -15,6 +15,7 @@#include "util/color.h" #include <linux/list.h> #include <linux/rbtree.h> +#include <linux/err.h> #include "util/symbol.h" #include "util/callchain.h" #include "util/values.h" @@ -61,6 +62,7 @@ struct report {bool inverted_callchain;bool mem_mode;bool stat_mode; +bool task_mode;bool header;bool header_only;bool nonany_branch_mode;@@ -598,6 +600,124 @@ static int stat_print(struct report *rep)return 0 ; } +static void task_setup (struct report *rep) +{ +memset (&rep->tool,0 ,sizeof (rep->tool)); + rep->tool.comm = perf_event__process_comm; + rep->tool.exit = perf_event__process_exit; + rep->tool.fork = perf_event__process_fork; + rep->tool.no_warn = true; +} + +struct task { +struct thread *thread; +struct list_head list; +struct list_head children; +}; + +static struct task *task_list (struct task *task,struct machine *machine) +{ +struct thread *parent_thread, *thread = task->thread; +struct task *parent_task; + +/* Already listed. */ +if (!list_empty (&task->list)) +return NULL ; + +/* Last one in the chain. */ +if (thread->ppid ==-1 ) +return task; + + parent_thread =machine__findnew_thread (machine,-1 , thread->ppid); +if (!parent_thread) +return ERR_PTR (-ENOMEM ); + + parent_task =thread__priv (parent_thread); +list_add_tail (&task->list, &parent_task->children); +return task_list (parent_task, machine); +} + +static void task__print_level (struct task *task,FILE *fp,int level) +{ +struct thread *thread = task->thread; +struct task *child; + +fprintf (fp," %8d %8d %8d |%*s%s\n" , + thread->pid_, thread->tid, thread->ppid, + level,"" ,thread__comm_str (thread)); + +if (!list_empty (&task->children)) { +list_for_each_entry (child, &task->children, list) +task__print_level (child, fp, level +1 ); + } +} + +static int task_print (struct report *rep,FILE *fp) +{ +struct perf_session *session = rep->session; +struct machine *machine = &session->machines.host; +struct task *tasks, *task; +unsigned int nr =0 , itask =0 , i; +struct rb_node *nd; +LIST_HEAD (list); + +/* +* No locking needed while accessing machine->threads, +* because --task is single threaded command. +*/ + +/* Count all the threads. */ +for (i =0 ; i <THREADS__TABLE_SIZE ; i++) + nr += machine->threads[i].nr; + + tasks =malloc (sizeof (*tasks) * nr); +if (!tasks) +return -ENOMEM ; + +for (i =0 ; i <THREADS__TABLE_SIZE ; i++) { +struct threads *threads = &machine->threads[i]; + +for (nd =rb_first (&threads->entries); nd; nd =rb_next (nd)) { + task = tasks + itask++; + + task->thread = rb_entry(nd, struct thread, rb_node); +INIT_LIST_HEAD (&task->children); +INIT_LIST_HEAD (&task->list); +thread__set_priv (task->thread, task); + } + } + +/* +* Iterate every task down to the unprocessed parent +* and link all in task children list. Task with no +* parent is added into 'list'. +*/ +for (itask =0 ; itask < nr; itask++) { + task = tasks + itask; + +if (!list_empty (&task->list)) +continue ; + + task =task_list (task, machine); +if (IS_ERR (task)) { +pr_err ("Error: failed to process tasks\n" ); +free (tasks); +return -ENOMEM ; + } + +if (task) +list_add_tail (&task->list, &list); + } + +fprintf (fp,"# %8s %8s %8s %s\n" ,"pid" ,"tid" ,"ppid" ,"comm" ); + +list_for_each_entry (task, &list, list) +task__print_level (task, fp,0 ); + +free (tasks); +return 0 ; +} +static int __cmd_report (struct report *rep) {int ret;@@ -632,6 +752,9 @@ static int __cmd_report(struct report *rep)if (rep->stat_mode)stat_setup (rep); +if (rep->task_mode) +task_setup (rep); + ret =perf_session__process_events (session);if (ret) {ui__error ("failed to process sample\n" );@@ -641,6 +764,9 @@ static int __cmd_report(struct report *rep)if (rep->stat_mode)return stat_print (rep); +if (rep->task_mode) +return task_print (rep, stdout); +report__warn_kptr_restrict (rep);evlist__for_each_entry (session->evlist, pos)@@ -798,6 +924,7 @@ int cmd_report(int argc, const char **argv)OPT_BOOLEAN ('D' ,"dump-raw-trace" , &dump_trace,"dump raw trace in ASCII" ),OPT_BOOLEAN (0 ,"stat" , &report.stat_mode,"Display event stats" ), +OPT_BOOLEAN (0 ,"task" , &report.task_mode,"Display recorded tasks" ),OPT_STRING ('k' ,"vmlinux" , &symbol_conf.vmlinux_name,"file" ,"vmlinux pathname" ), OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,@@ -1059,8 +1186,12 @@ int cmd_report(int argc, const char **argv) report.tool.show_feat_hdr =SHOW_FEAT_HEADER ;if (report.show_full_info) report.tool.show_feat_hdr =SHOW_FEAT_HEADER_FULL_INFO ; -if (report.stat_mode) +if (report.stat_mode || report.task_mode) use_browser =0 ; +if (report.stat_mode && report.task_mode) { +pr_err ("Error: --task and --stat options cannot be used together\n" ); + goto error; + }if (strcmp (input_name,"-" ) !=0 )setup_browser (true);@@ -1083,7 +1214,8 @@ int cmd_report(int argc, const char **argv) ret =0 ; goto error; } - }else if (use_browser ==0 && !quiet && !report.stat_mode) { + }else if (use_browser ==0 && !quiet && + !report.stat_mode && !report.task_mode) {fputs ("# To display the perf.data header info, please use --header/--header-only options.\n#\n" , stdout); }Signature · 1 line
2.13.6
Namhyung Kim
maintainerRe: [PATCH 12/12] perf report: Add --task option to display monitored tasks
In reply to Jiri OlsaHi Jiri,
Quoted 20 lines · Jiri Olsa
Adding --task option to display monitored tasks stored in perf.data. Displaying pid/tid/ppid plus the command string aligned to distinguish parent and child tasks.
$ perf record -a ... $ perf report --task # pid tid ppid comm 0 0 -1 |swapper 2 2 0 | kthreadd 14080 14080 2 | kworker/u17:1 4 4 2 | kworker/0:0H 6 6 2 | mm_percpu_wq ... 1 1 0 | systemd 23242 23242 1 | firefox 23242 23298 23242 | Cache2 I/O 23242 23304 23242 | GMPThread ... 1195 1195 1 | login
Quoted 8 lines
1611 1611 1195 | bash
1639 1639 1611 | startx
1663 1663 1639 | xinit
1673 1673 1663 | xmonad-x86_64-l
23939 23939 1673 | xterm
23941 23941 23939 | bash
23963 23963 23941 | mutt
24954 24954 23963 | offlineimapNice! :)
Quoted 66 lines
Signed-off-by Jiri Olsa <[email protected]>--- tools/perf/Documentation/perf-report.txt | 4 + tools/perf/builtin-report.c | 136 ++++++++++++++++++++++++++++++- 2 files changed, 138 insertions(+), 2 deletions(-)tools/perf/Documentation/perf-report.txt +4
-0@@ -441,6 +441,10 @@ include::itrace.txt[] Display overall events statistics without any further processing. (like the one at the end of the perf report -D command) +--task:: + Display monitored tasks stored in perf data. Displaying pid/tid/ppid + plus the command string aligned to distinguish parent and child tasks. + include::callchain-overhead-calculation.txt[] SEE ALSOtools/perf/builtin-report.c +21
-0@@ -15,6 +15,7 @@#include "util/color.h" #include <linux/list.h> #include <linux/rbtree.h> +#include <linux/err.h> #include "util/symbol.h" #include "util/callchain.h" #include "util/values.h" @@ -61,6 +62,7 @@ struct report {bool inverted_callchain;bool mem_mode;bool stat_mode; +bool task_mode;bool header;bool header_only;bool nonany_branch_mode;@@ -598,6 +600,124 @@ static int stat_print(struct report *rep)return 0 ; } +static void task_setup (struct report *rep) +{ +memset (&rep->tool,0 ,sizeof (rep->tool)); + rep->tool.comm = perf_event__process_comm; + rep->tool.exit = perf_event__process_exit; + rep->tool.fork = perf_event__process_fork; + rep->tool.no_warn = true; +} + +struct task { +struct thread *thread; +struct list_head list; +struct list_head children; +}; + +static struct task *task_list (struct task *task,struct machine *machine) +{ +struct thread *parent_thread, *thread = task->thread; +struct task *parent_task;
tools/perf/builtin-report.c static int stat_print(struct report *rep) · line 631
Quoted 10 lines
tools/perf/builtin-report.c +10
-0+ +/* Already listed. */ +if (!list_empty (&task->list)) +return NULL ; + +/* Last one in the chain. */ +if (thread->ppid ==-1 ) +return task; + + parent_thread =machine__findnew_thread (machine,-1 , thread->ppid);
I think it should be machine__find_thread() since creating a new thread at this stage would lack thread->priv anyway.
Thanks,
Namhyung
Quoted 7 lines
tools/perf/builtin-report.c +7
-0+if (!parent_thread) +return ERR_PTR (-ENOMEM ); + + parent_task =thread__priv (parent_thread); +list_add_tail (&task->list, &parent_task->children); +return task_list (parent_task, machine); +}
Re: [PATCH 12/12] perf report: Add --task option to display monitored tasks
On Tue, Jan 09, 2018 at 10:56:07AM +0900, Namhyung Kim wrote:
SNIP
Quoted 9 lines
Quoted 9 lines
tools/perf/builtin-report.c +9
-0+static struct task *task_list (struct task *task,struct machine *machine) +{ +struct thread *parent_thread, *thread = task->thread; +struct task *parent_task; + +/* Already listed. */ +if (!list_empty (&task->list)) +return NULL ; +
Quoted 8 lines
tools/perf/builtin-report.c static int stat_print(struct report *rep) · line 631
Quoted 5 lines
tools/perf/builtin-report.c +5
-0+/* Last one in the chain. */ +if (thread->ppid ==-1 ) +return task; + + parent_thread =machine__findnew_thread (machine,-1 , thread->ppid);I think it should be
machine__find_thread()since creating a new thread at this stage would lackthread->privanyway.
ugh, that's right.. I tried to stay safe, but the NULL in priv would bring it down anyway
Arnaldo,
I already see changed version on top of your branch, please let me know if you make also this change or I should send v2
thanks,
jirka
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 12/12] perf report: Add --task option to display monitored tasks
Em Tue, Jan 09, 2018 at 10:15:51AM +0100, Jiri Olsa escreveu:
Quoted 22 lines · Namhyung Kim
SNIP
Quoted 9 lines
Quoted 9 lines
(quoted diff) +9
-0+static struct task *task_list(struct task *task, struct machine *machine) +{ + struct thread *parent_thread, *thread = task->thread; + struct task *parent_task; + + /* Already listed. */ + if (!list_empty(&task->list)) + return NULL; +Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ /* Last one in the chain. */ + if (thread->ppid == -1) + return task; + + parent_thread = machine__findnew_thread(machine, -1, thread->ppid);I think it should be
machine__find_thread()since creating a new thread at this stage would lackthread->privanyway.
Quoted 7 lines
ugh, that's right.. I tried to stay safe, but the NULL in priv would bring it down anyway
Arnaldo,
I already see changed version on top of your branch, please let me know if you make also this change or I should send v2
I can make the change, thanks!
Just to make sure we're on the same page, just this, right?
tools/perf/builtin-report.c +2 -2
@@ -633,9 +633,9 @@ static struct task *tasks_list(struct task *task, struct machine *machine)if (thread->ppid ==-1 )return task; - parent_thread =machine__findnew_thread (machine,-1 , thread->ppid); + parent_thread =machine__find_thread (machine,-1 , thread->ppid);if (!parent_thread) -return ERR_PTR (-ENOMEM ); +return ERR_PTR (-ENOENT ); parent_task =thread__priv (parent_thread);list_add_tail (&task->list, &parent_task->children);
Re: [PATCH 12/12] perf report: Add --task option to display monitored tasks
Quoted 40 lines · Arnaldo Carvalho de Melo
Em Tue, Jan 09, 2018 at 10:15:51AM +0100, Jiri Olsa escreveu:
Quoted 22 lines · Namhyung Kim
SNIP
Quoted 9 lines
Quoted 9 lines
(quoted diff) +9
-0+static struct task *task_list(struct task *task, struct machine *machine) +{ + struct thread *parent_thread, *thread = task->thread; + struct task *parent_task; + + /* Already listed. */ + if (!list_empty(&task->list)) + return NULL; +Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ /* Last one in the chain. */ + if (thread->ppid == -1) + return task; + + parent_thread = machine__findnew_thread(machine, -1, thread->ppid);I think it should be
machine__find_thread()since creating a new thread at this stage would lackthread->privanyway.Quoted 7 lines
ugh, that's right.. I tried to stay safe, but the NULL in priv would bring it down anyway
Arnaldo,
I already see changed version on top of your branch, please let me know if you make also this change or I should send v2I can make the change, thanks!
Just to make sure we're on the same page, just this, right?
tools/perf/builtin-report.c +0
-0
tools/perf/builtin-report.c static struct task *tasks_list(struct task *task, struct machine *machine) · line 636
Quoted 5 lines
tools/perf/builtin-report.c +1
-1@@ -633,9 +633,9 @@ static struct task *tasks_list(struct task *task, struct machine *machine)if (thread->ppid ==-1 )return task; - parent_thread =machine__findnew_thread (machine,-1 , thread->ppid); + parent_thread =machine__find_thread (machine,-1 , thread->ppid);
yes
tools/perf/builtin-report.c static struct task *tasks_list(struct task *task, struct machine *machine) · line 638
Quoted 3 lines
tools/perf/builtin-report.c +1
-1if (!parent_thread) -return ERR_PTR (-ENOMEM ); +return ERR_PTR (-ENOENT );
right, I haven't noticed this one.. then we should also do in the attached change
thanks,
jirka
---
tools/perf/builtin-report.c +1 -1
@@ -710,7 +710,7 @@ static int tasks_print(struct report *rep, FILE *fp)if (IS_ERR (task)) {pr_err ("Error: failed to process tasks\n" );free (tasks); -return -ENOMEM ; +return PTR_ERR (task); }if (task)
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf report: Add --tasks option to display monitored tasks
In reply to Jiri Olsaperf report: Add --tasks option to display monitored tasks
Commit-ID: 930f8b3479444d264aa33e008c4b00b86e8c62cc Gitweb: https://git.kernel.org/tip/930f8b3479444d264aa33e008c4b00b86e8c62cc Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 7 Jan 2018 17:03:56 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 10 Jan 2018 12:00:56 -0300
perf report: Add --tasks option to display monitored tasks
Add --tasks option to display monitored tasks stored in perf.data. Displaying pid/tid/ppid plus the command string aligned to distinguish parent and child tasks.
$ perf record -a
...
$ perf report --tasks
# pid tid ppid comm
0 0 -1 |swapper
2 2 0 | kthreadd
14080 14080 2 | kworker/u17:1
4 4 2 | kworker/0:0H
6 6 2 | mm_percpu_wq
...
1 1 0 | systemd
23242 23242 1 | firefox
23242 23298 23242 | Cache2 I/O
23242 23304 23242 | GMPThread
...
1195 1195 1 | login
1611 1611 1195 | bash
1639 1639 1611 | startx
1663 1663 1639 | xinit
1673 1673 1663 | xmonad-x86_64-l
23939 23939 1673 | xterm
23941 23941 23939 | bash
23963 23963 23941 | mutt
24954 24954 23963 | offlineimap--- tools/perf/Documentation/perf-report.txt | 4 + tools/perf/builtin-report.c | 136 ++++++++++++++++++++++++++++++- 2 files changed, 138 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-report.txt +4 -0
@@ -461,6 +461,10 @@ include::itrace.txt[] Display overall events statistics without any further processing. (like the one at the end of the perf report -D command) +--tasks:: + Display monitored tasks stored in perf data. Displaying pid/tid/ppid + plus the command string aligned to distinguish parent and child tasks. + include::callchain-overhead-calculation.txt[] SEE ALSO
tools/perf/builtin-report.c +134 -2
185 lines not on this page · raw message