2020-01-06 16:09:12

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [GIT PULL] perf/core improvements and fixes

Hi Ingo/Thomas,

Please consider pulling,

Best regards,

- Arnaldo

Test results at the end of this message, as usual.

The following changes since commit b9fb2de0115bbacab36da31fd10483ea66d9cfab:

Merge tag 'perf-urgent-for-mingo-5.5-20191223' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent (2019-12-23 22:27:44 +0100)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-5.6-20200106

for you to fetch changes up to 6c4798d3f08b81c2c52936b10e0fa872590c96ae:

tools lib: Fix builds when glibc contains strlcpy() (2020-01-06 11:46:10 -0300)

----------------------------------------------------------------
perf/core improvements and fixes.

perf record:

Alexey Budankov:

- Adapt affinity for machines with #CPUs > 1K to overcome current 1024 CPUs
mask size limitation of cpu_set_t type.

perf report/top TUI:

Arnaldo Carvalho de Melo:

- Make ENTER consistently present the pop up menu with and without call
chains, to eliminate confusion. The menu continues available at all times
use 'm' and '+' can be used to toggle just one call chain level, 'e' for all
the call chains for a top level histogram entry and 'E' to expand all call
chains in all top level entries. Extra info about these options was added to
the pop up menu entries. Pressing 'k' serves as special hotkey to go straight
to the main vmlinux entries, to avoid having to press enter and then select
"Zoom into the kernel DSO".

perf sched timehist:

David Ahern:

- Add support for filtering on CPU.

perf tests:

Arnaldo Carvalho de Melo:

- Show expected versus obtained values in bp_signal test.

libperf:

Jiri Olsa:

- Move to tools/lib/perf.

- Add man pages.

libapi:

Andrey Zhizhikin:

- Fix gcc9 stringop-truncation compilation error.

tools lib:

Vitaly Chikunov:

- Fix builds when glibc contains strlcpy(), which is the case for ALT Linux.

Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>

----------------------------------------------------------------
Alexey Budankov (3):
tools bitmap: Implement bitmap_equal() operation at bitmap API
perf mmap: Declare type for cpu mask of arbitrary length
perf record: Adapt affinity to machines with #CPUs > 1K

Andrey Zhizhikin (1):
tools lib api fs: Fix gcc9 stringop-truncation compilation error

Arnaldo Carvalho de Melo (12):
perf tests bp_signal: Show expected versus obtained values
perf hists browser: Restore ESC as "Zoom out" of DSO/thread/etc
perf report/top: Make ENTER consistently bring up menu
perf report/top: Add menu entry for toggling callchain expansion
perf report/top: Improve toggle callchain menu option
perf hists browser: Generalize the do_zoom_dso() function
perf report/top: Add 'k' hotkey to zoom directly into the kernel map
perf hists browser: Allow passing an initial hotkey
tools ui popup: Allow returning hotkeys
perf report/top: Allow pressing hotkeys in the options popup menu
perf report/top: Do not offer annotation for symbols without samples
perf report/top: Make 'e' visible in the help and make it toggle showing callchains

David Ahern (1):
perf sched timehist: Add support for filtering on CPU

Jiri Olsa (2):
libperf: Move to tools/lib/perf
libperf: Add man pages

Vitaly Chikunov (1):
tools lib: Fix builds when glibc contains strlcpy()

tools/include/linux/bitmap.h | 30 +++
tools/include/linux/string.h | 8 +
tools/lib/api/fs/fs.c | 4 +-
tools/lib/bitmap.c | 15 ++
tools/{perf/lib => lib/perf}/Build | 0
tools/lib/perf/Documentation/Makefile | 156 ++++++++++++
tools/lib/perf/Documentation/asciidoc.conf | 120 +++++++++
tools/lib/perf/Documentation/examples/sampling.c | 119 +++++++++
tools/lib/perf/Documentation/libperf-counting.txt | 211 ++++++++++++++++
tools/lib/perf/Documentation/libperf-sampling.txt | 243 ++++++++++++++++++
tools/lib/perf/Documentation/libperf.txt | 246 ++++++++++++++++++
tools/lib/perf/Documentation/manpage-1.72.xsl | 14 ++
tools/lib/perf/Documentation/manpage-base.xsl | 35 +++
.../perf/Documentation/manpage-bold-literal.xsl | 17 ++
tools/lib/perf/Documentation/manpage-normal.xsl | 13 +
.../lib/perf/Documentation/manpage-suppress-sp.xsl | 21 ++
tools/{perf/lib => lib/perf}/Makefile | 7 +-
tools/{perf/lib => lib/perf}/core.c | 0
tools/{perf/lib => lib/perf}/cpumap.c | 0
tools/{perf/lib => lib/perf}/evlist.c | 0
tools/{perf/lib => lib/perf}/evsel.c | 0
.../lib => lib/perf}/include/internal/cpumap.h | 0
.../lib => lib/perf}/include/internal/evlist.h | 0
.../lib => lib/perf}/include/internal/evsel.h | 0
.../{perf/lib => lib/perf}/include/internal/lib.h | 0
.../{perf/lib => lib/perf}/include/internal/mmap.h | 0
.../lib => lib/perf}/include/internal/tests.h | 0
.../lib => lib/perf}/include/internal/threadmap.h | 0
.../lib => lib/perf}/include/internal/xyarray.h | 0
tools/{perf/lib => lib/perf}/include/perf/core.h | 0
tools/{perf/lib => lib/perf}/include/perf/cpumap.h | 0
tools/{perf/lib => lib/perf}/include/perf/event.h | 0
tools/{perf/lib => lib/perf}/include/perf/evlist.h | 0
tools/{perf/lib => lib/perf}/include/perf/evsel.h | 0
tools/{perf/lib => lib/perf}/include/perf/mmap.h | 0
.../lib => lib/perf}/include/perf/threadmap.h | 0
tools/{perf/lib => lib/perf}/internal.h | 0
tools/{perf/lib => lib/perf}/lib.c | 0
tools/{perf/lib => lib/perf}/libperf.map | 0
tools/{perf/lib => lib/perf}/libperf.pc.template | 0
tools/{perf/lib => lib/perf}/mmap.c | 0
tools/{perf/lib => lib/perf}/tests/Makefile | 2 +-
tools/{perf/lib => lib/perf}/tests/test-cpumap.c | 0
tools/{perf/lib => lib/perf}/tests/test-evlist.c | 0
tools/{perf/lib => lib/perf}/tests/test-evsel.c | 0
.../{perf/lib => lib/perf}/tests/test-threadmap.c | 0
tools/{perf/lib => lib/perf}/threadmap.c | 0
tools/{perf/lib => lib/perf}/xyarray.c | 0
tools/lib/string.c | 7 +
tools/perf/Documentation/perf-sched.txt | 4 +
tools/perf/MANIFEST | 1 +
tools/perf/Makefile.config | 2 +-
tools/perf/Makefile.perf | 2 +-
tools/perf/builtin-c2c.c | 4 +-
tools/perf/builtin-record.c | 28 ++-
tools/perf/builtin-sched.c | 13 +
tools/perf/lib/Documentation/Makefile | 7 -
tools/perf/lib/Documentation/man/libperf.rst | 100 --------
tools/perf/lib/Documentation/tutorial/tutorial.rst | 123 ---------
tools/perf/tests/bp_signal.c | 10 +-
tools/perf/ui/browsers/hists.c | 277 ++++++++++++++-------
tools/perf/ui/browsers/hists.h | 2 +-
tools/perf/ui/browsers/res_sample.c | 2 +-
tools/perf/ui/browsers/scripts.c | 2 +-
tools/perf/ui/tui/util.c | 12 +-
tools/perf/ui/util.h | 2 +-
tools/perf/util/mmap.c | 40 ++-
tools/perf/util/mmap.h | 13 +-
tools/perf/util/sort.c | 3 +-
tools/perf/util/sort.h | 2 +
70 files changed, 1565 insertions(+), 352 deletions(-)
rename tools/{perf/lib => lib/perf}/Build (100%)
create mode 100644 tools/lib/perf/Documentation/Makefile
create mode 100644 tools/lib/perf/Documentation/asciidoc.conf
create mode 100644 tools/lib/perf/Documentation/examples/sampling.c
create mode 100644 tools/lib/perf/Documentation/libperf-counting.txt
create mode 100644 tools/lib/perf/Documentation/libperf-sampling.txt
create mode 100644 tools/lib/perf/Documentation/libperf.txt
create mode 100644 tools/lib/perf/Documentation/manpage-1.72.xsl
create mode 100644 tools/lib/perf/Documentation/manpage-base.xsl
create mode 100644 tools/lib/perf/Documentation/manpage-bold-literal.xsl
create mode 100644 tools/lib/perf/Documentation/manpage-normal.xsl
create mode 100644 tools/lib/perf/Documentation/manpage-suppress-sp.xsl
rename tools/{perf/lib => lib/perf}/Makefile (96%)
rename tools/{perf/lib => lib/perf}/core.c (100%)
rename tools/{perf/lib => lib/perf}/cpumap.c (100%)
rename tools/{perf/lib => lib/perf}/evlist.c (100%)
rename tools/{perf/lib => lib/perf}/evsel.c (100%)
rename tools/{perf/lib => lib/perf}/include/internal/cpumap.h (100%)
rename tools/{perf/lib => lib/perf}/include/internal/evlist.h (100%)
rename tools/{perf/lib => lib/perf}/include/internal/evsel.h (100%)
rename tools/{perf/lib => lib/perf}/include/internal/lib.h (100%)
rename tools/{perf/lib => lib/perf}/include/internal/mmap.h (100%)
rename tools/{perf/lib => lib/perf}/include/internal/tests.h (100%)
rename tools/{perf/lib => lib/perf}/include/internal/threadmap.h (100%)
rename tools/{perf/lib => lib/perf}/include/internal/xyarray.h (100%)
rename tools/{perf/lib => lib/perf}/include/perf/core.h (100%)
rename tools/{perf/lib => lib/perf}/include/perf/cpumap.h (100%)
rename tools/{perf/lib => lib/perf}/include/perf/event.h (100%)
rename tools/{perf/lib => lib/perf}/include/perf/evlist.h (100%)
rename tools/{perf/lib => lib/perf}/include/perf/evsel.h (100%)
rename tools/{perf/lib => lib/perf}/include/perf/mmap.h (100%)
rename tools/{perf/lib => lib/perf}/include/perf/threadmap.h (100%)
rename tools/{perf/lib => lib/perf}/internal.h (100%)
rename tools/{perf/lib => lib/perf}/lib.c (100%)
rename tools/{perf/lib => lib/perf}/libperf.map (100%)
rename tools/{perf/lib => lib/perf}/libperf.pc.template (100%)
rename tools/{perf/lib => lib/perf}/mmap.c (100%)
rename tools/{perf/lib => lib/perf}/tests/Makefile (93%)
rename tools/{perf/lib => lib/perf}/tests/test-cpumap.c (100%)
rename tools/{perf/lib => lib/perf}/tests/test-evlist.c (100%)
rename tools/{perf/lib => lib/perf}/tests/test-evsel.c (100%)
rename tools/{perf/lib => lib/perf}/tests/test-threadmap.c (100%)
rename tools/{perf/lib => lib/perf}/threadmap.c (100%)
rename tools/{perf/lib => lib/perf}/xyarray.c (100%)
delete mode 100644 tools/perf/lib/Documentation/Makefile
delete mode 100644 tools/perf/lib/Documentation/man/libperf.rst
delete mode 100644 tools/perf/lib/Documentation/tutorial/tutorial.rst

Test results:

The first ones are container based builds of tools/perf with and without libelf
support. Where clang is available, it is also used to build perf with/without
libelf, and building with LIBCLANGLLVM=1 (built-in clang) with gcc and clang
when clang and its devel libraries are installed.

The objtool and samples/bpf/ builds are disabled now that I'm switching from
using the sources in a local volume to fetching them from a http server to
build it inside the container, to make it easier to build in a container cluster.
Those will come back later.

Several are cross builds, the ones with -x-ARCH and the android one, and those
may not have all the features built, due to lack of multi-arch devel packages,
available and being used so far on just a few, like
debian:experimental-x-{arm64,mipsel}.

The 'perf test' one will perform a variety of tests exercising
tools/perf/util/, tools/lib/{bpf,traceevent,etc}, as well as run perf commands
with a variety of command line event specifications to then intercept the
sys_perf_event syscall to check that the perf_event_attr fields are set up as
expected, among a variety of other unit tests.

Then there is the 'make -C tools/perf build-test' ones, that build tools/perf/
with a variety of feature sets, exercising the build with an incomplete set of
features as well as with a complete one. It is planned to have it run on each
of the containers mentioned above, using some container orchestration
infrastructure. Get in contact if interested in helping having this in place.

Clearlinux is failing when due to:

`.gnu.debuglto_.debug_macro' referenced in section `.gnu.debuglto_.debug_macro' of /tmp/build/perf/util/scripting-engines/perf-in.o: defined in discarded section `.gnu.debuglto_.debug_macro[wm4.stdcpredef.h.19.8dc41bed5d9037ff9622e015fb5f0ce3]' of /tmp/build/perf/util/scripting-engines/perf-in.o

OpenMandriva Cooker works well with gcc, uncovers a bug where we have to
get compiler-clang.h from the kernel sources, will be fixed soon.

With the update of linux/linkage.h to move from ENTRY()/ENDPROC() to
SYM_FUNC_START()/etc some of the older containers can't be used with clang,
as the minimum version for the constructs used in the new linkage.h is 3.5,
older versions (3.4, 3.4.2, etc) end up with:

bench/../../arch/x86/lib/memcpy_64.S:44:14: error: unexpected token in '.type' directive
.type MEMCPY STT_FUNC ; .size MEMCPY, .-MEMCPY
^

# export PERF_TARBALL=http://192.168.124.1/perf/perf-5.5.0-rc3.tar.xz
# dm
1 alpine:3.4 : Ok gcc (Alpine 5.3.0) 5.3.0, clang version 3.8.0 (tags/RELEASE_380/final)
2 alpine:3.5 : Ok gcc (Alpine 6.2.1) 6.2.1 20160822, clang version 3.8.1 (tags/RELEASE_381/final)
3 alpine:3.6 : Ok gcc (Alpine 6.3.0) 6.3.0, clang version 4.0.0 (tags/RELEASE_400/final)
4 alpine:3.7 : Ok gcc (Alpine 6.4.0) 6.4.0, Alpine clang version 5.0.0 (tags/RELEASE_500/final) (based on LLVM 5.0.0)
5 alpine:3.8 : Ok gcc (Alpine 6.4.0) 6.4.0, Alpine clang version 5.0.1 (tags/RELEASE_501/final) (based on LLVM 5.0.1)
6 alpine:3.9 : Ok gcc (Alpine 8.3.0) 8.3.0, Alpine clang version 5.0.1 (tags/RELEASE_502/final) (based on LLVM 5.0.1)
7 alpine:3.10 : Ok gcc (Alpine 8.3.0) 8.3.0, Alpine clang version 8.0.0 (tags/RELEASE_800/final) (based on LLVM 8.0.0)
8 alpine:3.11 : Ok gcc (Alpine 9.2.0) 9.2.0, Alpine clang version 9.0.0 (https://git.alpinelinux.org/aports f7f0d2c2b8bcd6a5843401a9a702029556492689) (based on LLVM 9.0.0)
9 alpine:edge : Ok gcc (Alpine 9.2.0) 9.2.0, Alpine clang version 9.0.0 (git://git.alpinelinux.org/aports 25c73ae7b95bdb42ae5f0ceac3b703e766582527) (based on LLVM 9.0.0)
10 alt:p8 : Ok x86_64-alt-linux-gcc (GCC) 5.3.1 20151207 (ALT p8 5.3.1-alt3.M80P.1), clang version 3.8.0 (tags/RELEASE_380/final)
11 alt:p9 : Ok x86_64-alt-linux-gcc (GCC) 8.3.1 20190507 (ALT p9 8.3.1-alt5), clang version 7.0.1
12 alt:sisyphus : Ok x86_64-alt-linux-gcc (GCC) 9.2.1 20190827 (ALT Sisyphus 9.2.1-alt2), clang version 7.0.1
13 amazonlinux:1 : Ok gcc (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2), clang version 3.6.2 (tags/RELEASE_362/final)
14 amazonlinux:2 : Ok gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-6), clang version 7.0.1 (Amazon Linux 2 7.0.1-1.amzn2.0.2)
15 android-ndk:r12b-arm : Ok arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
16 android-ndk:r15c-arm : Ok arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
17 centos:5 : Ok gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55)
18 centos:6 : Ok gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
19 centos:7 : Ok gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
20 centos:8 : Ok gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3), clang version 7.0.1 (tags/RELEASE_701/final)
21 clearlinux:latest : Ok gcc (Clear Linux OS for Intel Architecture) 9.2.1 20191210 gcc-9-branch@279166, clang version 9.0.0 (tags/RELEASE_900/final)
22 debian:8 : Ok gcc (Debian 4.9.2-10+deb8u2) 4.9.2, Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
23 debian:9 : Ok gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, clang version 3.8.1-24 (tags/RELEASE_381/final)
24 debian:10 : Ok gcc (Debian 8.3.0-6) 8.3.0, clang version 7.0.1-8 (tags/RELEASE_701/final)
25 debian:experimental : Ok gcc (Debian 9.2.1-19) 9.2.1 20191109, clang version 8.0.1-4 (tags/RELEASE_801/final)
26 debian:experimental-x-arm64 : Ok aarch64-linux-gnu-gcc (Debian 8.3.0-19) 8.3.0
27 debian:experimental-x-mips : Ok mips-linux-gnu-gcc (Debian 8.3.0-19) 8.3.0
28 debian:experimental-x-mips64 : Ok mips64-linux-gnuabi64-gcc (Debian 9.2.1-8) 9.2.1 20190909
29 debian:experimental-x-mipsel : Ok mipsel-linux-gnu-gcc (Debian 9.2.1-8) 9.2.1 20190909
30 fedora:20 : Ok gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)
31 fedora:22 : Ok gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6), clang version 3.5.0 (tags/RELEASE_350/final)
32 fedora:23 : Ok gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6), clang version 3.7.0 (tags/RELEASE_370/final)
33 fedora:24 : Ok gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1), clang version 3.8.1 (tags/RELEASE_381/final)
34 fedora:24-x-ARC-uClibc : Ok arc-linux-gcc (ARCompact ISA Linux uClibc toolchain 2017.09-rc2) 7.1.1 20170710
35 fedora:25 : Ok gcc (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1), clang version 3.9.1 (tags/RELEASE_391/final)
36 fedora:26 : Ok gcc (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2), clang version 4.0.1 (tags/RELEASE_401/final)
37 fedora:27 : Ok gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-6), clang version 5.0.2 (tags/RELEASE_502/final)
38 fedora:28 : Ok gcc (GCC) 8.3.1 20190223 (Red Hat 8.3.1-2), clang version 6.0.1 (tags/RELEASE_601/final)
39 fedora:29 : Ok gcc (GCC) 8.3.1 20190223 (Red Hat 8.3.1-2), clang version 7.0.1 (Fedora 7.0.1-6.fc29)
40 fedora:30 : Ok gcc (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1), clang version 8.0.0 (Fedora 8.0.0-3.fc30)
41 fedora:30-x-ARC-glibc : Ok arc-linux-gcc (ARC HS GNU/Linux glibc toolchain 2019.03-rc1) 8.3.1 20190225
42 fedora:30-x-ARC-uClibc : Ok arc-linux-gcc (ARCv2 ISA Linux uClibc toolchain 2019.03-rc1) 8.3.1 20190225
43 fedora:31 : Ok gcc (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1), clang version 9.0.0 (Fedora 9.0.0-1.fc31)
44 fedora:32 : Ok gcc (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1), clang version 9.0.0 (Fedora 9.0.0-1.fc32)
45 fedora:rawhide : Ok gcc (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1), clang version 9.0.0 (Fedora 9.0.0-1.fc32)
46 gentoo-stage3-amd64:latest : Ok gcc (Gentoo 9.2.0-r2 p3) 9.2.0
47 mageia:5 : Ok gcc (GCC) 4.9.2, clang version 3.5.2 (tags/RELEASE_352/final)
48 mageia:6 : Ok gcc (Mageia 5.5.0-1.mga6) 5.5.0, clang version 3.9.1 (tags/RELEASE_391/final)
49 mageia:7 : Ok gcc (Mageia 8.3.1-0.20190524.1.mga7) 8.3.1 20190524, clang version 8.0.0 (Mageia 8.0.0-1.mga7)
50 manjaro:latest : Ok gcc (GCC) 9.2.0, clang version 9.0.0 (tags/RELEASE_900/final)
51 openmandriva:cooker : Ok gcc (GCC) 9.2.1 20191123 (OpenMandriva)
52 opensuse:15.0 : Ok gcc (SUSE Linux) 7.4.1 20190424 [gcc-7-branch revision 270538], clang version 5.0.1 (tags/RELEASE_501/final 312548)
53 opensuse:15.1 : Ok gcc (SUSE Linux) 7.4.1 20190905 [gcc-7-branch revision 275407], clang version 7.0.1 (tags/RELEASE_701/final 349238)
54 opensuse:15.2 : Ok gcc (SUSE Linux) 7.4.1 20190905 [gcc-7-branch revision 275407], clang version 7.0.1 (tags/RELEASE_701/final 349238)
55 opensuse:42.3 : Ok gcc (SUSE Linux) 4.8.5, clang version 3.8.0 (tags/RELEASE_380/final 262553)
56 opensuse:tumbleweed : Ok gcc (SUSE Linux) 9.2.1 20190903 [gcc-9-branch revision 275330], clang version 9.0.0 (tags/RELEASE_900/final 372316)
57 oraclelinux:6 : Ok gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23.0.1)
58 oraclelinux:7 : Ok gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39.0.3)
59 oraclelinux:8 : Ok gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3.0.1), clang version 7.0.1 (tags/RELEASE_701/final)
60 ubuntu:12.04 : Ok gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0)
61 ubuntu:14.04 : Ok gcc (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4
62 ubuntu:16.04 : Ok gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609, clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
63 ubuntu:16.04-x-arm : Ok arm-linux-gnueabihf-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
64 ubuntu:16.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
65 ubuntu:16.04-x-powerpc : Ok powerpc-linux-gnu-gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
66 ubuntu:16.04-x-powerpc64 : Ok powerpc64-linux-gnu-gcc (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
67 ubuntu:16.04-x-powerpc64el : Ok powerpc64le-linux-gnu-gcc (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
68 ubuntu:16.04-x-s390 : Ok s390x-linux-gnu-gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
69 ubuntu:18.04 : Ok gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0, clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
70 ubuntu:18.04-x-arm : Ok arm-linux-gnueabihf-gcc (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1) 7.4.0
71 ubuntu:18.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1) 7.4.0
72 ubuntu:18.04-x-m68k : Ok m68k-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
73 ubuntu:18.04-x-powerpc : Ok powerpc-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
74 ubuntu:18.04-x-powerpc64 : Ok powerpc64-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
75 ubuntu:18.04-x-powerpc64el : Ok powerpc64le-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
76 ubuntu:18.04-x-riscv64 : Ok riscv64-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
77 ubuntu:18.04-x-s390 : Ok s390x-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
78 ubuntu:18.04-x-sh4 : Ok sh4-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
79 ubuntu:18.04-x-sparc64 : Ok sparc64-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
80 ubuntu:18.10 : Ok gcc (Ubuntu 8.3.0-6ubuntu1~18.10.1) 8.3.0, clang version 7.0.0-3 (tags/RELEASE_700/final)
81 ubuntu:19.04 : Ok gcc (Ubuntu 8.3.0-6ubuntu1) 8.3.0, clang version 8.0.0-3 (tags/RELEASE_800/final)
82 ubuntu:19.04-x-alpha : Ok alpha-linux-gnu-gcc (Ubuntu 8.3.0-6ubuntu1) 8.3.0
83 ubuntu:19.04-x-arm64 : Ok aarch64-linux-gnu-gcc (Ubuntu/Linaro 8.3.0-6ubuntu1) 8.3.0
84 ubuntu:19.04-x-hppa : Ok hppa-linux-gnu-gcc (Ubuntu 8.3.0-6ubuntu1) 8.3.0
85 ubuntu:19.10 : Ok gcc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008, clang version 9.0.0-2 (tags/RELEASE_900/final)
#

# uname -a
Linux quaco 5.5.0-rc4+ #2 SMP Thu Jan 2 11:17:21 -03 2020 x86_64 x86_64 x86_64 GNU/Linux
# git log --oneline -1
6c4798d3f08b tools lib: Fix builds when glibc contains strlcpy()
# perf version --build-options
perf version 5.5.rc3.g6c4798d3f08b
dwarf: [ on ] # HAVE_DWARF_SUPPORT
dwarf_getlocations: [ on ] # HAVE_DWARF_GETLOCATIONS_SUPPORT
glibc: [ on ] # HAVE_GLIBC_SUPPORT
gtk2: [ on ] # HAVE_GTK2_SUPPORT
syscall_table: [ on ] # HAVE_SYSCALL_TABLE_SUPPORT
libbfd: [ on ] # HAVE_LIBBFD_SUPPORT
libelf: [ on ] # HAVE_LIBELF_SUPPORT
libnuma: [ on ] # HAVE_LIBNUMA_SUPPORT
numa_num_possible_cpus: [ on ] # HAVE_LIBNUMA_SUPPORT
libperl: [ on ] # HAVE_LIBPERL_SUPPORT
libpython: [ on ] # HAVE_LIBPYTHON_SUPPORT
libslang: [ on ] # HAVE_SLANG_SUPPORT
libcrypto: [ on ] # HAVE_LIBCRYPTO_SUPPORT
libunwind: [ on ] # HAVE_LIBUNWIND_SUPPORT
libdw-dwarf-unwind: [ on ] # HAVE_DWARF_SUPPORT
zlib: [ on ] # HAVE_ZLIB_SUPPORT
lzma: [ on ] # HAVE_LZMA_SUPPORT
get_cpuid: [ on ] # HAVE_AUXTRACE_SUPPORT
bpf: [ on ] # HAVE_LIBBPF_SUPPORT
aio: [ on ] # HAVE_AIO_SUPPORT
zstd: [ on ] # HAVE_ZSTD_SUPPORT
# perf test
1: vmlinux symtab matches kallsyms : Ok
2: Detect openat syscall event : Ok
3: Detect openat syscall event on all cpus : Ok
4: Read samples using the mmap interface : Ok
5: Test data source output : Ok
6: Parse event definition strings : Ok
7: Simple expression parser : Ok
8: PERF_RECORD_* events & perf_sample fields : Ok
9: Parse perf pmu format : Ok
10: DSO data read : Ok
11: DSO data cache : Ok
12: DSO data reopen : Ok
13: Roundtrip evsel->name : Ok
14: Parse sched tracepoints fields : Ok
15: syscalls:sys_enter_openat event fields : Ok
16: Setup struct perf_event_attr : Ok
17: Match and link multiple hists : Ok
18: 'import perf' in python : Ok
19: Breakpoint overflow signal handler : Ok
20: Breakpoint overflow sampling : Ok
21: Breakpoint accounting : Ok
22: Watchpoint :
22.1: Read Only Watchpoint : Skip
22.2: Write Only Watchpoint : Ok
22.3: Read / Write Watchpoint : Ok
22.4: Modify Watchpoint : Ok
23: Number of exit events of a simple workload : Ok
24: Software clock events period values : Ok
25: Object code reading : Ok
26: Sample parsing : Ok
27: Use a dummy software event to keep tracking : Ok
28: Parse with no sample_id_all bit set : Ok
29: Filter hist entries : Ok
30: Lookup mmap thread : Ok
31: Share thread maps : Ok
32: Sort output of hist entries : Ok
33: Cumulate child hist entries : Ok
34: Track with sched_switch : Ok
35: Filter fds with revents mask in a fdarray : Ok
36: Add fd to a fdarray, making it autogrow : Ok
37: kmod_path__parse : Ok
38: Thread map : Ok
39: LLVM search and compile :
39.1: Basic BPF llvm compile : Ok
39.2: kbuild searching : Ok
39.3: Compile source for BPF prologue generation : Ok
39.4: Compile source for BPF relocation : Ok
40: Session topology : Ok
41: BPF filter :
41.1: Basic BPF filtering : Ok
41.2: BPF pinning : Ok
41.3: BPF prologue generation : Ok
41.4: BPF relocation checker : Ok
42: Synthesize thread map : Ok
43: Remove thread map : Ok
44: Synthesize cpu map : Ok
45: Synthesize stat config : Ok
46: Synthesize stat : Ok
47: Synthesize stat round : Ok
48: Synthesize attr update : Ok
49: Event times : Ok
50: Read backward ring buffer : Ok
51: Print cpu map : Ok
52: Merge cpu map : Ok
53: Probe SDT events : Ok
54: is_printable_array : Ok
55: Print bitmap : Ok
56: perf hooks : Ok
57: builtin clang support : Skip (not compiled in)
58: unit_number__scnprintf : Ok
59: mem2node : Ok
60: time utils : Ok
61: Test jit_write_elf : Ok
62: maps__merge_in : Ok
63: x86 rdpmc : Ok
64: Convert perf time to TSC : Ok
65: DWARF unwind : Ok
66: x86 instruction decoder - new instructions : Ok
67: Intel PT packet decoder : Ok
68: x86 bp modify : Ok
69: probe libc's inet_pton & backtrace it with ping : Ok
70: Use vfs_getname probe to get syscall args filenames : Ok
71: Add vfs_getname probe to get syscall args filenames : Ok
72: Check open filename arg using perf trace + vfs_getname: Ok
73: Zstd perf.data compression/decompression : Ok

$ time make -C tools/perf build-test
make: Entering directory '/home/acme/git/perf/tools/perf'
- tarpkg: ./tests/perf-targz-src-pkg .
make_util_pmu_bison_o_O: make util/pmu-bison.o
make_minimal_O: make NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1 NO_LIBZSTD=1 NO_LIBCAP=1
make_doc_O: make doc
make_no_libbionic_O: make NO_LIBBIONIC=1
make_no_libbpf_O: make NO_LIBBPF=1
make_install_prefix_slash_O: make install prefix=/tmp/krava/
make_cscope_O: make cscope
make_clean_all_O: make clean all
make_install_bin_O: make install-bin
make_no_libpython_O: make NO_LIBPYTHON=1
make_static_O: make LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1
make_util_map_o_O: make util/map.o
make_perf_o_O: make perf.o
make_with_babeltrace_O: make LIBBABELTRACE=1
make_no_newt_O: make NO_NEWT=1
make_debug_O: make DEBUG=1
make_no_libaudit_O: make NO_LIBAUDIT=1
make_no_scripts_O: make NO_LIBPYTHON=1 NO_LIBPERL=1
make_no_backtrace_O: make NO_BACKTRACE=1
make_with_clangllvm_O: make LIBCLANGLLVM=1
make_no_libunwind_O: make NO_LIBUNWIND=1
make_install_O: make install
make_no_libdw_dwarf_unwind_O: make NO_LIBDW_DWARF_UNWIND=1
make_help_O: make help
make_no_libnuma_O: make NO_LIBNUMA=1
make_no_slang_O: make NO_SLANG=1
make_no_demangle_O: make NO_DEMANGLE=1
make_no_libperl_O: make NO_LIBPERL=1
make_no_gtk2_O: make NO_GTK2=1
make_tags_O: make tags
make_no_ui_O: make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
make_no_auxtrace_O: make NO_AUXTRACE=1
make_pure_O: make
make_no_libelf_O: make NO_LIBELF=1
make_install_prefix_O: make install prefix=/tmp/krava
OK
make: Leaving directory '/home/acme/git/perf/tools/perf'
$


2020-01-06 16:09:16

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 11/20] perf report/top: Add menu entry for toggling callchain expansion

From: Arnaldo Carvalho de Melo <[email protected]>

Since previously pressing ENTER toggled expansion/collapse of callchain
entries and now brings up the same menu used when callchains are not
present, add an entry so that users can quickly figure out the change in
behaviour.

Its worth mentioning that we also always had 'e'/'c' to expand/collapse
all entries in a hist entry and 'E'/'C' for all hist entries.

Suggested-by: Linus Torvalds <[email protected]>
Reviewed-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Jin Yao <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/browsers/hists.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index fefa505d4fa8..1b5a5990dddb 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2527,6 +2527,26 @@ add_dso_opt(struct hist_browser *browser, struct popup_action *act,
return 1;
}

+static int do_toggle_callchain(struct hist_browser *browser, struct popup_action *act __maybe_unused)
+{
+ hist_browser__toggle_fold(browser);
+ return 0;
+}
+
+static int add_callchain_toggle_opt(struct hist_browser *browser, struct popup_action *act, char **optstr)
+{
+ struct hist_entry *he = browser->he_selection;
+
+ if (!he->has_children)
+ return 0;
+
+ if (asprintf(optstr, "Expand/Collapse callchain") < 0)
+ return 0;
+
+ act->fn = do_toggle_callchain;
+ return 1;
+}
+
static int
do_browse_map(struct hist_browser *browser __maybe_unused,
struct popup_action *act)
@@ -3137,6 +3157,7 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,
&options[nr_options], thread);
nr_options += add_dso_opt(browser, &actions[nr_options],
&options[nr_options], map);
+ nr_options += add_callchain_toggle_opt(browser, &actions[nr_options], &options[nr_options]);
nr_options += add_map_opt(browser, &actions[nr_options],
&options[nr_options],
browser->selection ?
--
2.21.1

2020-01-06 16:09:23

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 14/20] perf report/top: Add 'k' hotkey to zoom directly into the kernel map

From: Arnaldo Carvalho de Melo <[email protected]>

As a convenience, equivalent to pressing Enter in a line with a kernel
symbol and then selecting "Zoom" into the kernel DSO.

Reviewed-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Jin Yao <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/browsers/hists.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 8aba1aeea0eb..6dfdd8d5a743 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -18,7 +18,9 @@
#include "../../util/evlist.h"
#include "../../util/header.h"
#include "../../util/hist.h"
+#include "../../util/machine.h"
#include "../../util/map.h"
+#include "../../util/maps.h"
#include "../../util/symbol.h"
#include "../../util/map_symbol.h"
#include "../../util/branch.h"
@@ -2566,7 +2568,7 @@ add_dso_opt(struct hist_browser *browser, struct popup_action *act,
if (!hists__has(browser->hists, dso) || map == NULL)
return 0;

- if (asprintf(optstr, "Zoom %s %s DSO",
+ if (asprintf(optstr, "Zoom %s %s DSO (use the 'k' hotkey to zoom directly into the kernel)",
browser->hists->dso_filter ? "out of" : "into",
__map__is_kernel(map) ? "the Kernel" : map->dso->short_name) < 0)
return 0;
@@ -2936,6 +2938,7 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,
"E Expand all callchains\n" \
"F Toggle percentage of filtered entries\n" \
"H Display column headers\n" \
+ "k Zoom into the kernel map\n" \
"L Change percent limit\n" \
"m Display context menu\n" \
"S Zoom into current Processor Socket\n" \
@@ -3033,6 +3036,10 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,
actions->ms.map = map;
do_zoom_dso(browser, actions);
continue;
+ case 'k':
+ if (browser->selection != NULL)
+ hists_browser__zoom_map(browser, browser->selection->maps->machine->vmlinux_map);
+ continue;
case 'V':
verbose = (verbose + 1) % 4;
browser->show_dso = verbose > 0;
--
2.21.1

2020-01-06 16:09:32

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 16/20] tools ui popup: Allow returning hotkeys

From: Arnaldo Carvalho de Melo <[email protected]>

With this patch if an optional pointer is passed to ui__popup_menu()
then when any key that is not being handled (ENTER, ESC, etc) is typed,
it'll record that key in the pointer and return, allowing for hotkey
processing on the caller.

If NULL is passed, no change in logic, unhandled keys continue to be
ignored.

Reviewed-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Jin Yao <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/browsers/hists.c | 4 ++--
tools/perf/ui/browsers/res_sample.c | 2 +-
tools/perf/ui/browsers/scripts.c | 2 +-
tools/perf/ui/tui/util.c | 12 ++++++++----
tools/perf/ui/util.h | 2 +-
5 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index ac118aef5ed1..c44b508f9e06 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2393,7 +2393,7 @@ static int switch_data_file(void)
closedir(pwd_dir);

if (nr_options) {
- choice = ui__popup_menu(nr_options, options);
+ choice = ui__popup_menu(nr_options, options, NULL);
if (choice < nr_options && choice >= 0) {
tmp = strdup(abs_path[choice]);
if (tmp) {
@@ -3279,7 +3279,7 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,
do {
struct popup_action *act;

- choice = ui__popup_menu(nr_options, options);
+ choice = ui__popup_menu(nr_options, options, NULL);
if (choice == -1 || choice >= nr_options)
break;

diff --git a/tools/perf/ui/browsers/res_sample.c b/tools/perf/ui/browsers/res_sample.c
index 76d356a18790..7cb2d6678039 100644
--- a/tools/perf/ui/browsers/res_sample.c
+++ b/tools/perf/ui/browsers/res_sample.c
@@ -56,7 +56,7 @@ int res_sample_browse(struct res_sample *res_samples, int num_res,
return -1;
}
}
- choice = ui__popup_menu(num_res, names);
+ choice = ui__popup_menu(num_res, names, NULL);
for (i = 0; i < num_res; i++)
zfree(&names[i]);
free(names);
diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c
index fc733a6354d4..47d2c7a8cbe1 100644
--- a/tools/perf/ui/browsers/scripts.c
+++ b/tools/perf/ui/browsers/scripts.c
@@ -126,7 +126,7 @@ static int list_scripts(char *script_name, bool *custom,
SCRIPT_FULLPATH_LEN);
if (num < 0)
num = 0;
- choice = ui__popup_menu(num + max_std, (char * const *)names);
+ choice = ui__popup_menu(num + max_std, (char * const *)names, NULL);
if (choice < 0) {
ret = -1;
goto out;
diff --git a/tools/perf/ui/tui/util.c b/tools/perf/ui/tui/util.c
index b98dd0e31dc1..0f562e2cb1e8 100644
--- a/tools/perf/ui/tui/util.c
+++ b/tools/perf/ui/tui/util.c
@@ -23,7 +23,7 @@ static void ui_browser__argv_write(struct ui_browser *browser,
ui_browser__write_nstring(browser, *arg, browser->width);
}

-static int popup_menu__run(struct ui_browser *menu)
+static int popup_menu__run(struct ui_browser *menu, int *keyp)
{
int key;

@@ -45,6 +45,11 @@ static int popup_menu__run(struct ui_browser *menu)
key = -1;
break;
default:
+ if (keyp) {
+ *keyp = key;
+ key = menu->nr_entries;
+ break;
+ }
continue;
}

@@ -55,7 +60,7 @@ static int popup_menu__run(struct ui_browser *menu)
return key;
}

-int ui__popup_menu(int argc, char * const argv[])
+int ui__popup_menu(int argc, char * const argv[], int *keyp)
{
struct ui_browser menu = {
.entries = (void *)argv,
@@ -64,8 +69,7 @@ int ui__popup_menu(int argc, char * const argv[])
.write = ui_browser__argv_write,
.nr_entries = argc,
};
-
- return popup_menu__run(&menu);
+ return popup_menu__run(&menu, keyp);
}

int ui_browser__input_window(const char *title, const char *text, char *input,
diff --git a/tools/perf/ui/util.h b/tools/perf/ui/util.h
index 40891942f465..e30cea807564 100644
--- a/tools/perf/ui/util.h
+++ b/tools/perf/ui/util.h
@@ -5,7 +5,7 @@
#include <stdarg.h>

int ui__getch(int delay_secs);
-int ui__popup_menu(int argc, char * const argv[]);
+int ui__popup_menu(int argc, char * const argv[], int *keyp);
int ui__help_window(const char *text);
int ui__dialog_yesno(const char *msg);
void __ui__info_window(const char *title, const char *text, const char *exit_msg);
--
2.21.1

2020-01-06 16:09:34

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 17/20] perf report/top: Allow pressing hotkeys in the options popup menu

From: Arnaldo Carvalho de Melo <[email protected]>

When the users presses ENTER in the main 'perf report/top' screen a
popup menu is presented, in it some hotkeys are suggested as
alternatives to using the menu, or for additional features.

At that point the user may try those hotkeys, so allow for that by
recording the key used and exiting, the caller then can check for that
possibility and process the hotkey.

I.e. try pressing ENTER, and then 'k' to exit and zoom into the kernel
map, using ESC then zooms out, etc.

Reviewed-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Jin Yao <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/browsers/hists.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index c44b508f9e06..8776b1cb29b7 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2995,12 +2995,13 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,
while (1) {
struct thread *thread = NULL;
struct map *map = NULL;
- int choice = 0;
+ int choice;
int socked_id = -1;

- nr_options = 0;
-
- key = hist_browser__run(browser, helpline, warn_lost_event, 0);
+ key = 0; // reset key
+do_hotkey: // key came straight from options ui__popup_menu()
+ choice = nr_options = 0;
+ key = hist_browser__run(browser, helpline, warn_lost_event, key);

if (browser->he_selection != NULL) {
thread = hist_browser__selected_thread(browser);
@@ -3279,10 +3280,13 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,
do {
struct popup_action *act;

- choice = ui__popup_menu(nr_options, options, NULL);
- if (choice == -1 || choice >= nr_options)
+ choice = ui__popup_menu(nr_options, options, &key);
+ if (choice == -1)
break;

+ if (choice == nr_options)
+ goto do_hotkey;
+
act = &actions[choice];
key = act->fn(browser, act);
} while (key == 1);
--
2.21.1

2020-01-06 16:10:00

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 09/20] perf hists browser: Restore ESC as "Zoom out" of DSO/thread/etc

From: Arnaldo Carvalho de Melo <[email protected]>

We need to set actions->ms.map since 599a2f38a989 ("perf hists browser:
Check sort keys before hot key actions"), as in that patch we bail out
if map is NULL.

Reviewed-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Namhyung Kim <[email protected]>
Fixes: 599a2f38a989 ("perf hists browser: Check sort keys before hot key actions")
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/browsers/hists.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index d4d3558fdef4..cfc6172ecab7 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -3062,6 +3062,7 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,

continue;
}
+ actions->ms.map = map;
top = pstack__peek(browser->pstack);
if (top == &browser->hists->dso_filter) {
/*
--
2.21.1

2020-01-06 16:10:01

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 12/20] perf report/top: Improve toggle callchain menu option

From: Arnaldo Carvalho de Melo <[email protected]>

Taking into account the current status of the callchain, i.e. if folded,
show "Expand", otherwise "Collapse", also show the name of the entry
that will be affected and mention the hotkeys for expanding/collapsing
all callchains below the main entry, the one that appears with/without
callchains.

Reviewed-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Jin Yao <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/browsers/hists.c | 54 ++++++++++++++++++++++++++++++++--
tools/perf/util/sort.c | 3 +-
tools/perf/util/sort.h | 2 ++
3 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 1b5a5990dddb..a4413d983216 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -391,6 +391,52 @@ static void hist_entry__init_have_children(struct hist_entry *he)
he->init_have_children = true;
}

+static bool hist_browser__selection_has_children(struct hist_browser *browser)
+{
+ struct hist_entry *he = browser->he_selection;
+ struct map_symbol *ms = browser->selection;
+
+ if (!he || !ms)
+ return false;
+
+ if (ms == &he->ms)
+ return he->has_children;
+
+ return container_of(ms, struct callchain_list, ms)->has_children;
+}
+
+static bool hist_browser__selection_unfolded(struct hist_browser *browser)
+{
+ struct hist_entry *he = browser->he_selection;
+ struct map_symbol *ms = browser->selection;
+
+ if (!he || !ms)
+ return false;
+
+ if (ms == &he->ms)
+ return he->unfolded;
+
+ return container_of(ms, struct callchain_list, ms)->unfolded;
+}
+
+static char *hist_browser__selection_sym_name(struct hist_browser *browser, char *bf, size_t size)
+{
+ struct hist_entry *he = browser->he_selection;
+ struct map_symbol *ms = browser->selection;
+ struct callchain_list *callchain_entry;
+
+ if (!he || !ms)
+ return NULL;
+
+ if (ms == &he->ms) {
+ hist_entry__sym_snprintf(he, bf, size, 0);
+ return bf + 4; // skip the level, e.g. '[k] '
+ }
+
+ callchain_entry = container_of(ms, struct callchain_list, ms);
+ return callchain_list__sym_name(callchain_entry, bf, size, browser->show_dso);
+}
+
static bool hist_browser__toggle_fold(struct hist_browser *browser)
{
struct hist_entry *he = browser->he_selection;
@@ -2535,12 +2581,14 @@ static int do_toggle_callchain(struct hist_browser *browser, struct popup_action

static int add_callchain_toggle_opt(struct hist_browser *browser, struct popup_action *act, char **optstr)
{
- struct hist_entry *he = browser->he_selection;
+ char sym_name[512];

- if (!he->has_children)
+ if (!hist_browser__selection_has_children(browser))
return 0;

- if (asprintf(optstr, "Expand/Collapse callchain") < 0)
+ if (asprintf(optstr, "%s [%s] callchain (one level, same as '+' hotkey, use 'e'/'c' for the whole main level entry)",
+ hist_browser__selection_unfolded(browser) ? "Collapse" : "Expand",
+ hist_browser__selection_sym_name(browser, sym_name, sizeof(sym_name))) < 0)
return 0;

act->fn = do_toggle_callchain;
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 9fcba2872130..ab0cfd790ad0 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -324,8 +324,7 @@ static int _hist_entry__sym_snprintf(struct map_symbol *ms,
return ret;
}

-static int hist_entry__sym_snprintf(struct hist_entry *he, char *bf,
- size_t size, unsigned int width)
+int hist_entry__sym_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width)
{
return _hist_entry__sym_snprintf(&he->ms, he->ip,
he->level, bf, size, width);
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h
index 5aff9542d9b7..6c862d62d052 100644
--- a/tools/perf/util/sort.h
+++ b/tools/perf/util/sort.h
@@ -164,6 +164,8 @@ static __pure inline bool hist_entry__has_callchains(struct hist_entry *he)
return he->callchain_size != 0;
}

+int hist_entry__sym_snprintf(struct hist_entry *he, char *bf, size_t size, unsigned int width);
+
static inline bool hist_entry__has_pairs(struct hist_entry *he)
{
return !list_empty(&he->pairs.node);
--
2.21.1

2020-01-06 16:10:02

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 20/20] tools lib: Fix builds when glibc contains strlcpy()

From: Vitaly Chikunov <[email protected]>

Disable a couple of compilation warnings (which are treated as errors)
on strlcpy() definition and declaration, allowing users to compile perf
and kernel (objtool) when:

1. glibc have strlcpy() (such as in ALT Linux since 2004) objtool and
perf build fails with this (in gcc):

In file included from exec-cmd.c:3:
tools/include/linux/string.h:20:15: error: redundant redeclaration of ‘strlcpy’ [-Werror=redundant-decls]
20 | extern size_t strlcpy(char *dest, const char *src, size_t size);

2. clang ignores `-Wredundant-decls', but produces another warning when
building perf:

CC util/string.o
../lib/string.c:99:8: error: attribute declaration must precede definition [-Werror,-Wignored-attributes]
size_t __weak strlcpy(char *dest, const char *src, size_t size)
../../tools/include/linux/compiler.h:66:34: note: expanded from macro '__weak'
# define __weak __attribute__((weak))
/usr/include/bits/string_fortified.h:151:8: note: previous definition is here
__NTH (strlcpy (char *__restrict __dest, const char *__restrict __src,

Committer notes:

The

#pragma GCC diagnostic

directive was introduced in gcc 4.6, so check for that as well.

Fixes: ce99091 ("perf tools: Move strlcpy() from perf to tools/lib/string.c")
Fixes: 0215d59 ("tools lib: Reinstate strlcpy() header guard with __UCLIBC__")
Resolves: https://bugzilla.kernel.org/show_bug.cgi?id=118481
Signed-off-by: Vitaly Chikunov <[email protected]>
Reviewed-by: Dmitry Levin <[email protected]>
Cc: Dmitry Levin <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: kbuild test robot <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: [email protected]
Cc: Vineet Gupta <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/include/linux/string.h | 8 ++++++++
tools/lib/string.c | 7 +++++++
2 files changed, 15 insertions(+)

diff --git a/tools/include/linux/string.h b/tools/include/linux/string.h
index 980cb9266718..5e9e781905ed 100644
--- a/tools/include/linux/string.h
+++ b/tools/include/linux/string.h
@@ -17,7 +17,15 @@ int strtobool(const char *s, bool *res);
* However uClibc headers also define __GLIBC__ hence the hack below
*/
#if defined(__GLIBC__) && !defined(__UCLIBC__)
+// pragma diagnostic was introduced in gcc 4.6
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wredundant-decls"
+#endif
extern size_t strlcpy(char *dest, const char *src, size_t size);
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#pragma GCC diagnostic pop
+#endif
#endif

char *str_error_r(int errnum, char *buf, size_t buflen);
diff --git a/tools/lib/string.c b/tools/lib/string.c
index f2ae1b87c719..f645343815de 100644
--- a/tools/lib/string.c
+++ b/tools/lib/string.c
@@ -96,6 +96,10 @@ int strtobool(const char *s, bool *res)
* If libc has strlcpy() then that version will override this
* implementation:
*/
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wignored-attributes"
+#endif
size_t __weak strlcpy(char *dest, const char *src, size_t size)
{
size_t ret = strlen(src);
@@ -107,6 +111,9 @@ size_t __weak strlcpy(char *dest, const char *src, size_t size)
}
return ret;
}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif

/**
* skip_spaces - Removes leading whitespace from @str.
--
2.21.1

2020-01-06 16:10:20

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 13/20] perf hists browser: Generalize the do_zoom_dso() function

From: Arnaldo Carvalho de Melo <[email protected]>

We'll use it to provide a top level hotkey to zoom into the kernel dso
directly.

Reviewed-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Jin Yao <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/browsers/hists.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index a4413d983216..8aba1aeea0eb 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2530,11 +2530,8 @@ add_thread_opt(struct hist_browser *browser, struct popup_action *act,
return 1;
}

-static int
-do_zoom_dso(struct hist_browser *browser, struct popup_action *act)
+static int hists_browser__zoom_map(struct hist_browser *browser, struct map *map)
{
- struct map *map = act->ms.map;
-
if (!hists__has(browser->hists, dso) || map == NULL)
return 0;

@@ -2556,6 +2553,12 @@ do_zoom_dso(struct hist_browser *browser, struct popup_action *act)
return 0;
}

+static int
+do_zoom_dso(struct hist_browser *browser, struct popup_action *act)
+{
+ return hists_browser__zoom_map(browser, act->ms.map);
+}
+
static int
add_dso_opt(struct hist_browser *browser, struct popup_action *act,
char **optstr, struct map *map)
--
2.21.1

2020-01-06 16:10:30

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 15/20] perf hists browser: Allow passing an initial hotkey

From: Arnaldo Carvalho de Melo <[email protected]>

Sometimes we're in an outer code, like the main hists browser popup menu
and the user follows a suggestion about using some hotkey, and that
hotkey is really handled by hists_browser__run(), so allow for calling
it with that hotkey, making it handle it instead of waiting for the user
to press one.

Reviewed-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Jin Yao <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/builtin-c2c.c | 4 +-
tools/perf/ui/browsers/hists.c | 153 +++++++++++++++++----------------
tools/perf/ui/browsers/hists.h | 2 +-
3 files changed, 82 insertions(+), 77 deletions(-)

diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index e69f44941aad..346351260c0b 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -2384,7 +2384,7 @@ static int perf_c2c__browse_cacheline(struct hist_entry *he)
c2c_browser__update_nr_entries(browser);

while (1) {
- key = hist_browser__run(browser, "? - help", true);
+ key = hist_browser__run(browser, "? - help", true, 0);

switch (key) {
case 's':
@@ -2453,7 +2453,7 @@ static int perf_c2c__hists_browse(struct hists *hists)
c2c_browser__update_nr_entries(browser);

while (1) {
- key = hist_browser__run(browser, "? - help", true);
+ key = hist_browser__run(browser, "? - help", true, 0);

switch (key) {
case 'q':
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 6dfdd8d5a743..ac118aef5ed1 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -672,10 +672,81 @@ static int hist_browser__title(struct hist_browser *browser, char *bf, size_t si
return browser->title ? browser->title(browser, bf, size) : 0;
}

+static int hist_browser__handle_hotkey(struct hist_browser *browser, bool warn_lost_event, char *title, int key)
+{
+ switch (key) {
+ case K_TIMER: {
+ struct hist_browser_timer *hbt = browser->hbt;
+ u64 nr_entries;
+
+ WARN_ON_ONCE(!hbt);
+
+ if (hbt)
+ hbt->timer(hbt->arg);
+
+ if (hist_browser__has_filter(browser) || symbol_conf.report_hierarchy)
+ hist_browser__update_nr_entries(browser);
+
+ nr_entries = hist_browser__nr_entries(browser);
+ ui_browser__update_nr_entries(&browser->b, nr_entries);
+
+ if (warn_lost_event &&
+ (browser->hists->stats.nr_lost_warned !=
+ browser->hists->stats.nr_events[PERF_RECORD_LOST])) {
+ browser->hists->stats.nr_lost_warned =
+ browser->hists->stats.nr_events[PERF_RECORD_LOST];
+ ui_browser__warn_lost_events(&browser->b);
+ }
+
+ hist_browser__title(browser, title, sizeof(title));
+ ui_browser__show_title(&browser->b, title);
+ break;
+ }
+ case 'D': { /* Debug */
+ struct hist_entry *h = rb_entry(browser->b.top, struct hist_entry, rb_node);
+ static int seq;
+
+ ui_helpline__pop();
+ ui_helpline__fpush("%d: nr_ent=(%d,%d), etl: %d, rows=%d, idx=%d, fve: idx=%d, row_off=%d, nrows=%d",
+ seq++, browser->b.nr_entries, browser->hists->nr_entries,
+ browser->b.extra_title_lines, browser->b.rows,
+ browser->b.index, browser->b.top_idx, h->row_offset, h->nr_rows);
+ }
+ break;
+ case 'C':
+ /* Collapse the whole world. */
+ hist_browser__set_folding(browser, false);
+ break;
+ case 'c':
+ /* Collapse the selected entry. */
+ hist_browser__set_folding_selected(browser, false);
+ break;
+ case 'E':
+ /* Expand the whole world. */
+ hist_browser__set_folding(browser, true);
+ break;
+ case 'e':
+ /* Expand the selected entry. */
+ hist_browser__set_folding_selected(browser, true);
+ break;
+ case 'H':
+ browser->show_headers = !browser->show_headers;
+ hist_browser__update_rows(browser);
+ break;
+ case '+':
+ if (hist_browser__toggle_fold(browser))
+ break;
+ /* fall thru */
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
int hist_browser__run(struct hist_browser *browser, const char *help,
- bool warn_lost_event)
+ bool warn_lost_event, int key)
{
- int key;
char title[160];
struct hist_browser_timer *hbt = browser->hbt;
int delay_secs = hbt ? hbt->refresh : 0;
@@ -688,79 +759,14 @@ int hist_browser__run(struct hist_browser *browser, const char *help,
if (ui_browser__show(&browser->b, title, "%s", help) < 0)
return -1;

+ if (key && hist_browser__handle_hotkey(browser, warn_lost_event, title, key))
+ goto out;
+
while (1) {
key = ui_browser__run(&browser->b, delay_secs);

- switch (key) {
- case K_TIMER: {
- u64 nr_entries;
-
- WARN_ON_ONCE(!hbt);
-
- if (hbt)
- hbt->timer(hbt->arg);
-
- if (hist_browser__has_filter(browser) ||
- symbol_conf.report_hierarchy)
- hist_browser__update_nr_entries(browser);
-
- nr_entries = hist_browser__nr_entries(browser);
- ui_browser__update_nr_entries(&browser->b, nr_entries);
-
- if (warn_lost_event &&
- (browser->hists->stats.nr_lost_warned !=
- browser->hists->stats.nr_events[PERF_RECORD_LOST])) {
- browser->hists->stats.nr_lost_warned =
- browser->hists->stats.nr_events[PERF_RECORD_LOST];
- ui_browser__warn_lost_events(&browser->b);
- }
-
- hist_browser__title(browser, title, sizeof(title));
- ui_browser__show_title(&browser->b, title);
- continue;
- }
- case 'D': { /* Debug */
- static int seq;
- struct hist_entry *h = rb_entry(browser->b.top,
- struct hist_entry, rb_node);
- ui_helpline__pop();
- ui_helpline__fpush("%d: nr_ent=(%d,%d), etl: %d, rows=%d, idx=%d, fve: idx=%d, row_off=%d, nrows=%d",
- seq++, browser->b.nr_entries,
- browser->hists->nr_entries,
- browser->b.extra_title_lines,
- browser->b.rows,
- browser->b.index,
- browser->b.top_idx,
- h->row_offset, h->nr_rows);
- }
- break;
- case 'C':
- /* Collapse the whole world. */
- hist_browser__set_folding(browser, false);
- break;
- case 'c':
- /* Collapse the selected entry. */
- hist_browser__set_folding_selected(browser, false);
- break;
- case 'E':
- /* Expand the whole world. */
- hist_browser__set_folding(browser, true);
+ if (hist_browser__handle_hotkey(browser, warn_lost_event, title, key))
break;
- case 'e':
- /* Expand the selected entry. */
- hist_browser__set_folding_selected(browser, true);
- break;
- case 'H':
- browser->show_headers = !browser->show_headers;
- hist_browser__update_rows(browser);
- break;
- case '+':
- if (hist_browser__toggle_fold(browser))
- break;
- /* fall thru */
- default:
- goto out;
- }
}
out:
ui_browser__hide(&browser->b);
@@ -2994,8 +3000,7 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,

nr_options = 0;

- key = hist_browser__run(browser, helpline,
- warn_lost_event);
+ key = hist_browser__run(browser, helpline, warn_lost_event, 0);

if (browser->he_selection != NULL) {
thread = hist_browser__selected_thread(browser);
@@ -3573,7 +3578,7 @@ int block_hists_tui_browse(struct block_hist *bh, struct evsel *evsel,
memset(&action, 0, sizeof(action));

while (1) {
- key = hist_browser__run(browser, "? - help", true);
+ key = hist_browser__run(browser, "? - help", true, 0);

switch (key) {
case 'q':
diff --git a/tools/perf/ui/browsers/hists.h b/tools/perf/ui/browsers/hists.h
index 078f2f2c7abd..1e938d9ffa5e 100644
--- a/tools/perf/ui/browsers/hists.h
+++ b/tools/perf/ui/browsers/hists.h
@@ -34,7 +34,7 @@ struct hist_browser {
struct hist_browser *hist_browser__new(struct hists *hists);
void hist_browser__delete(struct hist_browser *browser);
int hist_browser__run(struct hist_browser *browser, const char *help,
- bool warn_lost_event);
+ bool warn_lost_event, int key);
void hist_browser__init(struct hist_browser *browser,
struct hists *hists);
#endif /* _PERF_UI_BROWSER_HISTS_H_ */
--
2.21.1

2020-01-06 16:10:39

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 19/20] perf report/top: Make 'e' visible in the help and make it toggle showing callchains

From: Arnaldo Carvalho de Melo <[email protected]>

The 'e' and 'c' hotkeys were present for a long time, but not documented
in the help window, change 'e' to be a toggle so that it gets consistent
with other toggles like '+' and document it in the help window.

Keep 'c' as is for people used to it but don't document, as it is easier
to just use 'e' to show/hide all the callchains for a top level
histogram entry.

Reviewed-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Jin Yao <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/browsers/hists.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 3bec8de89880..f36dee499320 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -407,6 +407,11 @@ static bool hist_browser__selection_has_children(struct hist_browser *browser)
return container_of(ms, struct callchain_list, ms)->has_children;
}

+static bool hist_browser__he_selection_unfolded(struct hist_browser *browser)
+{
+ return browser->he_selection ? browser->he_selection->unfolded : false;
+}
+
static bool hist_browser__selection_unfolded(struct hist_browser *browser)
{
struct hist_entry *he = browser->he_selection;
@@ -727,7 +732,7 @@ static int hist_browser__handle_hotkey(struct hist_browser *browser, bool warn_l
break;
case 'e':
/* Expand the selected entry. */
- hist_browser__set_folding_selected(browser, true);
+ hist_browser__set_folding_selected(browser, !hist_browser__he_selection_unfolded(browser));
break;
case 'H':
browser->show_headers = !browser->show_headers;
@@ -2942,6 +2947,7 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,
"a Annotate current symbol\n" \
"C Collapse all callchains\n" \
"d Zoom into current DSO\n" \
+ "e Expand/Collapse main entry callchains\n" \
"E Expand all callchains\n" \
"F Toggle percentage of filtered entries\n" \
"H Display column headers\n" \
--
2.21.1

2020-01-06 16:10:40

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 18/20] perf report/top: Do not offer annotation for symbols without samples

From: Arnaldo Carvalho de Melo <[email protected]>

This can happen in the --children mode, i.e. the default mode when
callchains are present, where one of the main entries may be a callchain
entry with no samples.

So far we were not providing any information about why an annotation
couldn't be provided even offering the Annotation option in the popup
menu.

Work is needed to allow for no-samples "annotation', i.e. to show the
disassembly anyway and allow for navigation, etc.

Reviewed-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Jin Yao <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/browsers/hists.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 8776b1cb29b7..3bec8de89880 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -2465,7 +2465,8 @@ add_annotate_opt(struct hist_browser *browser __maybe_unused,
struct popup_action *act, char **optstr,
struct map_symbol *ms)
{
- if (ms->sym == NULL || ms->map->dso->annotate_warned)
+ if (ms->sym == NULL || ms->map->dso->annotate_warned ||
+ symbol__annotation(ms->sym)->src == NULL)
return 0;

if (asprintf(optstr, "Annotate %s", ms->sym->name) < 0)
@@ -3031,6 +3032,14 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,
browser->selection->map->dso->annotate_warned)
continue;

+ if (symbol__annotation(browser->selection->sym)->src == NULL) {
+ ui_browser__warning(&browser->b, delay_secs * 2,
+ "No samples for the \"%s\" symbol.\n\n"
+ "Probably appeared just in a callchain",
+ browser->selection->sym->name);
+ continue;
+ }
+
actions->ms.map = browser->selection->map;
actions->ms.sym = browser->selection->sym;
do_annotate(browser, actions);
--
2.21.1

2020-01-06 16:10:59

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 10/20] perf report/top: Make ENTER consistently bring up menu

From: Arnaldo Carvalho de Melo <[email protected]>

When callchains are present the ENTER key switches from bringing up the
menu that offers Annotation, Zoom by DSO, etc to expanding/collapsing
one callchain level, causing confusion, fix it by making it consistently
bring up the menu and use '+' to expand/collapse one callchain level.

Next patch will also add an entry to the menu to allow
expanding/collapsing, so that people used to ENTER expanding one
callchain level can quickly find it and use it instead.

Reported-by: Linus Torvalds <[email protected]>
Reviewed-by: Jiri Olsa <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Jin Yao <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/ui/browsers/hists.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index cfc6172ecab7..fefa505d4fa8 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -706,7 +706,7 @@ int hist_browser__run(struct hist_browser *browser, const char *help,
browser->show_headers = !browser->show_headers;
hist_browser__update_rows(browser);
break;
- case K_ENTER:
+ case '+':
if (hist_browser__toggle_fold(browser))
break;
/* fall thru */
@@ -2858,6 +2858,7 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,
"For symbolic views (--sort has sym):\n\n" \
"ENTER Zoom into DSO/Threads & Annotate current symbol\n" \
"ESC Zoom out\n" \
+ "+ Expand/Collapse one callchain level\n" \
"a Annotate current symbol\n" \
"C Collapse all callchains\n" \
"d Zoom into current DSO\n" \
--
2.21.1

2020-01-06 17:04:46

by David Laight

[permalink] [raw]
Subject: RE: [PATCH 20/20] tools lib: Fix builds when glibc contains strlcpy()

From: Arnaldo Carvalho de Melo
> Sent: 06 January 2020 16:07
>
> From: Vitaly Chikunov <[email protected]>
>
> Disable a couple of compilation warnings (which are treated as errors)
> on strlcpy() definition and declaration, allowing users to compile perf
> and kernel (objtool) when:
>
> 1. glibc have strlcpy() (such as in ALT Linux since 2004) objtool and
> perf build fails with this (in gcc):
>
> In file included from exec-cmd.c:3:
> tools/include/linux/string.h:20:15: error: redundant redeclaration of ‘strlcpy’ [-Werror=redundant-decls]
> 20 | extern size_t strlcpy(char *dest, const char *src, size_t size);
>
> 2. clang ignores `-Wredundant-decls', but produces another warning when
> building perf:
>
> CC util/string.o
> ../lib/string.c:99:8: error: attribute declaration must precede definition [-Werror,-Wignored-attributes]
> size_t __weak strlcpy(char *dest, const char *src, size_t size)
> ../../tools/include/linux/compiler.h:66:34: note: expanded from macro '__weak'
> # define __weak __attribute__((weak))
> /usr/include/bits/string_fortified.h:151:8: note: previous definition is here
> __NTH (strlcpy (char *__restrict __dest, const char *__restrict __src,

Why not just always use the local version by renaming it?

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

2020-01-07 20:49:37

by Vitaly Chikunov

[permalink] [raw]
Subject: Re: [PATCH 20/20] tools lib: Fix builds when glibc contains strlcpy()

David,

On Mon, Jan 06, 2020 at 05:03:26PM +0000, David Laight wrote:
> From: Arnaldo Carvalho de Melo
> > Sent: 06 January 2020 16:07
> >
> > From: Vitaly Chikunov <[email protected]>
> >
> > Disable a couple of compilation warnings (which are treated as errors)
> > on strlcpy() definition and declaration, allowing users to compile perf
> > and kernel (objtool) when:
> >
> > 1. glibc have strlcpy() (such as in ALT Linux since 2004) objtool and
> > perf build fails with this (in gcc):
> >
> > In file included from exec-cmd.c:3:
> > tools/include/linux/string.h:20:15: error: redundant redeclaration of ‘strlcpy’ [-Werror=redundant-decls]
> > 20 | extern size_t strlcpy(char *dest, const char *src, size_t size);
> >
> > 2. clang ignores `-Wredundant-decls', but produces another warning when
> > building perf:
> >
> > CC util/string.o
> > ../lib/string.c:99:8: error: attribute declaration must precede definition [-Werror,-Wignored-attributes]
> > size_t __weak strlcpy(char *dest, const char *src, size_t size)
> > ../../tools/include/linux/compiler.h:66:34: note: expanded from macro '__weak'
> > # define __weak __attribute__((weak))
> > /usr/include/bits/string_fortified.h:151:8: note: previous definition is here
> > __NTH (strlcpy (char *__restrict __dest, const char *__restrict __src,
>
> Why not just always use the local version by renaming it?

I believe that was the initial approach, which is changed some time ago
to using weak linking. Also, Dmitry Levin (as one of glibc maintainers)
claims that glibc implementation of strlcpy() is more correct and thus
better.

Thanks,

>
> David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)

2020-01-10 17:53:08

by Ingo Molnar

[permalink] [raw]
Subject: Re: [GIT PULL] perf/core improvements and fixes


* Arnaldo Carvalho de Melo <[email protected]> wrote:

> Hi Ingo/Thomas,
>
> Please consider pulling,
>
> Best regards,
>
> - Arnaldo
>
> Test results at the end of this message, as usual.
>
> The following changes since commit b9fb2de0115bbacab36da31fd10483ea66d9cfab:
>
> Merge tag 'perf-urgent-for-mingo-5.5-20191223' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent (2019-12-23 22:27:44 +0100)
>
> are available in the Git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-5.6-20200106
>
> for you to fetch changes up to 6c4798d3f08b81c2c52936b10e0fa872590c96ae:
>
> tools lib: Fix builds when glibc contains strlcpy() (2020-01-06 11:46:10 -0300)
>
> ----------------------------------------------------------------
> perf/core improvements and fixes.
>
> perf record:
>
> Alexey Budankov:
>
> - Adapt affinity for machines with #CPUs > 1K to overcome current 1024 CPUs
> mask size limitation of cpu_set_t type.
>
> perf report/top TUI:
>
> Arnaldo Carvalho de Melo:
>
> - Make ENTER consistently present the pop up menu with and without call
> chains, to eliminate confusion. The menu continues available at all times
> use 'm' and '+' can be used to toggle just one call chain level, 'e' for all
> the call chains for a top level histogram entry and 'E' to expand all call
> chains in all top level entries. Extra info about these options was added to
> the pop up menu entries. Pressing 'k' serves as special hotkey to go straight
> to the main vmlinux entries, to avoid having to press enter and then select
> "Zoom into the kernel DSO".
>
> perf sched timehist:
>
> David Ahern:
>
> - Add support for filtering on CPU.
>
> perf tests:
>
> Arnaldo Carvalho de Melo:
>
> - Show expected versus obtained values in bp_signal test.
>
> libperf:
>
> Jiri Olsa:
>
> - Move to tools/lib/perf.
>
> - Add man pages.
>
> libapi:
>
> Andrey Zhizhikin:
>
> - Fix gcc9 stringop-truncation compilation error.
>
> tools lib:
>
> Vitaly Chikunov:
>
> - Fix builds when glibc contains strlcpy(), which is the case for ALT Linux.
>
> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
>
> ----------------------------------------------------------------
> Alexey Budankov (3):
> tools bitmap: Implement bitmap_equal() operation at bitmap API
> perf mmap: Declare type for cpu mask of arbitrary length
> perf record: Adapt affinity to machines with #CPUs > 1K
>
> Andrey Zhizhikin (1):
> tools lib api fs: Fix gcc9 stringop-truncation compilation error
>
> Arnaldo Carvalho de Melo (12):
> perf tests bp_signal: Show expected versus obtained values
> perf hists browser: Restore ESC as "Zoom out" of DSO/thread/etc
> perf report/top: Make ENTER consistently bring up menu
> perf report/top: Add menu entry for toggling callchain expansion
> perf report/top: Improve toggle callchain menu option
> perf hists browser: Generalize the do_zoom_dso() function
> perf report/top: Add 'k' hotkey to zoom directly into the kernel map
> perf hists browser: Allow passing an initial hotkey
> tools ui popup: Allow returning hotkeys
> perf report/top: Allow pressing hotkeys in the options popup menu
> perf report/top: Do not offer annotation for symbols without samples
> perf report/top: Make 'e' visible in the help and make it toggle showing callchains
>
> David Ahern (1):
> perf sched timehist: Add support for filtering on CPU
>
> Jiri Olsa (2):
> libperf: Move to tools/lib/perf
> libperf: Add man pages
>
> Vitaly Chikunov (1):
> tools lib: Fix builds when glibc contains strlcpy()

> 70 files changed, 1565 insertions(+), 352 deletions(-)

Pulled, thanks a lot Arnaldo!

Ingo

2020-01-28 19:11:16

by pr-tracker-bot

[permalink] [raw]
Subject: Re: [GIT PULL] perf/core improvements and fixes

The pull request you sent on Mon, 6 Jan 2020 13:06:45 -0300:

> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-5.6-20200106

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/53f3feeb7bd2d78039b3dc9ab158bad2a5dbe012

Thank you!

--
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker