perf/core improvements and fixes
Subsystems (3)
Arnaldo Carvalho de Melo
maintainerHi Ingo/Thomas,
Please consider pulling,
Best regards,
- Arnaldo
Test results at the end of this message, as usual.
The following changes since commit 3442a9ecb8e72a33c28a2b969b766c659830e410:
perf/x86/intel/uncore: Factor out __snr_uncore_mmio_init_box (2020-03-20 13:06:23 +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.7-20200325
for you to fetch changes up to 0d33b34352531ff7029c58eda2321340c0ea3f5f:
perf dso: Fix dso comparison (2020-03-24 10:57:38 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:
perf report/top:
Jin Yao:
- Support annotation of unresolved symbols, just using its addresses.
- Print addr_location.al_addr when finding a map but not a symbol, so that we have the address relative to the map which is what objdump produces, then we can match the output of perf and objdump for such unresolved addresses.
- Allow sorting by non-group leaders when working with multiple events, be it in a explicit group, i.e. an event list surrounded by {} (e.g. 'perf record -e '{cycles,instructions,cache-misses}', or without, using --group in 'perf report', e.g.:
perf record -e cycles,instructions,cache-misses perf report --group --group-sort-idx 1
That '1' will ask for the output to be sorted by 'instructions', not the default 'cycles'.
- Add hotkeys to interactively resort the output when using multiple events, '0', '1', ... '9' to resort by the nth event, just like when using --group-sort-idx, as explained above.
perf stat:
Jin Yao:
- Align the output for interval aggregation mode.
event parsing:
Ian Rogers:
- Fix 3 use after frees found with clang ASAN.
perf tools:
Jiri Olsa:
- Unify a bit the build directory output.
perf tests:
John Garry:
- Add PMU events tests, checking that JSON files are properly parsed.
perf stat:
Kajol Jain:
- Fix printing event names of metric group with multiple events incase of overlapping events.
perf symbols:
Leo Yan:
- Consolidate symbol fixup issue.
vendor events AMD:
Vijay Thakkar:
- Restrict model detection for zen1 based processors
- Add Zen2 events.
- Update Zen1 events to V2.
perf cpumap:
Christophe JAILLET:
- Fix snprintf overflow check
DSOs:
Ravi Bangoria:
- Fix dso comparison wrt IDs (maj, min, etc), that had made 'perf archive' stop working when build-ids were not being collected.
----------------------------------------------------------------
Arnaldo Carvalho de Melo (1):
tools headers uapi: Update linux/in.h copy
Christophe JAILLET (1):
perf cpumap: Fix snprintf overflow check
Ian Rogers (1):
perf parse-events: Fix 3 use after frees found with clang ASAN
Jin Yao (7):
perf report: Print al_addr when symbol is not found
perf report: Support interactive annotation of code without symbols perf report/top TUI: Support hotkey 'a' for annotation of unresolved addresses perf report: Allow specifying event to be used as sort key in --group output perf report: Support a new key to reload the browser
perf report/top TUI: Support hotkeys to let user select any event for sorting perf stat: Align the output for interval aggregation mode
Jiri Olsa (1):
perf tools: Unify a bit the build directory output
John Garry (7):
perf jevents: Add some test events perf jevents: Support test events folder perf pmu: Refactor pmu_add_cpu_aliases() perf test: Add pmu-events test
perf pmu: Add is_pmu_core()
perf pmu: Make pmu_uncore_alias_match() public perf test: Test pmu-events aliases
Kajol Jain (1):
perf metricgroup: Fix printing event names of metric group with multiple events incase of overlapping events
Leo Yan (1):
perf symbols: Consolidate symbol fixup issue
Ravi Bangoria (1):
perf dso: Fix dso comparison
Vijay Thakkar (3):
perf vendor events amd: Restrict model detection for zen1 based processors perf vendor events amd: Add Zen2 events
perf vendor events amd: Update Zen1 events to V2
tools/include/uapi/linux/in.h | 2 +
tools/perf/Documentation/perf-report.txt | 5 +
tools/perf/Makefile.perf | 9 +-
tools/perf/arch/arm64/util/Build | 1 -
tools/perf/arch/arm64/util/sym-handling.c | 19 --
tools/perf/arch/powerpc/util/Build | 1 -
tools/perf/arch/powerpc/util/sym-handling.c | 10 -
tools/perf/builtin-report.c | 16 +-
.../{x86/amdfam17h => test/test_cpu}/branch.json | 0
.../perf/pmu-events/arch/test/test_cpu/other.json | 26 ++
.../perf/pmu-events/arch/test/test_cpu/uncore.json | 21 ++
.../perf/pmu-events/arch/x86/amdfam17h/cache.json | 329 ------------------
.../perf/pmu-events/arch/x86/amdfam17h/other.json | 65 ----
tools/perf/pmu-events/arch/x86/amdzen1/branch.json | 23 ++
tools/perf/pmu-events/arch/x86/amdzen1/cache.json | 294 ++++++++++++++++
.../arch/x86/{amdfam17h => amdzen1}/core.json | 15 +-
.../x86/{amdfam17h => amdzen1}/floating-point.json | 64 +++-
.../arch/x86/{amdfam17h => amdzen1}/memory.json | 82 +++--
tools/perf/pmu-events/arch/x86/amdzen1/other.json | 56 +++
tools/perf/pmu-events/arch/x86/amdzen2/branch.json | 52 +++
tools/perf/pmu-events/arch/x86/amdzen2/cache.json | 338 ++++++++++++++++++
tools/perf/pmu-events/arch/x86/amdzen2/core.json | 130 +++++++
.../arch/x86/amdzen2/floating-point.json | 140 ++++++++
tools/perf/pmu-events/arch/x86/amdzen2/memory.json | 341 ++++++++++++++++++
tools/perf/pmu-events/arch/x86/amdzen2/other.json | 115 +++++++
tools/perf/pmu-events/arch/x86/mapfile.csv | 3 +-
tools/perf/pmu-events/jevents.c | 30 ++
tools/perf/tests/Build | 1 +
tools/perf/tests/builtin-test.c | 4 +
tools/perf/tests/pmu-events.c | 379 +++++++++++++++++++++
tools/perf/tests/tests.h | 1 +
tools/perf/ui/browsers/hists.c | 118 ++++++-
tools/perf/ui/hist.c | 93 ++++-
tools/perf/ui/keysyms.h | 1 +
tools/perf/util/annotate.h | 1 +
tools/perf/util/cpumap.c | 10 +-
tools/perf/util/dsos.c | 22 +-
tools/perf/util/evsel.c | 1 +
tools/perf/util/hist.h | 1 +
tools/perf/util/metricgroup.c | 49 +--
tools/perf/util/parse-events.c | 6 +-
tools/perf/util/pmu.c | 28 +-
tools/perf/util/pmu.h | 5 +
tools/perf/util/sort.c | 6 +-
tools/perf/util/stat-display.c | 6 +-
tools/perf/util/symbol-elf.c | 10 +-
tools/perf/util/symbol_conf.h | 1 +
47 files changed, 2374 insertions(+), 556 deletions(-)
delete mode 100644 tools/perf/arch/arm64/util/sym-handling.c
rename tools/perf/pmu-events/arch/{x86/amdfam17h => test/test_cpu}/branch.json (100%)
create mode 100644 tools/perf/pmu-events/arch/test/test_cpu/other.json
create mode 100644 tools/perf/pmu-events/arch/test/test_cpu/uncore.json
delete mode 100644 tools/perf/pmu-events/arch/x86/amdfam17h/cache.json
delete mode 100644 tools/perf/pmu-events/arch/x86/amdfam17h/other.json
create mode 100644 tools/perf/pmu-events/arch/x86/amdzen1/branch.json
create mode 100644 tools/perf/pmu-events/arch/x86/amdzen1/cache.json
rename tools/perf/pmu-events/arch/x86/{amdfam17h => amdzen1}/core.json (87%)
rename tools/perf/pmu-events/arch/x86/{amdfam17h => amdzen1}/floating-point.json (61%)
rename tools/perf/pmu-events/arch/x86/{amdfam17h => amdzen1}/memory.json (63%)
create mode 100644 tools/perf/pmu-events/arch/x86/amdzen1/other.json
create mode 100644 tools/perf/pmu-events/arch/x86/amdzen2/branch.json
create mode 100644 tools/perf/pmu-events/arch/x86/amdzen2/cache.json
create mode 100644 tools/perf/pmu-events/arch/x86/amdzen2/core.json
create mode 100644 tools/perf/pmu-events/arch/x86/amdzen2/floating-point.json
create mode 100644 tools/perf/pmu-events/arch/x86/amdzen2/memory.json
create mode 100644 tools/perf/pmu-events/arch/x86/amdzen2/other.json
create mode 100644 tools/perf/tests/pmu-events.cTest 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.
Ubuntu 19.10 is failing when linking against libllvm, which isn't the default, needs to be investigated, haven't tested with CC=gcc, but should be the same problem:
+ make ARCH= CROSS_COMPILE= EXTRA_CFLAGS= LIBCLANGLLVM=1 -C /git/linux/tools/perf O=/tmp/build/perf CC=clang
.../usr/bin/ld: /usr/lib/llvm-9/lib/libclangAnalysis.a(ExprMutationAnalyzer.cpp.o): in function `clang::ast_matchers::internal::matcher_ignoringImpCasts0Matcher::matches(clang::Expr const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const':
(.text._ZNK5clang12ast_matchers8internal32matcher_ignoringImpCasts0Matcher7matchesERKNS_4ExprEPNS1_14ASTMatchFinderEPNS1_21BoundNodesTreeBuilderE[_ZNK5clang12ast_matchers8internal32matcher_ignoringImpCasts0Matcher7matchesERKNS_4ExprEPNS1_14ASTMatchFinderEPNS1_21BoundNodesTreeBuilderE]+0x43): undefined reference to `clang::ast_matchers::internal::DynTypedMatcher::matches(clang::ast_type_traits::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const' /usr/bin/ld: /usr/lib/llvm-9/lib/libclangAnalysis.a(ExprMutationAnalyzer.cpp.o): in function `clang::ast_matchers::internal::matcher_hasLoopVariable0Matcher::matches(clang::CXXForRangeStmt const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const':
(.text._ZNK5clang12ast_matchers8internal31matcher_hasLoopVariable0Matcher7matchesERKNS_15CXXForRangeStmtEPNS1_14ASTMatchFinderEPNS1_21BoundNodesTreeBuilderE[_ZNK5clang12ast_matchers8internal31matcher_hasLoopVariable0Matcher7matchesERKNS_15CXXForRangeStmtEPNS1_14ASTMatchFinderEPNS1_21BoundNodesTreeBuilderE]+0x48): undefined reference to `clang::ast_matchers::internal::DynTypedMatcher::matches(clang::ast_type_traits::DynTypedNode const&, clang::ast_matchers::internal::ASTMatchFinder*, clang::ast_matchers::internal::BoundNodesTreeBuilder*) const'
...
It builds ok with the default set of options.
# export PERF_TARBALL=http://192.168.124.1/perf/perf-5.6.0-rc6.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.1 (git://git.alpinelinux.org/aports 7c78441134e54efbb34618f457d88c783c913361) (based on LLVM 9.0.1) 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.3.1 20190507 (Red Hat 8.3.1-4), clang version 8.0.1 (Red Hat 8.0.1-1.module_el8.1.0+215+a01033fb) 21 clearlinux:latest : Ok gcc (Clear Linux OS for Intel Architecture) 9.2.1 20200214 gcc_9_2_0_release-615-g7866f9ebf1, clang version 9.0.1 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-28) 9.2.1 20200203, clang version 8.0.1-7 (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-24) 9.2.1 20200117 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.1 (Fedora 9.0.1-2.fc31) 44 fedora:32 : Ok gcc (GCC) 10.0.1 20200216 (Red Hat 10.0.1-0.8), clang version 10.0.0 (Fedora 10.0.0-0.1.rc2.fc32) 45 fedora:rawhide : Ok gcc (GCC) 10.0.1 20200216 (Red Hat 10.0.1-0.8), clang version 10.0.0 (Fedora 10.0.0-0.3.rc2.fc33) 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) 10.0.0 20200216 (OpenMandriva), clang version 10.0.0 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.5.0, clang version 7.0.1 (tags/RELEASE_701/final 349238) 54 opensuse:15.2 : Ok gcc (SUSE Linux) 7.5.0, 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 20200128 [revision 83f65674e78d97d27537361de1a9d74067ff228d], clang version 9.0.1 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.3.1 20190507 (Red Hat 8.3.1-4.5.0.5), clang version 8.0.1 (Red Hat 8.0.1-1.0.1.module+el8.1.0+5428+345cee14) 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 : FAIL gcc (Ubuntu 9.2.1-9ubuntu2) 9.2.1 20191008, clang version 9.0.0-2 (tags/RELEASE_900/final) #
# uname -a
Linux five 5.5.10-200.fc31.x86_64 #1 SMP Wed Mar 18 14:21:38 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
# git log --oneline -1
0d33b3435253 perf dso: Fix dso comparison
# perf version --build-options
perf version 5.6.rc6.g9a13a0215c8d
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: PMU events : Ok
11: DSO data read : Ok
12: DSO data cache : Ok
13: DSO data reopen : Ok
14: Roundtrip evsel->name : Ok
15: Parse sched tracepoints fields : Ok
16: syscalls:sys_enter_openat event fields : Ok
17: Setup struct perf_event_attr : Ok
18: Match and link multiple hists : Ok
19: 'import perf' in python : Ok
20: Breakpoint overflow signal handler : Ok
21: Breakpoint overflow sampling : Ok
22: Breakpoint accounting : Ok
23: Watchpoint :
23.1: Read Only Watchpoint : Skip
23.2: Write Only Watchpoint : Ok
23.3: Read / Write Watchpoint : Ok
23.4: Modify Watchpoint : Ok
24: Number of exit events of a simple workload : Ok
25: Software clock events period values : Ok
26: Object code reading : Ok
27: Sample parsing : Ok
28: Use a dummy software event to keep tracking : Ok
29: Parse with no sample_id_all bit set : Ok
30: Filter hist entries : Ok
31: Lookup mmap thread : Ok
32: Share thread maps : Ok
33: Sort output of hist entries : Ok
34: Cumulate child hist entries : Ok
35: Track with sched_switch : Ok
36: Filter fds with revents mask in a fdarray : Ok
37: Add fd to a fdarray, making it autogrow : Ok
38: kmod_path__parse : Ok
39: Thread map : Ok
40: LLVM search and compile :
40.1: Basic BPF llvm compile : Ok
40.2: kbuild searching : Ok
40.3: Compile source for BPF prologue generation : Ok
40.4: Compile source for BPF relocation : Ok
41: Session topology : Ok
42: BPF filter :
42.1: Basic BPF filtering : Ok
42.2: BPF pinning : Ok
42.3: BPF prologue generation : Ok
42.4: BPF relocation checker : Ok
43: Synthesize thread map : Ok
44: Remove thread map : Ok
45: Synthesize cpu map : Ok
46: Synthesize stat config : Ok
47: Synthesize stat : Ok
48: Synthesize stat round : Ok
49: Synthesize attr update : Ok
50: Event times : Ok
51: Read backward ring buffer : Ok
52: Print cpu map : Ok
53: Merge cpu map : Ok
54: Probe SDT events : Ok
55: is_printable_array : Ok
56: Print bitmap : Ok
57: perf hooks : Ok
58: builtin clang support : Skip (not compiled in)
59: unit_number__scnprintf : Ok
60: mem2node : Ok
61: time utils : Ok
62: Test jit_write_elf : Ok
63: maps__merge_in : Ok
64: x86 rdpmc : Ok
65: Convert perf time to TSC : Ok
66: DWARF unwind : Ok
67: x86 instruction decoder - new instructions : Ok
68: Intel PT packet decoder : Ok
69: x86 bp modify : Ok
70: probe libc's inet_pton & backtrace it with ping : Ok
71: Use 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
74: Add vfs_getname probe to get syscall args filenames : Ok $ make -C tools/perf build-test
make: Entering directory '/home/acme/git/perf/tools/perf'
- tarpkg: ./tests/perf-targz-src-pkg .
make_tags_O: make tags
make_no_scripts_O: make NO_LIBPYTHON=1 NO_LIBPERL=1
make_no_libnuma_O: make NO_LIBNUMA=1
make_no_libperl_O: make NO_LIBPERL=1
make_no_libaudit_O: make NO_LIBAUDIT=1
make_no_libbionic_O: make NO_LIBBIONIC=1
make_no_libelf_O: make NO_LIBELF=1
make_debug_O: make DEBUG=1
make_no_ui_O: make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
make_no_newt_O: make NO_NEWT=1
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_no_auxtrace_O: make NO_AUXTRACE=1
make_install_bin_O: make install-bin
make_help_O: make help
make_pure_O: make
make_no_slang_O: make NO_SLANG=1
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_no_libunwind_O: make NO_LIBUNWIND=1
make_no_gtk2_O: make NO_GTK2=1
make_with_clangllvm_O: make LIBCLANGLLVM=1
make_no_demangle_O: make NO_DEMANGLE=1
make_util_map_o_O: make util/map.o
make_no_backtrace_O: make NO_BACKTRACE=1
make_install_prefix_O: make install prefix=/tmp/krava
make_no_libdw_dwarf_unwind_O: make NO_LIBDW_DWARF_UNWIND=1
make_install_prefix_slash_O: make install prefix=/tmp/krava/
make_doc_O: make doc
make_util_pmu_bison_o_O: make util/pmu-bison.o
make_no_libbpf_O: make NO_LIBBPF=1
make_perf_o_O: make perf.o
make_clean_all_O: make clean all
make_install_O: make install
make_with_babeltrace_O: make LIBBABELTRACE=1
OK
make: Leaving directory '/home/acme/git/perf/tools/perf'
$Arnaldo Carvalho de Melo
maintainerPATCH 1/24 perf parse-events: Fix 3 use after frees found with clang ASAN
From: Ian Rogers <[email protected]>
Reproducible with a clang asan build and then running perf test in particular 'Parse event definition strings'.
--- tools/perf/util/evsel.c | 1 + tools/perf/util/parse-events.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-)
tools/perf/util/evsel.c +1 -0
@@ -1287,6 +1287,7 @@ void perf_evsel__exit(struct evsel *evsel)perf_thread_map__put (evsel->core.threads);zfree (&evsel->group_name);zfree (&evsel->name); +zfree (&evsel->pmu_name); perf_evsel__object.fini (evsel); }
tools/perf/util/parse-events.c +3 -3
@@ -1449,7 +1449,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, evsel =__add_event (list, &parse_state->idx, &attr,NULL , pmu,NULL , auto_merge_stats,NULL );if (evsel) { - evsel->pmu_name = name; + evsel->pmu_name = name ?strdup (name) :NULL ; evsel->use_uncore_alias = use_uncore_alias;return 0 ; }else {
@@ -1497,7 +1497,7 @@ int parse_events_add_pmu(struct parse_events_state *parse_state, evsel->snapshot = info.snapshot; evsel->metric_expr = info.metric_expr; evsel->metric_name = info.metric_name; - evsel->pmu_name = name; + evsel->pmu_name = name ?strdup (name) :NULL ; evsel->use_uncore_alias = use_uncore_alias; evsel->percore =config_term_percore (&evsel->config_terms); }
@@ -1547,7 +1547,7 @@ int parse_events_multi_pmu_add(struct parse_events_state *parse_state,if (!parse_events_add_pmu (parse_state, list, pmu->name, head, true, true)) { -pr_debug ("%s -> %s/%s/\n" , config, +pr_debug ("%s -> %s/%s/\n" , str, pmu->name, alias->str); ok++; }
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 2/24 perf symbols: Consolidate symbol fixup issue
In reply to Arnaldo Carvalho de MeloFrom: Leo Yan <[email protected]>
After copying Arm64's perf archive with object files and perf.data file to x86 laptop, the x86's perf kernel symbol resolution fails. It outputs 'unknown' for all symbols parsing.
This issue is root caused by the function elf__needs_adjust_symbols(), x86 perf tool uses one weak version, Arm64 (and powerpc) has rewritten their own version. elf__needs_adjust_symbols() decides if need to parse symbols with the relative offset address; but x86 building uses the weak function which misses to check for the elf type 'ET_DYN', so that it cannot parse symbols in Arm DSOs due to the wrong result from elf__needs_adjust_symbols().
The DSO parsing should not depend on any specific architecture perf building; e.g. x86 perf tool can parse Arm and Arm64 DSOs, vice versa. And confirmed by Naveen N. Rao that powerpc64 kernels are not being built as ET_DYN anymore and change to ET_EXEC.
This patch removes the arch specific functions for Arm64 and powerpc and changes elf__needs_adjust_symbols() as a common function.
In the common elf__needs_adjust_symbols(), it checks an extra condition 'ET_DYN' for elf header type. With this fixing, the Arm64 DSO can be parsed properly with x86's perf tool.
Before:
# perf script main 3258 1 branches: 0 [unknown] ([unknown]) => ffff800010c4665c [unknown] ([kernel.kallsyms]) main 3258 1 branches: ffff800010c46670 [unknown] ([kernel.kallsyms]) => ffff800010c4eaec [unknown] ([kernel.kallsyms]) main 3258 1 branches: ffff800010c4eaec [unknown] ([kernel.kallsyms]) => ffff800010c4eb00 [unknown] ([kernel.kallsyms]) main 3258 1 branches: ffff800010c4eb08 [unknown] ([kernel.kallsyms]) => ffff800010c4e780 [unknown] ([kernel.kallsyms]) main 3258 1 branches: ffff800010c4e7a0 [unknown] ([kernel.kallsyms]) => ffff800010c4eeac [unknown] ([kernel.kallsyms]) main 3258 1 branches: ffff800010c4eebc [unknown] ([kernel.kallsyms]) => ffff800010c4ed80 [unknown] ([kernel.kallsyms])
After:
# perf script main 3258 1 branches: 0 [unknown] ([unknown]) => ffff800010c4665c coresight_timeout+0x54 ([kernel.kallsyms]) main 3258 1 branches: ffff800010c46670 coresight_timeout+0x68 ([kernel.kallsyms]) => ffff800010c4eaec etm4_enable_hw+0x3cc ([kernel.kallsyms]) main 3258 1 branches: ffff800010c4eaec etm4_enable_hw+0x3cc ([kernel.kallsyms]) => ffff800010c4eb00 etm4_enable_hw+0x3e0 ([kernel.kallsyms]) main 3258 1 branches: ffff800010c4eb08 etm4_enable_hw+0x3e8 ([kernel.kallsyms]) => ffff800010c4e780 etm4_enable_hw+0x60 ([kernel.kallsyms]) main 3258 1 branches: ffff800010c4e7a0 etm4_enable_hw+0x80 ([kernel.kallsyms]) => ffff800010c4eeac etm4_enable+0x2d4 ([kernel.kallsyms]) main 3258 1 branches: ffff800010c4eebc etm4_enable+0x2e4 ([kernel.kallsyms]) => ffff800010c4ed80 etm4_enable+0x1a8 ([kernel.kallsyms])
v3: Changed to check for ET_DYN across all architectures.
v2: Fixed Arm64 and powerpc native building.
--- tools/perf/arch/arm64/util/Build | 1 - tools/perf/arch/arm64/util/sym-handling.c | 19 ------------------- tools/perf/arch/powerpc/util/Build | 1 - tools/perf/arch/powerpc/util/sym-handling.c | 10 ---------- tools/perf/util/symbol-elf.c | 10 ++++++++-- 5 files changed, 8 insertions(+), 33 deletions(-) delete mode 100644 tools/perf/arch/arm64/util/sym-handling.c
tools/perf/arch/arm64/util/Build +0 -1
@@ -1,6 +1,5 @@ perf-y += header.o perf-y += perf_regs.o -perf-y += sym-handling.o perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
tools/perf/arch/arm64/util/sym-handling.c deleted +0 -19
@@ -1,19 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* -* -* Copyright (C) 2015 Naveen N. Rao, IBM Corporation -*/ - -#include "symbol.h" // for the elf__needs_adjust_symbols() prototype -#include <stdbool.h> - -#ifdef HAVE_LIBELF_SUPPORT -#include <gelf.h> - -bool elf__needs_adjust_symbols (GElf_Ehdr ehdr) -{ -return ehdr.e_type ==ET_EXEC || - ehdr.e_type ==ET_REL || - ehdr.e_type ==ET_DYN ; -} -#endif
tools/perf/arch/powerpc/util/Build +0 -1
@@ -1,5 +1,4 @@ perf-y += header.o -perf-y += sym-handling.o perf-y += kvm-stat.o perf-y += perf_regs.o perf-y += mem-events.o
tools/perf/arch/powerpc/util/sym-handling.c +0 -10
@@ -10,16 +10,6 @@#include "probe-event.h" #include "probe-file.h" -#ifdef HAVE_LIBELF_SUPPORT -bool elf__needs_adjust_symbols (GElf_Ehdr ehdr) -{ -return ehdr.e_type ==ET_EXEC || - ehdr.e_type ==ET_REL || - ehdr.e_type ==ET_DYN ; -} - -#endif -int arch__choose_best_symbol (struct symbol *syma,struct symbol *symb__maybe_unused ) {
tools/perf/util/symbol-elf.c +8 -2
@@ -704,9 +704,15 @@ void symsrc__destroy(struct symsrc *ss)close (ss->fd); } -bool __weak elf__needs_adjust_symbols (GElf_Ehdr ehdr) +bool elf__needs_adjust_symbols (GElf_Ehdr ehdr) { -return ehdr.e_type ==ET_EXEC || ehdr.e_type ==ET_REL ; +/* +* Usually vmlinux is an ELF file with type ET_EXEC for most +* architectures; except Arm64 kernel is linked with option +* '-share', so need to check type ET_DYN. +*/ +return ehdr.e_type ==ET_EXEC || ehdr.e_type ==ET_REL || + ehdr.e_type ==ET_DYN ; } int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name,
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 3/24 perf report: Print al_addr when symbol is not found
In reply to Arnaldo Carvalho de MeloFrom: Jin Yao <[email protected]>
For branch mode, if the symbol is not found, it prints the address.
For example, 0x0000555eee0365a0 in below output.
Overhead Command Source Shared Object Source Symbol Target Symbol
17.55% div libc-2.27.so [.] __random [.] __random
6.11% div div [.] 0x0000555eee0365a0 [.] rand
6.10% div libc-2.27.so [.] rand [.] 0x0000555eee036769
5.80% div libc-2.27.so [.] __random_r [.] __random
5.72% div libc-2.27.so [.] __random [.] __random_r
5.62% div libc-2.27.so [.] __random_r [.] __random_r
5.38% div libc-2.27.so [.] __random [.] rand
4.56% div libc-2.27.so [.] __random [.] __random
4.49% div div [.] 0x0000555eee036779 [.] 0x0000555eee0365ff
4.25% div div [.] 0x0000555eee0365fa [.] 0x0000555eee036760But it's not very easy to understand what the instructions are in the binary. So this patch uses the al_addr instead.
With this patch, the output is
Overhead Command Source Shared Object Source Symbol Target Symbol
17.55% div libc-2.27.so [.] __random [.] __random
6.11% div div [.] 0x00000000000005a0 [.] rand
6.10% div libc-2.27.so [.] rand [.] 0x0000000000000769
5.80% div libc-2.27.so [.] __random_r [.] __random
5.72% div libc-2.27.so [.] __random [.] __random_r
5.62% div libc-2.27.so [.] __random_r [.] __random_r
5.38% div libc-2.27.so [.] __random [.] rand
4.56% div libc-2.27.so [.] __random [.] __random
4.49% div div [.] 0x0000000000000779 [.] 0x00000000000005ff
4.25% div div [.] 0x00000000000005fa [.] 0x0000000000000760Now we can use objdump to dump the object starting from 0x5a0.
For example,
objdump -d --start-address 0x5a0 div
00000000000005a0 <rand@plt>:
5a0: ff 25 2a 0a 20 00 jmpq *0x200a2a(%rip) # 200fd0 <__cxa_finalize@plt+0x200a20> 5a6: 68 02 00 00 00 pushq $0x2 5ab: e9 c0 ff ff ff jmpq 570 <srand@plt-0x10>
...
Committer testing:
[root@seventh ~]# perf record -a -b sleep 1
[root@seventh ~]# perf report --header-only | grep cpudesc
# cpudesc : Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
[root@seventh ~]# perf evlist -v
cycles: size: 120, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|BRANCH_STACK, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1, branch_sample_type: ANY
[root@seventh ~]#Before:
[root@seventh ~]# perf report --stdio --dso libsystemd-shared-241.so | head -20
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 2K of event 'cycles'
# Event count (approx.): 2240
#
# Overhead Command Source Shared Object Source Symbol Target Symbol Basic Block Cycles
# ........ ............... ........................ ...................... ...................... ..................
#
0.13% systemd-journal libc-2.29.so [.] cfree@GLIBC_2.2.5 [.] _int_free 1
0.09% systemd libsystemd-shared-241.so [.] 0x00007fe406465c82 [.] 0x00007fe406465d80 1
0.09% systemd libsystemd-shared-241.so [.] 0x00007fe406465ded [.] 0x00007fe406465c30 1
0.09% systemd libsystemd-shared-241.so [.] 0x00007fe406465e4e [.] 0x00007fe406465de0 1
0.09% systemd-journal systemd-journald [.] free@plt [.] cfree@GLIBC_2.2.5 1
0.09% systemd-journal libc-2.29.so [.] _int_free [.] _int_free 18
0.09% systemd-journal libc-2.29.so [.] _int_free [.] _int_free 2
0.04% systemd libsystemd-shared-241.so [.] bus_resolve@plt [.] bus_resolve 204
0.04% systemd libsystemd-shared-241.so [.] getpid_cached@plt [.] getpid_cached 7
[root@seventh ~]#After:
[root@seventh ~]# perf report --stdio --dso libsystemd-shared-241.so | head -20
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 2K of event 'cycles'
# Event count (approx.): 2240
#
# Overhead Command Source Shared Object Source Symbol Target Symbol Basic Block Cycles
# ........ ............... ........................ ...................... ...................... ..................
#
0.13% systemd-journal libc-2.29.so [.] cfree@GLIBC_2.2.5 [.] _int_free 1
0.09% systemd libsystemd-shared-241.so [.] 0x00000000000f7c82 [.] 0x00000000000f7d80 1
0.09% systemd libsystemd-shared-241.so [.] 0x00000000000f7ded [.] 0x00000000000f7c30 1
0.09% systemd libsystemd-shared-241.so [.] 0x00000000000f7e4e [.] 0x00000000000f7de0 1
0.09% systemd-journal systemd-journald [.] free@plt [.] cfree@GLIBC_2.2.5 1
0.09% systemd-journal libc-2.29.so [.] _int_free [.] _int_free 18
0.09% systemd-journal libc-2.29.so [.] _int_free [.] _int_free 2
0.04% systemd libsystemd-shared-241.so [.] bus_resolve@plt [.] bus_resolve 204
0.04% systemd libsystemd-shared-241.so [.] getpid_cached@plt [.] getpid_cached 7
[root@seventh ~]#Lets use -v to get full paths and then try objdump on the unresolved address:
[root@seventh ~]# perf report -v --stdio --dso libsystemd-shared-241.so |& grep libsystemd-shared-241.so | tail -1
0.04% systemd-journal /usr/lib/systemd/libsystemd-shared-241.so 0x80c1a B [.] 0x0000000000080c1a 0x80a95 B [.] 0x0000000000080a95 61
[root@seventh ~]#
[root@seventh ~]# objdump -d --start-address 0x00000000000f7d80 /usr/lib/systemd/libsystemd-shared-241.so | head -20 /usr/lib/systemd/libsystemd-shared-241.so: file format elf64-x86-64
Disassembly of section .text:
00000000000f7d80 <proc_cmdline_parse_given@@SD_SHARED+0x330>:
f7d80: 41 39 11 cmp %edx,(%r9)
f7d83: 0f 84 ff fe ff ff je f7c88 <proc_cmdline_parse_given@@SD_SHARED+0x238>
f7d89: 4c 8d 05 97 09 0c 00 lea 0xc0997(%rip),%r8 # 1b8727 <utf8_skip_data@@SD_SHARED+0x3147>
f7d90: b9 49 00 00 00 mov $0x49,%ecx
f7d95: 48 8d 15 c9 f5 0b 00 lea 0xbf5c9(%rip),%rdx # 1b7365 <utf8_skip_data@@SD_SHARED+0x1d85>
f7d9c: 31 ff xor %edi,%edi
f7d9e: 48 8d 35 9b ff 0b 00 lea 0xbff9b(%rip),%rsi # 1b7d40 <utf8_skip_data@@SD_SHARED+0x2760>
f7da5: e8 a6 d6 f4 ff callq 45450 <log_assert_failed_realm@plt>
f7daa: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1)
f7db0: 41 56 push %r14
f7db2: 41 55 push %r13
f7db4: 41 54 push %r12
f7db6: 55 push %rbp[root@seventh ~]#
If we tried the the reported address before this patch:
[root@seventh ~]# objdump -d --start-address 0x00007fe406465d80 /usr/lib/systemd/libsystemd-shared-241.so | head -20
/usr/lib/systemd/libsystemd-shared-241.so: file format elf64-x86-64
[root@seventh ~]#
--- tools/perf/util/sort.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/sort.c +4 -2
@@ -869,7 +869,8 @@ static int hist_entry__sym_from_snprintf(struct hist_entry *he, char *bf,if (he->branch_info) {struct addr_map_symbol *from = &he->branch_info->from; -return _hist_entry__sym_snprintf (&from->ms, from->addr, he->level, bf, size, width); +return _hist_entry__sym_snprintf (&from->ms, from->al_addr, + he->level, bf, size, width); }return repsep_snprintf (bf, size,"%-*.*s" , width, width,"N/A" );
@@ -881,7 +882,8 @@ static int hist_entry__sym_to_snprintf(struct hist_entry *he, char *bf,if (he->branch_info) {struct addr_map_symbol *to = &he->branch_info->to; -return _hist_entry__sym_snprintf (&to->ms, to->addr, he->level, bf, size, width); +return _hist_entry__sym_snprintf (&to->ms, to->al_addr, + he->level, bf, size, width); }return repsep_snprintf (bf, size,"%-*.*s" , width, width,"N/A" );
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 4/24 perf report: Support interactive annotation of code without symbols
In reply to Arnaldo Carvalho de MeloFrom: Jin Yao <[email protected]>
For perf report on stripped binaries it is currently impossible to do annotation. The annotation state is all tied to symbols, but there are either no symbols, or symbols are not covering all the code.
We should support the annotation functionality even without symbols.
This patch fakes a symbol and the symbol name is the string of address. After that, we just follow current annotation working flow.
For example,
1. perf report
Overhead Command Shared Object Symbol
20.67% div libc-2.27.so [.] __random_r
17.29% div libc-2.27.so [.] __random
10.59% div div [.] 0x0000000000000628
9.25% div div [.] 0x0000000000000612
6.11% div div [.] 0x00000000000006452. Select the line of "10.59% div div [.] 0x0000000000000628" and ENTER.
Annotate 0x0000000000000628
Zoom into div thread
Zoom into div DSO (use the 'k' hotkey to zoom directly into the kernel) Browse map details
Run scripts for samples of symbol [0x0000000000000628]
Run scripts for all samples
Switch to another data file in PWD
Exit
3. Select the "Annotate 0x0000000000000628" and ENTER.
Percent│
│
│
│ Disassembly of section .text:
│
│ 0000000000000628 <.text+0x68>:
│ divsd %xmm4,%xmm0
│ divsd %xmm3,%xmm1
│ movsd (%rsp),%xmm2
│ addsd %xmm1,%xmm0
│ addsd %xmm2,%xmm0
│ movsd %xmm0,(%rsp)Now we can see the dump of object starting from 0x628.
v5:
---
Remove the hotkey 'a' implementation from this patch. It will be moved to a separate patch.
v4:
---
1. Support the hotkey 'a'. When we press 'a' on address, now it supports the annotation.
2. Change the patch title from
"Support interactive annotation of code without symbols" to "perf report: Support interactive annotation of code without symbols"
v3:
---
Keep just the ANNOTATION_DUMMY_LEN, and remove the opts->annotate_dummy_len since it's the "maybe in future we will provide" feature.
v2:
---
Fix a crash issue when annotating an address in "unknown" object.
The steps to reproduce this issue:
perf record -e cycles:u ls
perf report
75.29% ls ld-2.27.so [.] do_lookup_x
23.64% ls ld-2.27.so [.] __GI___tunables_init
1.04% ls [unknown] [k] 0xffffffff85c01210
0.03% ls ld-2.27.so [.] _start When annotating 0xffffffff85c01210, the crash happens.
v2 adds checking for ms->map in add_annotate_opt(). If the object is "unknown", ms->map is NULL.
Committer notes:
Renamed new_annotate_sym() to symbol__new_unresolved().
Use PRIx64 to fix this issue in some 32-bit arches:
ui/browsers/hists.c: In function 'symbol__new_unresolved':
ui/browsers/hists.c:2474:38: error: format '%lx' expects argument of type 'long unsigned int', but argument 5 has type 'u64' {aka 'long long unsigned int'} [-Werror=format=]
snprintf(name, sizeof(name), "%-#.*lx", BITS_PER_LONG / 4, addr);
~~~~~~^ ~~~~
%-#.*llx--- tools/perf/ui/browsers/hists.c | 43 +++++++++++++++++++++++++++++----- tools/perf/util/annotate.h | 1 + 2 files changed, 38 insertions(+), 6 deletions(-)
tools/perf/ui/browsers/hists.c +37 -6
@@ -2465,13 +2465,41 @@ do_annotate(struct hist_browser *browser, struct popup_action *act)return 0 ; } +static struct symbol *symbol__new_unresolved (u64 addr,struct map *map) +{ +struct annotated_source *src; +struct symbol *sym; +char name[64 ]; + +snprintf (name,sizeof (name),"%.*" PRIx64,BITS_PER_LONG /4 , addr); + + sym =symbol__new (addr,ANNOTATION_DUMMY_LEN ,0 ,0 , name); +if (sym) { + src =symbol__hists (sym,1 ); +if (!src) { +symbol__delete (sym); +return NULL ; + } + +dso__insert_symbol (map->dso, sym); + } + +return sym; +} +static int add_annotate_opt (struct hist_browser *browser__maybe_unused ,struct popup_action *act,char **optstr, -struct map_symbol *ms) +struct map_symbol *ms, +u64 addr) { -if (ms->sym ==NULL || ms->map->dso->annotate_warned || -symbol__annotation (ms->sym)->src ==NULL ) +if (!ms->map || !ms->map->dso || ms->map->dso->annotate_warned) +return 0 ; + +if (!ms->sym) + ms->sym =symbol__new_unresolved (addr, ms->map); + +if (ms->sym ==NULL ||symbol__annotation (ms->sym)->src ==NULL )return 0 ;if (asprintf (optstr,"Annotate %s" , ms->sym->name) <0 )
@@ -3219,17 +3247,20 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events, nr_options +=add_annotate_opt (browser, &actions[nr_options], &options[nr_options], - &bi->from.ms); + &bi->from.ms, + bi->from.al_addr);if (bi->to.ms.sym != bi->from.ms.sym) nr_options +=add_annotate_opt (browser, &actions[nr_options], &options[nr_options], - &bi->to.ms); + &bi->to.ms, + bi->to.al_addr); }else { nr_options +=add_annotate_opt (browser, &actions[nr_options], &options[nr_options], - browser->selection); + browser->selection, + browser->he_selection->ip); } skip_annotation: nr_options += add_thread_opt(browser, &actions[nr_options],
tools/perf/util/annotate.h +1 -0
@@ -74,6 +74,7 @@ bool ins__is_fused(struct arch *arch, const char *ins1, const char *ins2);#define ANNOTATION__CYCLES_WIDTH 6#define ANNOTATION__MINMAX_CYCLES_WIDTH 19#define ANNOTATION__AVG_IPC_WIDTH 36 +#define ANNOTATION_DUMMY_LEN 256struct annotation_options { bool hide_src_code,
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 5/24 perf report/top TUI: Support hotkey 'a' for annotation of unresolved addresses
In reply to Arnaldo Carvalho de MeloFrom: Jin Yao <[email protected]>
In previous patch, we have supported the annotation functionality even without symbols.
For this patch, it supports the hotkey 'a' on address in report view. Note that, for branch mode, we only support the annotation for "branch to" address.
--- tools/perf/ui/browsers/hists.c | 46 ++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 11 deletions(-)
tools/perf/ui/browsers/hists.c +35 -11
@@ -3061,21 +3061,45 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,continue ; } -if (browser->selection ==NULL || - browser->selection->sym ==NULL || - browser->selection->map->dso->annotate_warned) +if (!browser->selection || + !browser->selection->map || + !browser->selection->map->dso || + 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 ; +if (!browser->selection->sym) { +if (!browser->he_selection) +continue ; + +if (sort__mode ==SORT_MODE__BRANCH ) { + bi = browser->he_selection->branch_info; +if (!bi || !bi->to.ms.map) +continue ; + + actions->ms.sym =symbol__new_unresolved (bi->to.al_addr, bi->to.ms.map); + actions->ms.map = bi->to.ms.map; + }else { + actions->ms.sym =symbol__new_unresolved (browser->he_selection->ip, + browser->selection->map); + actions->ms.map = browser->selection->map; + } + +if (!actions->ms.sym) +continue ; + }else { +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; } - actions->ms.map = browser->selection->map; - actions->ms.sym = browser->selection->sym;do_annotate (browser, actions);continue ;case 'P' :
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 6/24 perf report: Allow specifying event to be used as sort key in --group output
In reply to Arnaldo Carvalho de MeloFrom: Jin Yao <[email protected]>
When performing "perf report --group", it shows the event group information together. By default, the output is sorted by the first event in group.
It would be nice for user to select any event for sorting. This patch introduces a new option "--group-sort-idx" to sort the output by the event at the index n in event group.
For example,
Before:
# perf report --group --stdio
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 12K of events 'cpu/instructions,period=2000003/, cpu/cpu-cycles,period=200003/, BR_MISP_RETIRED.ALL_BRANCHES:pp, cpu/event=0xc0,umask=1,cmask=1, # Event count (approx.): 6451235635
#
# Overhead Command Shared Object Symbol
# ................................ ......... ....................... ...................................
#
92.19% 98.68% 0.00% 93.30% mgen mgen [.] LOOP1
3.12% 0.29% 0.00% 0.16% gsd-color libglib-2.0.so.0.5600.4 [.] 0x0000000000049515
1.56% 0.03% 0.00% 0.04% gsd-color libglib-2.0.so.0.5600.4 [.] 0x00000000000494b7
1.56% 0.01% 0.00% 0.00% gsd-color libglib-2.0.so.0.5600.4 [.] 0x00000000000494ce
1.56% 0.00% 0.00% 0.00% mgen [kernel.kallsyms] [k] task_tick_fair
0.00% 0.15% 0.00% 0.04% perf [kernel.kallsyms] [k] smp_call_function_single
0.00% 0.13% 0.00% 6.08% swapper [kernel.kallsyms] [k] intel_idle
0.00% 0.03% 0.00% 0.00% gsd-color libglib-2.0.so.0.5600.4 [.] g_main_context_check
0.00% 0.03% 0.00% 0.00% swapper [kernel.kallsyms] [k] apic_timer_interrupt
...After:
# perf report --group --stdio --group-sort-idx 3
# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 12K of events 'cpu/instructions,period=2000003/, cpu/cpu-cycles,period=200003/, BR_MISP_RETIRED.ALL_BRANCHES:pp, cpu/event=0xc0,umask=1,cmask=1, # Event count (approx.): 6451235635
#
# Overhead Command Shared Object Symbol
# ................................ ......... ....................... ...................................
#
92.19% 98.68% 0.00% 93.30% mgen mgen [.] LOOP1
0.00% 0.13% 0.00% 6.08% swapper [kernel.kallsyms] [k] intel_idle
3.12% 0.29% 0.00% 0.16% gsd-color libglib-2.0.so.0.5600.4 [.] 0x0000000000049515
0.00% 0.00% 0.00% 0.06% swapper [kernel.kallsyms] [k] hrtimer_start_range_ns
1.56% 0.03% 0.00% 0.04% gsd-color libglib-2.0.so.0.5600.4 [.] 0x00000000000494b7
0.00% 0.15% 0.00% 0.04% perf [kernel.kallsyms] [k] smp_call_function_single
0.00% 0.00% 0.00% 0.02% mgen [kernel.kallsyms] [k] update_curr
0.00% 0.00% 0.00% 0.02% mgen [kernel.kallsyms] [k] apic_timer_interrupt
0.00% 0.00% 0.00% 0.02% mgen [kernel.kallsyms] [k] native_apic_msr_eoi_write
0.00% 0.00% 0.00% 0.02% mgen [kernel.kallsyms] [k] __update_load_avg_se
0.00% 0.00% 0.00% 0.02% mgen [kernel.kallsyms] [k] scheduler_tickNow the output is sorted by the fourth event in group.
v7:
---
Rebase to latest perf/core, no other change.
v4:
---
1. Update Documentation/perf-report.txt to mention '--group-sort-idx' support multiple groups with different amount of events and it should be used on grouped events.
2. Update __hpp__group_sort_idx(), just return when the idx is out of limit.
3. Return failure on symbol_conf.group_sort_idx && !session->evlist->nr_groups. So now we don't need to use together with --group.
v3:
---
Refine the code in __hpp__group_sort_idx().
Before:
for (i = 1; i < nr_members; i++) {
if (i == idx) {
ret = field_cmp(fields_a[i], fields_b[i]);
if (ret)
goto out;
}}
After:
if (idx >= 1 && idx < nr_members) {
ret = field_cmp(fields_a[idx], fields_b[idx]);
if (ret)
goto out;}
--- tools/perf/Documentation/perf-report.txt | 5 ++ tools/perf/builtin-report.c | 10 +++ tools/perf/ui/hist.c | 93 ++++++++++++++++++++---- tools/perf/util/symbol_conf.h | 1 + 4 files changed, 94 insertions(+), 15 deletions(-)
tools/perf/Documentation/perf-report.txt +5 -0
@@ -377,6 +377,11 @@ OPTIONS Show event group information together. It forces group output also if there are no groups defined in data file. +--group-sort-idx:: + Sort the output by the event at the index n in group. If n is invalid, + sort by the first event. It can support multiple groups with different + amount of events. WARNING: This should be used on grouped events. + --demangle:: Demangle symbol names to human readable form. It's enabled by default, disable with --no-demangle.
tools/perf/builtin-report.c +10 -0
@@ -1227,6 +1227,10 @@ int cmd_report(int argc, const char **argv) "Show a column with the sum of periods"),OPT_BOOLEAN_SET (0 ,"group" , &symbol_conf.event_group, &report.group_set,"Show event group information together" ), +OPT_INTEGER (0 ,"group-sort-idx" , &symbol_conf.group_sort_idx, +"Sort the output by the event at the index n in group. " +"If n is invalid, sort by the first event. " +"WARNING: should be used on grouped events." ),OPT_CALLBACK_NOOPT ('b' ,"branch-stack" , &branch_mode,"" ,"use branch records for per branch histogram filling" , parse_branch_mode),
@@ -1369,6 +1373,12 @@ int cmd_report(int argc, const char **argv)setup_forced_leader (&report, session->evlist); +if (symbol_conf.group_sort_idx && !session->evlist->nr_groups) { +parse_options_usage (NULL , options,"group-sort-idx" ,0 ); + ret = -EINVAL ; + goto error; + } +if (itrace_synth_opts.last_branch) has_br_stack = true;
tools/perf/ui/hist.c +78 -15
115 lines not on this page · raw message
tools/perf/util/symbol_conf.h +1 -0
@@ -73,6 +73,7 @@ struct symbol_conf {const char *symfs;int res_sample;int pad_output_len_dso; +int group_sort_idx; };extern struct symbol_conf symbol_conf;
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 7/24 perf report: Support a new key to reload the browser
In reply to Arnaldo Carvalho de MeloFrom: Jin Yao <[email protected]>
Sometimes we may need to reload the browser to update the output since some options are changed.
This patch creates a new key K_RELOAD. Once the __cmd_report() returns K_RELOAD, it would repeat the whole process, such as, read samples from data file, sort the data and display in the browser.
v5:
---
1. Fix the 'make NO_SLANG=1' error. Define K_RELOAD in util/hist.h.
2. Skip setup_sorting() in repeat path if last key is K_RELOAD.
v4:
---
Need to quit in perf_evsel_menu__run if key is K_RELOAD.
--- tools/perf/builtin-report.c | 6 +++--- tools/perf/ui/browsers/hists.c | 1 + tools/perf/ui/keysyms.h | 1 + tools/perf/util/hist.h | 1 + 4 files changed, 6 insertions(+), 3 deletions(-)
tools/perf/builtin-report.c +3 -3
@@ -635,7 +635,7 @@ static int report__browse_hists(struct report *rep)* Usually "ret" is the last pressed key, and we only * care if the key notifies us to switch data file. */ -if (ret !=K_SWITCH_INPUT_DATA ) +if (ret !=K_SWITCH_INPUT_DATA && ret !=K_RELOAD ) ret =0 ;break ;case 2 :
@@ -1480,7 +1480,7 @@ int cmd_report(int argc, const char **argv) sort_order = sort_tmp; } -if ((last_key !=K_SWITCH_INPUT_DATA ) && +if ((last_key !=K_SWITCH_INPUT_DATA && last_key !=K_RELOAD ) && (setup_sorting (session->evlist) <0 )) {if (sort_order)parse_options_usage (report_usage, options,"s" ,1 );
@@ -1559,7 +1559,7 @@ int cmd_report(int argc, const char **argv)sort__setup_elide (stdout); ret =__cmd_report (&report); -if (ret ==K_SWITCH_INPUT_DATA ) { +if (ret ==K_SWITCH_INPUT_DATA || ret ==K_RELOAD ) {perf_session__delete (session); last_key =K_SWITCH_INPUT_DATA ; goto repeat;
tools/perf/ui/browsers/hists.c +1 -0
@@ -3495,6 +3495,7 @@ static int perf_evsel_menu__run(struct evsel_menu *menu, pos =perf_evsel__prev (pos); goto browse_hists;case K_SWITCH_INPUT_DATA : +case K_RELOAD :case 'q' :case CTRL ('c' ): goto out;
tools/perf/ui/keysyms.h +1 -0
@@ -25,5 +25,6 @@#define K_ERROR -2#define K_RESIZE -3#define K_SWITCH_INPUT_DATA -4 +#define K_RELOAD -5#endif /* _PERF_KEYSYMS_H_ */
tools/perf/util/hist.h +1 -0
@@ -536,6 +536,7 @@ static inline int block_hists_tui_browse(struct block_hist *bh __maybe_unused,#define K_LEFT -1000#define K_RIGHT -2000#define K_SWITCH_INPUT_DATA -3000 +#define K_RELOAD -4000#endif unsigned int hists__sort_list_width (struct hists *hists);
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 8/24 perf report/top TUI: Support hotkeys to let user select any event for sorting
In reply to Arnaldo Carvalho de MeloFrom: Jin Yao <[email protected]>
When performing "perf report --group", it shows the event group information together. In previous patch, we have supported a new option "--group-sort-idx" to sort the output by the event at the index n in event group.
It would be nice if we can use a hotkey in browser to select a event to sort.
For example,
# perf report --group
Samples: 12K of events 'cpu/instructions,period=2000003/, cpu/cpu-cycles,period=200003/, ...
Overhead Command Shared Object Symbol 92.19% 98.68% 0.00% 93.30% mgen mgen [.] LOOP1 3.12% 0.29% 0.00% 0.16% gsd-color libglib-2.0.so.0.5600.4 [.] 0x0000000000049515 1.56% 0.03% 0.00% 0.04% gsd-color libglib-2.0.so.0.5600.4 [.] 0x00000000000494b7 1.56% 0.01% 0.00% 0.00% gsd-color libglib-2.0.so.0.5600.4 [.] 0x00000000000494ce 1.56% 0.00% 0.00% 0.00% mgen [kernel.kallsyms] [k] task_tick_fair 0.00% 0.15% 0.00% 0.04% perf [kernel.kallsyms] [k] smp_call_function_single 0.00% 0.13% 0.00% 6.08% swapper [kernel.kallsyms] [k] intel_idle 0.00% 0.03% 0.00% 0.00% gsd-color libglib-2.0.so.0.5600.4 [.] g_main_context_check 0.00% 0.03% 0.00% 0.00% swapper [kernel.kallsyms] [k] apic_timer_interrupt 0.00% 0.03% 0.00% 0.00% swapper [kernel.kallsyms] [k] check_preempt_curr
When user press hotkey '3' (event index, starting from 0), it indicates to sort output by the forth event in group.
Samples: 12K of events 'cpu/instructions,period=2000003/, cpu/cpu-cycles,period=200003/, ...
Overhead Command Shared Object Symbol 92.19% 98.68% 0.00% 93.30% mgen mgen [.] LOOP1 0.00% 0.13% 0.00% 6.08% swapper [kernel.kallsyms] [k] intel_idle 3.12% 0.29% 0.00% 0.16% gsd-color libglib-2.0.so.0.5600.4 [.] 0x0000000000049515 0.00% 0.00% 0.00% 0.06% swapper [kernel.kallsyms] [k] hrtimer_start_range_ns 1.56% 0.03% 0.00% 0.04% gsd-color libglib-2.0.so.0.5600.4 [.] 0x00000000000494b7 0.00% 0.15% 0.00% 0.04% perf [kernel.kallsyms] [k] smp_call_function_single 0.00% 0.00% 0.00% 0.02% mgen [kernel.kallsyms] [k] update_curr 0.00% 0.00% 0.00% 0.02% mgen [kernel.kallsyms] [k] apic_timer_interrupt 0.00% 0.00% 0.00% 0.02% mgen [kernel.kallsyms] [k] native_apic_msr_eoi_write 0.00% 0.00% 0.00% 0.02% mgen [kernel.kallsyms] [k] __update_load_avg_se
v6:
---
Jiri provided a good improvement to eliminate unneeded refresh. This improvement is added to v6.
v2:
---
1. Report warning at helpline when index is invalid.
2. Report warning at helpline when it's not group event.
3. Use "case '0' ... '9'" to refine the code
4. Split K_RELOAD implementation to another patch.
--- tools/perf/ui/browsers/hists.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
tools/perf/ui/browsers/hists.c +27 -1
@@ -2992,7 +2992,8 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,"s Switch to another data file in PWD\n" "t Zoom into current Thread\n" "V Verbose (DSO names in callchains, etc)\n" -"/ Filter symbol by name" ; +"/ Filter symbol by name\n" +"0-9 Sort by event n in group" ;static const char top_help[] =HIST_BROWSER_HELP_COMMON "P Print histograms to perf.hist.N\n" "t Zoom into current Thread\n"
@@ -3053,6 +3054,31 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,* go to the next or previous */ goto out_free_stack; + case '0' ... '9': +if (!symbol_conf.event_group || + evsel->core.nr_members <2 ) { +snprintf (buf,sizeof (buf), +"Sort by index only available with group events!" ); + helpline = buf; +continue ; + } + +if (key -'0' == symbol_conf.group_sort_idx) +continue ; + + symbol_conf.group_sort_idx = key -'0' ; + +if (symbol_conf.group_sort_idx >= evsel->core.nr_members) { +snprintf (buf,sizeof (buf), +"Max event group index to sort is %d (index from 0 to %d)" , + evsel->core.nr_members -1 , + evsel->core.nr_members -1 ); + helpline = buf; +continue ; + } + + key =K_RELOAD ; + goto out_free_stack;case 'a' :if (!hists__has (hists, sym)) { ui_browser__warning(&browser->b, delay_secs * 2,
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 9/24 perf stat: Align the output for interval aggregation mode
In reply to Arnaldo Carvalho de MeloFrom: Jin Yao <[email protected]>
There is a slight misalignment in -A -I output.
For example:
# perf stat -e cpu/event=cpu-cycles/ -a -A -I 1000
# time CPU counts unit events
1.000440863 CPU0 1,068,388 cpu/event=cpu-cycles/
1.000440863 CPU1 875,954 cpu/event=cpu-cycles/
1.000440863 CPU2 3,072,538 cpu/event=cpu-cycles/
1.000440863 CPU3 4,026,870 cpu/event=cpu-cycles/
1.000440863 CPU4 5,919,630 cpu/event=cpu-cycles/
1.000440863 CPU5 2,714,260 cpu/event=cpu-cycles/
1.000440863 CPU6 2,219,240 cpu/event=cpu-cycles/
1.000440863 CPU7 1,299,232 cpu/event=cpu-cycles/The value of counts is not aligned with the column "counts" and the event name is not aligned with the column "events".
With this patch, the output is,
# perf stat -e cpu/event=cpu-cycles/ -a -A -I 1000
# time CPU counts unit events
1.000423009 CPU0 997,421 cpu/event=cpu-cycles/
1.000423009 CPU1 1,422,042 cpu/event=cpu-cycles/
1.000423009 CPU2 484,651 cpu/event=cpu-cycles/
1.000423009 CPU3 525,791 cpu/event=cpu-cycles/
1.000423009 CPU4 1,370,100 cpu/event=cpu-cycles/
1.000423009 CPU5 442,072 cpu/event=cpu-cycles/
1.000423009 CPU6 205,643 cpu/event=cpu-cycles/
1.000423009 CPU7 1,302,250 cpu/event=cpu-cycles/Now output is aligned.
--- tools/perf/util/stat-display.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/util/stat-display.c +3 -3
@@ -115,11 +115,11 @@ static void aggr_printout(struct perf_stat_config *config,fprintf (config->output,"S%d-D%d-C%*d%s" ,cpu_map__id_to_socket (id),cpu_map__id_to_die (id), - config->csv_output ?0 :-5 , + config->csv_output ?0 :-3 ,cpu_map__id_to_cpu (id), config->csv_sep); }else { -fprintf (config->output,"CPU%*d%s " , - config->csv_output ?0 :-5 , +fprintf (config->output,"CPU%*d%s" , + config->csv_output ?0 :-7 ,evsel__cpus (evsel)->map[id], config->csv_sep); }
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 10/24 perf metricgroup: Fix printing event names of metric group with multiple events incase of overlapping events
In reply to Arnaldo Carvalho de MeloFrom: Kajol Jain <[email protected]>
Commit f01642e4912b ("perf metricgroup: Support multiple events for metricgroup") introduced support for multiple events in a metric group. But with the current upstream, metric events names are not printed properly incase we try to run multiple metric groups with overlapping event.
With current upstream version, incase of overlapping metric events issue is, we always start our comparision logic from start. So, the events which already matched with some metric group also take part in comparision logic. Because of that when we have overlapping events, we end up matching current metric group event with already matched one.
For example, in skylake machine we have metric event CoreIPC and Instructions. Both of them need 'inst_retired.any' event value. As events in Instructions is subset of events in CoreIPC, they endup in pointing to same 'inst_retired.any' value.
In skylake platform:
command:# ./perf stat -M CoreIPC,Instructions -C 0 sleep 1
Performance counter stats for 'CPU(s) 0':
1,254,992,790 inst_retired.any # 1254992790.0
Instructions
# 1.3 CoreIPC
977,172,805 cycles
1,254,992,756 inst_retired.any
1.000802596 seconds time elapsedcommand:# sudo ./perf stat -M UPI,IPC sleep 1
Performance counter stats for 'sleep 1':
948,650 uops_retired.retire_slots
866,182 inst_retired.any # 0.7 IPC
866,182 inst_retired.any
1,175,671 cpu_clk_unhalted.threadPatch fixes the issue by adding a new bool pointer 'evlist_used' to keep track of events which already matched with some group by setting it true. So, we skip all used events in list when we start comparision logic. Patch also make some changes in comparision logic, incase we get a match miss, we discard the whole match and start again with first event id in metric event.
With this patch:
In skylake platform:
command:# ./perf stat -M CoreIPC,Instructions -C 0 sleep 1
Performance counter stats for 'CPU(s) 0':
3,348,415 inst_retired.any # 0.3 CoreIPC
11,779,026 cycles
3,348,381 inst_retired.any # 3348381.0
Instructions
1.001649056 seconds time elapsedcommand:# ./perf stat -M UPI,IPC sleep 1
Performance counter stats for 'sleep 1':
1,023,148 uops_retired.retire_slots # 1.1 UPI
924,976 inst_retired.any
924,976 inst_retired.any # 0.6 IPC
1,489,414 cpu_clk_unhalted.thread1.003064672 seconds time elapsed
--- tools/perf/util/metricgroup.c | 49 +++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 19 deletions(-)
tools/perf/util/metricgroup.c +30 -19
@@ -95,13 +95,16 @@ struct egroup {static struct evsel *find_evsel_group (struct evlist *perf_evlist,const char **ids,int idnum, -struct evsel **metric_events) +struct evsel **metric_events, +bool *evlist_used) {struct evsel *ev; -int i =0 ; +int i =0 , j =0 ;bool leader_found; evlist__for_each_entry (perf_evlist, ev) { +if (evlist_used[j++]) +continue ;if (!strcmp (ev->name, ids[i])) {if (!metric_events[i]) metric_events[i] = ev;
@@ -109,22 +112,17 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,if (i == idnum)break ; }else { -if (i +1 == idnum) { -/* Discard the whole match and start again */ - i =0 ; -memset (metric_events,0 , -sizeof (struct evsel *) * idnum); -continue ; - } - -if (!strcmp (ev->name, ids[i])) - metric_events[i] = ev; -else { -/* Discard the whole match and start again */ - i =0 ; -memset (metric_events,0 , -sizeof (struct evsel *) * idnum); -continue ; +/* Discard the whole match and start again */ + i =0 ; +memset (metric_events,0 , +sizeof (struct evsel *) * idnum); + +if (!strcmp (ev->name, ids[i])) { +if (!metric_events[i]) + metric_events[i] = ev; + i++; +if (i == idnum) +break ; } } }
@@ -146,7 +144,10 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist, !strcmp(ev->name, metric_events[i]->name)) { ev->metric_leader = metric_events[i]; } + j++; } + ev = metric_events[i]; + evlist_used[ev->idx] = true; }return metric_events[0 ];
@@ -162,6 +163,13 @@ static int metricgroup__setup_events(struct list_head *groups,int ret =0 ;struct egroup *eg;struct evsel *evsel; +bool *evlist_used; + + evlist_used =calloc (perf_evlist->core.nr_entries,sizeof (bool )); +if (!evlist_used) { + ret = -ENOMEM ; +return ret; + } list_for_each_entry (eg, groups, nd) {struct evsel **metric_events;
@@ -172,7 +180,7 @@ static int metricgroup__setup_events(struct list_head *groups,break ; } evsel =find_evsel_group (perf_evlist, eg->ids, eg->idnum, - metric_events); + metric_events, evlist_used);if (!evsel) {pr_debug ("Cannot resolve %s: %s\n" , eg->metric_name, eg->metric_expr);
@@ -196,6 +204,9 @@ static int metricgroup__setup_events(struct list_head *groups, expr->metric_events = metric_events;list_add (&expr->nd, &me->head); } + +free (evlist_used); +return ret; }
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 11/24 perf vendor events amd: Restrict model detection for zen1 based processors
In reply to Arnaldo Carvalho de MeloFrom: Vijay Thakkar <[email protected]>
This patch changes the previous blanket detection of AMD Family 17h processors to be more specific to Zen1 core based products only by replacing model detection regex pattern [[:xdigit:]]+ with ([12][0-9A-F]|[0-9A-F]), restricting to models 0 though 2f only.
This change is required to allow for the addition of separate PMU events for Zen2 core based models in the following patches as those belong to family 17h but have different PMCs. Current PMU events directory has also been renamed to "amdzen1" from "amdfam17h" to reflect this specificity.
Note that although this change does not break PMU counters for existing zen1 based systems, it does disable the current set of counters for zen2 based systems. Counters for zen2 have been added in the following patches in this patchset.
---
.../perf/pmu-events/arch/x86/{amdfam17h => amdzen1}/branch.json | 0
.../perf/pmu-events/arch/x86/{amdfam17h => amdzen1}/cache.json | 0
tools/perf/pmu-events/arch/x86/{amdfam17h => amdzen1}/core.json | 0
.../arch/x86/{amdfam17h => amdzen1}/floating-point.json | 0
.../perf/pmu-events/arch/x86/{amdfam17h => amdzen1}/memory.json | 0
.../perf/pmu-events/arch/x86/{amdfam17h => amdzen1}/other.json | 0
tools/perf/pmu-events/arch/x86/mapfile.csv | 2 +-
7 files changed, 1 insertion(+), 1 deletion(-)
rename tools/perf/pmu-events/arch/x86/{amdfam17h => amdzen1}/branch.json (100%)
rename tools/perf/pmu-events/arch/x86/{amdfam17h => amdzen1}/cache.json (100%)
rename tools/perf/pmu-events/arch/x86/{amdfam17h => amdzen1}/core.json (100%)
rename tools/perf/pmu-events/arch/x86/{amdfam17h => amdzen1}/floating-point.json (100%)
rename tools/perf/pmu-events/arch/x86/{amdfam17h => amdzen1}/memory.json (100%)
rename tools/perf/pmu-events/arch/x86/{amdfam17h => amdzen1}/other.json (100%)tools/perf/pmu-events/arch/x86/amdzen1/branch.json renamed from tools/perf/pmu-events/arch/x86/amdfam17h/branch.json +0 -0
tools/perf/pmu-events/arch/x86/amdzen1/cache.json renamed from tools/perf/pmu-events/arch/x86/amdfam17h/cache.json +0 -0
tools/perf/pmu-events/arch/x86/amdzen1/core.json renamed from tools/perf/pmu-events/arch/x86/amdfam17h/core.json +0 -0
tools/perf/pmu-events/arch/x86/amdzen1/floating-point.json renamed from tools/perf/pmu-events/arch/x86/amdfam17h/floating-point.json +0 -0
tools/perf/pmu-events/arch/x86/amdzen1/memory.json renamed from tools/perf/pmu-events/arch/x86/amdfam17h/memory.json +0 -0
tools/perf/pmu-events/arch/x86/amdzen1/other.json renamed from tools/perf/pmu-events/arch/x86/amdfam17h/other.json +0 -0
tools/perf/pmu-events/arch/x86/mapfile.csv +1 -1
@@ -36,4 +36,4 @@ GenuineIntel-6-55-[56789ABCDEF],v1,cascadelakex,core GenuineIntel-6-7D,v1,icelake,core GenuineIntel-6-7E,v1,icelake,core GenuineIntel-6-86,v1,tremontx,core -AuthenticAMD-23-[[:xdigit:]]+,v1,amdfam17h,core +AuthenticAMD-23-([12][0-9A-F]|[0-9A-F]),v1,amdzen1,core
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 12/24 perf vendor events amd: Add Zen2 events
In reply to Arnaldo Carvalho de MeloFrom: Vijay Thakkar <[email protected]>
This patch adds PMU events for AMD Zen2 core based processors, namely, Matisse (model 71h), Castle Peak (model 31h) and Rome (model 2xh), as documented in the AMD Processor Programming Reference for Matisse [1]. The model number regex has been set to detect all the models under family 17 that do not match those of Zen1, as the range is larger for zen2.
Zen2 adds some additional counters that are not present in Zen1 and events for them have been added in this patch. Some counters have also been removed for Zen2 thatwere previously present in Zen1 and have been confirmed to always sample zero on zen2. These added/removed counters have been omitted for brevity but can be found here:
https://gist.github.com/thakkarV/5b12ca5fd7488eb2c42e451e40bdd5f3
Note that PPR for Zen2 [1] does not include some counters that were documented in the PPR for Zen1 based processors [2]. After having tested these counters, some of them that still work for zen2 systems have been preserved in the events for zen2. The counters that are omitted in [1] but are still measurable and non-zero on zen2 (tested on a Ryzen 3900X system) are the following:
PMC 0x000 fpu_pipe_assignment.{total|total0|total1|total2|total3} PMC 0x004 fp_num_mov_elim_scal_op.*
PMC 0x046 ls_tablewalker.*
PMC 0x062 l2_latency.l2_cycles_waiting_on_fills
PMC 0x063 l2_wcb_req.*
PMC 0x06D l2_fill_pending.l2_fill_busy
PMC 0x080 ic_fw32
PMC 0x081 ic_fw32_miss
PMC 0x086 bp_snp_re_sync
PMC 0x087 ic_fetch_stall.*
PMC 0x08C ic_cache_inval.*
PMC 0x099 bp_tlb_rel
PMC 0x0C7 ex_ret_brn_resync
PMC 0x28A ic_oc_mode_switch.*
L3PMC 0x001 l3_request_g1.*
L3PMC 0x006 l3_comb_clstr_state.*
[1]: Processor Programming Reference (PPR) for AMD Family 17h Model 71h, Revision B0 Processors, 56176 Rev 3.06 - Jul 17, 2019
[2]: Processor Programming Reference (PPR) for AMD Family 17h Models 01h,08h, Revision B2 Processors, 54945 Rev 3.03 - Jun 14, 2019
All of the PPRs can be found at:
https://bugzilla.kernel.org/show_bug.cgi?id=206537
Here are the results of running "fpu_pipe_assignment.total" events on my Ryzen 3900X family 17h model 71h system:
Before this patch:
$> perf list *fpu_pipe_assignment*
List of pre-defined events (to be used in -e):
After:
$> perf list *fpu_pipe_assignment*
floating point:
fpu_pipe_assignment.total
[Total number of fp uOps]
fpu_pipe_assignment.total0
[Total number uOps assigned to pipe 0]
fpu_pipe_assignment.total1
[Total number uOps assigned to pipe 1]
fpu_pipe_assignment.total2
[Total number uOps assigned to pipe 2]
fpu_pipe_assignment.total3
[Total number uOps assigned to pipe 3]
Metric Groups:
$> perf stat -e fpu_pipe_assignment.total sleep 1
Performance counter stats for 'sleep 1':
25,883 fpu_pipe_assignment.total
1.004145868 seconds time elapsed
0.001805000 seconds user
0.000000000 seconds sysUsage tests while running Linpackin the background:
$> perf stat -I1000 -e fpu_pipe_assignment.total
1.000266796 79,313,191,516 fpu_pipe_assignment.total
2.000809630 68,091,474,430 fpu_pipe_assignment.total
3.001028115 52,925,023,174 fpu_pipe_assignment.total $> perf record -e fpu_pipe_assignment.total,fpu_pipe_assignment.total0 -a sleep 1 [ perf record: Woken up 9 times to write data ]
[ perf record: Captured and wrote 4.031 MB perf.data (64764 samples) ]
$> perf report --stdio --no-header | head -30
98.33% xhpl xhpl [.] dgemm_kernel
0.28% xhpl xhpl [.] dtrsm_kernel_LT
0.10% xhpl [kernel.kallsyms] [k] entry_SYSCALL_64
0.08% xhpl xhpl [.] idamax_k
0.07% baloo_file_extr liblmdb.so [.] mdb_mid2l_insert
0.06% xhpl xhpl [.] dgemm_itcopy
0.06% xhpl xhpl [.] dgemm_oncopy
0.06% xhpl [kernel.kallsyms] [k] __schedule
0.06% xhpl [kernel.kallsyms] [k] syscall_trace_enter
0.06% xhpl [kernel.kallsyms] [k] native_sched_clock
0.06% xhpl [kernel.kallsyms] [k] pick_next_task_fair
0.05% xhpl xhpl [.] blas_thread_server.llvm.15009391670273914865
0.04% xhpl [kernel.kallsyms] [k] do_syscall_64
0.04% xhpl [kernel.kallsyms] [k] yield_task_fair
0.04% xhpl libpthread-2.31.so [.] __pthread_mutex_unlock_usercnt
0.03% xhpl [kernel.kallsyms] [k] cpuacct_charge
0.03% xhpl [kernel.kallsyms] [k] syscall_return_via_sysret
0.03% xhpl libc-2.31.so [.] __sched_yield
0.03% xhpl [kernel.kallsyms] [k] __calc_delta
$> perf annotate --stdio2 dgemm_kernel | egrep '^ {0,2}[0-9]+' -B2 -A2
sub $0x60,%rsp
mov %rbx,(%rsp)
0.00 mov %rbp,0x8(%rsp)
mov %r12,0x10(%rsp)
0.00 mov %r13,0x18(%rsp)
mov %r14,0x20(%rsp)
mov %r15,0x28(%rsp)
--
mov %rdi,%r13
mov %rsi,0x28(%rsp)
0.00 mov %rdx,%r12
vmovsd %xmm0,0x30(%rsp)
shl $0x3,%r10
mov 0x28(%rsp),%rax
0.00 xor %rdx,%rdx
mov $0x18,%rdi
div %rdi
--
nop
a0: mov %r12,%rax
0.00 shl $0x3,%rax
mov %r8,%rdi
lea (%r8,%rax,8),%r15
--
mov %r12,%rax
nop
0.00 c0: vmovups (%rdi),%ymm1
0.09 vmovups 0x20(%rdi),%ymm2
0.02 vmovups (%r15),%ymm3
0.10 vmovups %ymm1,(%rsi)
0.07 vmovups %ymm2,0x20(%rsi)
0.07 vmovups %ymm3,0x40(%rsi)
0.06 add $0x40,%rdi
add $0x40,%r15
add $0x60,%rsi
0.00 dec %rax
↑ jne c0
mov %r9,%r15
--
nop
110: lea 0x80(%rsp),%rsi
0.01 add $0x60,%rsi
0.03 mov %r12,%rax
0.00 sar $0x3,%rax
cmp $0x2,%rax
↓ jl d26
prefetcht0 0x200(%rdi)
0.01 vmovups -0x60(%rsi),%ymm1
0.02 prefetcht0 0xa0(%rsi)
0.00 vbroadcastsd -0x80(%rdi),%ymm0
0.00 prefetcht0 0xe0(%rsi)
0.03 vmovups -0x40(%rsi),%ymm2
0.00 prefetcht0 0x120(%rsi)
vmovups -0x20(%rsi),%ymm3
vmulpd %ymm0,%ymm1,%ymm4
0.01 prefetcht0 0x160(%rsi)
vmulpd %ymm0,%ymm2,%ymm8
0.01 vmulpd %ymm0,%ymm3,%ymm12
0.02 prefetcht0 0x1a0(%rsi)
0.01 vbroadcastsd -0x78(%rdi),%ymm0
vmulpd %ymm0,%ymm1,%ymm5
0.01 vmulpd %ymm0,%ymm2,%ymm9
vmulpd %ymm0,%ymm3,%ymm13
0.01 vbroadcastsd -0x70(%rdi),%ymm0
vmulpd %ymm0,%ymm1,%ymm6
0.00 vmulpd %ymm0,%ymm2,%ymm10
0.00 add $0x60,%rsi... snip ...
nop
65e0: vmovddup -0x60(%rsi),%xmm2
0.00 vmovups -0x80(%rdi),%xmm0
vmovups -0x70(%rdi),%xmm1
0.00 vmovddup -0x58(%rsi),%xmm3
vfmadd231pd %xmm0,%xmm2,%xmm4
0.00 vfmadd231pd %xmm1,%xmm2,%xmm5
0.00 vfmadd231pd %xmm0,%xmm3,%xmm6
0.00 vfmadd231pd %xmm1,%xmm3,%xmm7
0.00 add $0x10,%rsi
add $0x20,%rdi
0.00 dec %rax
↑ jne 65e0
nop
nop
6620: vmovddup 0x30(%rsp),%xmm0
0.00 vmulpd %xmm0,%xmm4,%xmm4
0.00 vmulpd %xmm0,%xmm5,%xmm5
vmulpd %xmm0,%xmm6,%xmm6
vmulpd %xmm0,%xmm7,%xmm7
vaddpd (%r15),%xmm4,%xmm4
vaddpd 0x10(%r15),%xmm5,%xmm5
0.00 vaddpd (%r15,%r10,1),%xmm6,%xmm6
0.00 vaddpd 0x10(%r15,%r10,1),%xmm7,%xmm7
0.00 vmovups %xmm4,(%r15)
vmovups %xmm5,0x10(%r15)
0.00 vmovups %xmm6,(%r15,%r10,1)
vmovups %xmm7,0x10(%r15,%r10,1)
add $0x20,%r15
--
lea (%r8,%rax,8),%r8
69d8: mov 0x20(%rsp),%r14
0.00 test $0x1,%r14
↓ je 6d84
mov %r9,%r15
--
vbroadcastsd -0x28(%rsi),%ymm3
vfmadd231pd (%rdi),%ymm0,%ymm4
0.00 vfmadd231pd 0x20(%rdi),%ymm1,%ymm5
vfmadd231pd 0x40(%rdi),%ymm2,%ymm6
vfmadd231pd 0x60(%rdi),%ymm3,%ymm7
--
vmulpd %ymm0,%ymm4,%ymm4
vaddpd (%r15),%ymm4,%ymm4
0.00 vmovups %ymm4,(%r15)
add $0x20,%r15
dec %r11
--
mov %rbx,%rsp
mov (%rsp),%rbx
0.01 mov 0x8(%rsp),%rbp
mov 0x10(%rsp),%r12
mov 0x18(%rsp),%r13--- .../pmu-events/arch/x86/amdzen2/branch.json | 52 +++ .../pmu-events/arch/x86/amdzen2/cache.json | 338 +++++++++++++++++ .../pmu-events/arch/x86/amdzen2/core.json | 130 +++++++ .../arch/x86/amdzen2/floating-point.json | 140 +++++++ .../pmu-events/arch/x86/amdzen2/memory.json | 341 ++++++++++++++++++ .../pmu-events/arch/x86/amdzen2/other.json | 115 ++++++ tools/perf/pmu-events/arch/x86/mapfile.csv | 1 + 7 files changed, 1117 insertions(+) create mode 100644 tools/perf/pmu-events/arch/x86/amdzen2/branch.json create mode 100644 tools/perf/pmu-events/arch/x86/amdzen2/cache.json create mode 100644 tools/perf/pmu-events/arch/x86/amdzen2/core.json create mode 100644 tools/perf/pmu-events/arch/x86/amdzen2/floating-point.json create mode 100644 tools/perf/pmu-events/arch/x86/amdzen2/memory.json create mode 100644 tools/perf/pmu-events/arch/x86/amdzen2/other.json
tools/perf/pmu-events/arch/x86/amdzen2/branch.json new file +52 -0
@@ -0,0 +1,52 @@ +[ + { + "EventName": "bp_l1_btb_correct", + "EventCode": "0x8a", + "BriefDescription": "L1 Branch Prediction Overrides Existing Prediction (speculative)." + }, + { + "EventName": "bp_l2_btb_correct", + "EventCode": "0x8b", + "BriefDescription": "L2 Branch Prediction Overrides Existing Prediction (speculative)." + }, + { + "EventName": "bp_dyn_ind_pred", + "EventCode": "0x8e", + "BriefDescription": "Dynamic Indirect Predictions.", + "PublicDescription": "Indirect Branch Prediction for potential multi-target branch (speculative)." + }, + { + "EventName": "bp_de_redirect", + "EventCode": "0x91", + "BriefDescription": "Decoder Overrides Existing Branch Prediction (speculative)." + }, + { + "EventName": "bp_l1_tlb_fetch_hit", + "EventCode": "0x94", + "BriefDescription": "The number of instruction fetches that hit in the L1 ITLB.", + "UMask": "0xFF" + }, + { + "EventName": "bp_l1_tlb_fetch_hit.if1g", + "EventCode": "0x94", + "BriefDescription": "The number of instruction fetches that hit in the L1 ITLB. Instruction fetches to a 1GB page.", + "UMask": "0x4" + }, + { + "EventName": "bp_l1_tlb_fetch_hit.if2m", + "EventCode": "0x94", + "BriefDescription": "The number of instruction fetches that hit in the L1 ITLB. Instruction fetches to a 2MB page.", + "UMask": "0x2" + }, + { + "EventName": "bp_l1_tlb_fetch_hit.if4k", + "EventCode": "0x94", + "BriefDescription": "The number of instruction fetches that hit in the L1 ITLB. Instruction fetches to a 4KB page.", + "UMask": "0x1" + }, + { + "EventName": "bp_tlb_rel", + "EventCode": "0x99", + "BriefDescription": "The number of ITLB reload requests." + } +]
tools/perf/pmu-events/arch/x86/amdzen2/cache.json new file +338 -0
338 lines not on this page · raw message
tools/perf/pmu-events/arch/x86/amdzen2/core.json new file +130 -0
130 lines not on this page · raw message
tools/perf/pmu-events/arch/x86/amdzen2/floating-point.json new file +140 -0
140 lines not on this page · raw message
tools/perf/pmu-events/arch/x86/amdzen2/memory.json new file +341 -0
341 lines not on this page · raw message
tools/perf/pmu-events/arch/x86/amdzen2/other.json new file +115 -0
115 lines not on this page · raw message
tools/perf/pmu-events/arch/x86/mapfile.csv +1 -0
@@ -37,3 +37,4 @@ GenuineIntel-6-7D,v1,icelake,core GenuineIntel-6-7E,v1,icelake,core GenuineIntel-6-86,v1,tremontx,core AuthenticAMD-23-([12][0-9A-F]|[0-9A-F]),v1,amdzen1,core +AuthenticAMD-23-[[:xdigit:]]+,v1,amdzen2,core
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 13/24 perf vendor events amd: Update Zen1 events to V2
In reply to Arnaldo Carvalho de MeloFrom: Vijay Thakkar <[email protected]>
This patch updates the PMCs for AMD Zen1 core based processors (Family 17h; Models 0 through 2F) to be in accordance with PMCs as documented in the latest versions of the AMD Processor Programming Reference [1], [2] and [3]. Note that some events, such as FPU pipe assignment are missing in [1], and therefore [3] is included for full coverage of events.
PMCs added:
fpu_pipe_assignment.dual{0|1|2|3}
fpu_pipe_assignment.total{0|1|2|3}
ls_mab_alloc.dc_prefetcher
ls_mab_alloc.stores
ls_mab_alloc.loads
bp_dyn_ind_pred
bp_de_redirect
PMC removed:
ex_ret_cond_misp
Cumulative counts, fpu_pipe_assignment.total and fpu_pipe_assignment.dual, existed in v1, but did expose port-level counters.
ex_ret_cond_misp has been removed as it has been removed from the latest versions of the PPR, and when tested, always seems to sample zero as tested on a Ryzen 3400G system.
[1]: Processor Programming Reference (PPR) for AMD Family 17h Models 01h,08h, Revision B2 Processors, 54945 Rev 3.03 - Jun 14, 2019.
[2]: Processor Programming Reference (PPR) for AMD Family 17h Model 18h, Revision B1 Processors, 55570-B1 Rev 3.14 - Sep 26, 2019.
[3]: OSRR for AMD Family 17h processors, Models 00h-2Fh, 56255 Rev 3.03 - July, 2018
All of the PPRs can be found at:
https://bugzilla.kernel.org/show_bug.cgi?id=206537
--- .../pmu-events/arch/x86/amdzen1/branch.json | 11 ++ .../pmu-events/arch/x86/amdzen1/cache.json | 107 ++++++------------ .../pmu-events/arch/x86/amdzen1/core.json | 15 +-- .../arch/x86/amdzen1/floating-point.json | 64 ++++++++++- .../pmu-events/arch/x86/amdzen1/memory.json | 82 +++++++++----- .../pmu-events/arch/x86/amdzen1/other.json | 27 ++--- tools/perf/pmu-events/arch/x86/mapfile.csv | 2 +- 7 files changed, 172 insertions(+), 136 deletions(-)
tools/perf/pmu-events/arch/x86/amdzen1/branch.json +11 -0
@@ -8,5 +8,16 @@ "EventName": "bp_l2_btb_correct", "EventCode": "0x8b", "BriefDescription": "L2 BTB Correction." + }, + { + "EventName": "bp_dyn_ind_pred", + "EventCode": "0x8e", + "BriefDescription": "Dynamic Indirect Predictions.", + "PublicDescription": "Indirect Branch Prediction for potential multi-target branch (speculative)." + }, + { + "EventName": "bp_de_redirect", + "EventCode": "0x91", + "BriefDescription": "Decoder Overrides Existing Branch Prediction (speculative)." } ]
tools/perf/pmu-events/arch/x86/amdzen1/cache.json +36 -71
283 lines not on this page · raw message
tools/perf/pmu-events/arch/x86/amdzen1/core.json +3 -12
@@ -62,7 +62,6 @@ "EventName": "ex_ret_brn_ind_misp", "EventCode": "0xca", "BriefDescription": "Retired Indirect Branch Instructions Mispredicted.", - "PublicDescription": "Retired Indirect Branch Instructions Mispredicted." }, { "EventName": "ex_ret_mmx_fp_instr.sse_instr",
@@ -90,11 +89,6 @@ "EventCode": "0xd1", "BriefDescription": "Retired Conditional Branch Instructions." }, - { - "EventName": "ex_ret_cond_misp", - "EventCode": "0xd2", - "BriefDescription": "Retired Conditional Branch Instructions Mispredicted." - }, { "EventName": "ex_div_busy", "EventCode": "0xd3",
@@ -108,22 +102,19 @@ { "EventName": "ex_tagged_ibs_ops.ibs_count_rollover", "EventCode": "0x1cf", - "BriefDescription": "Number of times an op could not be tagged by IBS because of a previous tagged op that has not retired.", - "PublicDescription": "Tagged IBS Ops. Number of times an op could not be tagged by IBS because of a previous tagged op that has not retired.", + "BriefDescription": "Tagged IBS Ops. Number of times an op could not be tagged by IBS because of a previous tagged op that has not retired.", "UMask": "0x4" }, { "EventName": "ex_tagged_ibs_ops.ibs_tagged_ops_ret", "EventCode": "0x1cf", - "BriefDescription": "Number of Ops tagged by IBS that retired.", - "PublicDescription": "Tagged IBS Ops. Number of Ops tagged by IBS that retired.", + "BriefDescription": "Tagged IBS Ops. Number of Ops tagged by IBS that retired.", "UMask": "0x2" }, { "EventName": "ex_tagged_ibs_ops.ibs_tagged_ops", "EventCode": "0x1cf", - "BriefDescription": "Number of Ops tagged by IBS.", - "PublicDescription": "Tagged IBS Ops. Number of Ops tagged by IBS.", + "BriefDescription": "Tagged IBS Ops. Number of Ops tagged by IBS.", "UMask": "0x1" }, {
tools/perf/pmu-events/arch/x86/amdzen1/floating-point.json +60 -4
77 lines not on this page · raw message
tools/perf/pmu-events/arch/x86/amdzen1/memory.json +52 -30
198 lines not on this page · raw message
tools/perf/pmu-events/arch/x86/amdzen1/other.json +9 -18
@@ -2,64 +2,55 @@ { "EventName": "ic_oc_mode_switch.oc_ic_mode_switch", "EventCode": "0x28a", - "BriefDescription": "OC to IC mode switch.", - "PublicDescription": "OC Mode Switch. OC to IC mode switch.", + "BriefDescription": "OC Mode Switch. OC to IC mode switch.", "UMask": "0x2" }, { "EventName": "ic_oc_mode_switch.ic_oc_mode_switch", "EventCode": "0x28a", - "BriefDescription": "IC to OC mode switch.", - "PublicDescription": "OC Mode Switch. IC to OC mode switch.", + "BriefDescription": "OC Mode Switch. IC to OC mode switch.", "UMask": "0x1" }, { "EventName": "de_dis_dispatch_token_stalls0.retire_token_stall", "EventCode": "0xaf", - "BriefDescription": "RETIRE Tokens unavailable.", - "PublicDescription": "Cycles where a dispatch group is valid but does not get dispatched due to a token stall. RETIRE Tokens unavailable.", + "BriefDescription": "Cycles where a dispatch group is valid but does not get dispatched due to a token stall. RETIRE Tokens unavailable.", "UMask": "0x40" }, { "EventName": "de_dis_dispatch_token_stalls0.agsq_token_stall", "EventCode": "0xaf", - "BriefDescription": "AGSQ Tokens unavailable.", - "PublicDescription": "Cycles where a dispatch group is valid but does not get dispatched due to a token stall. AGSQ Tokens unavailable.", + "BriefDescription": "Cycles where a dispatch group is valid but does not get dispatched due to a token stall. AGSQ Tokens unavailable.", "UMask": "0x20" }, { "EventName": "de_dis_dispatch_token_stalls0.alu_token_stall", "EventCode": "0xaf", - "BriefDescription": "ALU tokens total unavailable.", - "PublicDescription": "Cycles where a dispatch group is valid but does not get dispatched due to a token stall. ALU tokens total unavailable.", + "BriefDescription": "Cycles where a dispatch group is valid but does not get dispatched due to a token stall. ALU tokens total unavailable.", "UMask": "0x10" }, { "EventName": "de_dis_dispatch_token_stalls0.alsq3_0_token_stall", "EventCode": "0xaf", - "BriefDescription": "Cycles where a dispatch group is valid but does not get dispatched due to a token stall.", - "PublicDescription": "Cycles where a dispatch group is valid but does not get dispatched due to a token stall.", + "BriefDescription": "Cycles where a dispatch group is valid but does not get dispatched due to a token stall. ALSQ 3_0 Tokens unavailable.", "UMask": "0x8" }, { "EventName": "de_dis_dispatch_token_stalls0.alsq3_token_stall", "EventCode": "0xaf", - "BriefDescription": "ALSQ 3 Tokens unavailable.", - "PublicDescription": "Cycles where a dispatch group is valid but does not get dispatched due to a token stall. ALSQ 3 Tokens unavailable.", + "BriefDescription": "Cycles where a dispatch group is valid but does not get dispatched due to a token stall. ALSQ 3 Tokens unavailable.", "UMask": "0x4" }, { "EventName": "de_dis_dispatch_token_stalls0.alsq2_token_stall", "EventCode": "0xaf", - "BriefDescription": "ALSQ 2 Tokens unavailable.", - "PublicDescription": "Cycles where a dispatch group is valid but does not get dispatched due to a token stall. ALSQ 2 Tokens unavailable.", + "BriefDescription": "Cycles where a dispatch group is valid but does not get dispatched due to a token stall. ALSQ 2 Tokens unavailable.", "UMask": "0x2" }, { "EventName": "de_dis_dispatch_token_stalls0.alsq1_token_stall", "EventCode": "0xaf", - "BriefDescription": "ALSQ 1 Tokens unavailable.", - "PublicDescription": "Cycles where a dispatch group is valid but does not get dispatched due to a token stall. ALSQ 1 Tokens unavailable.", + "BriefDescription": "Cycles where a dispatch group is valid but does not get dispatched due to a token stall. ALSQ 1 Tokens unavailable.", "UMask": "0x1" } ]
tools/perf/pmu-events/arch/x86/mapfile.csv +1 -1
@@ -36,5 +36,5 @@ GenuineIntel-6-55-[56789ABCDEF],v1,cascadelakex,core GenuineIntel-6-7D,v1,icelake,core GenuineIntel-6-7E,v1,icelake,core GenuineIntel-6-86,v1,tremontx,core -AuthenticAMD-23-([12][0-9A-F]|[0-9A-F]),v1,amdzen1,core +AuthenticAMD-23-([12][0-9A-F]|[0-9A-F]),v2,amdzen1,core AuthenticAMD-23-[[:xdigit:]]+,v1,amdzen2,core
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 14/24 tools headers uapi: Update linux/in.h copy
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To get the changes in:
267762538705 ("seg6: fix SRv6 L2 tunnels to use IANA-assigned protocol number")
That ends up automatically adding the new IPPROTO_ETHERNET to the socket args beautifiers:
$ tools/perf/trace/beauty/socket_ipproto.sh > before
Apply this patch:
$ tools/perf/trace/beauty/socket_ipproto.sh > after $ diff -u before after --- before 2020-03-19 11:48:36.876673819 -0300 +++ after 2020-03-19 11:49:00.148541377 -0300 @@ -6,6 +6,7 @@ [132] = "SCTP", [136] = "UDPLITE", [137] = "MPLS", + [143] = "ETHERNET", [17] = "UDP", [1] = "ICMP", [22] = "IDP", $
Addresses this tools/perf build warning:
Warning: Kernel ABI header at 'tools/include/uapi/linux/in.h' differs from latest version at 'include/uapi/linux/in.h' diff -u tools/include/uapi/linux/in.h include/uapi/linux/in.h
--- tools/include/uapi/linux/in.h | 2 ++ 1 file changed, 2 insertions(+)
tools/include/uapi/linux/in.h +2 -0
@@ -74,6 +74,8 @@ enum {#define IPPROTO_UDPLITE IPPROTO_UDPLITE IPPROTO_MPLS = 137, /* MPLS in IP (RFC 4023) */#define IPPROTO_MPLS IPPROTO_MPLS + IPPROTO_ETHERNET = 143, /* Ethernet-within-IPv6 Encapsulation */ +#define IPPROTO_ETHERNET IPPROTO_ETHERNET IPPROTO_RAW = 255, /* Raw IP packets */#define IPPROTO_RAW IPPROTO_RAW IPPROTO_MPTCP = 262, /* Multipath TCP connection */
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 15/24 perf tools: Unify a bit the build directory output
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Removing the extra 'SUBDIR' line from clean and doc build output. Because it's annoying.. ;-)
Before:
$ make clean ... SUBDIR Documentation CLEAN Documentation
After:
$ make clean ... CLEAN Documentation
Before:
$ make doc BUILD: Doing 'make -j8' parallel build SUBDIR Documentation ASCIIDOC perf-stat.html ...
After:
$ make doc BUILD: Doing 'make -j8' parallel build ASCIIDOC perf-stat.html ...
--- tools/perf/Makefile.perf | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
tools/perf/Makefile.perf +5 -4
@@ -231,6 +231,7 @@ TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/ BPF_DIR = $(srctree)/tools/lib/bpf/ SUBCMD_DIR = $(srctree)/tools/lib/subcmd/ LIBPERF_DIR = $(srctree)/tools/lib/perf/ +DOC_DIR = $(srctree)/tools/perf/Documentation/ # Set FEATURE_TESTS to 'all' so all possible feature checkers are executed. # Without this setting the output feature dump file misses some features, for
@@ -792,7 +793,6 @@ $(LIBSUBCMD): FORCE $(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) $(OUTPUT)libsubcmd.a $(LIBSUBCMD)-clean: - $(call QUIET_CLEAN, libsubcmd) $(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) clean help:
@@ -832,7 +832,7 @@ INSTALL_DOC_TARGETS += quick-install-doc quick-install-man quick-install-html # 'make doc' should call 'make -C Documentation all' $(DOC_TARGETS): - $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:doc=all) + $(Q)$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) $(@:doc=all) TAG_FOLDERS= . ../lib ../include TAG_FILES= ../../include/uapi/linux/perf_event.h
@@ -959,7 +959,7 @@ install-python_ext: # 'make install-doc' should call 'make -C Documentation install' $(INSTALL_DOC_TARGETS): - $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) $(@:-doc=) + $(Q)$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) $(@:-doc=) ### Cleaning rules
@@ -1008,7 +1008,8 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea $(OUTPUT)$(rename_flags_array) \ $(OUTPUT)$(arch_errno_name_array) \ $(OUTPUT)$(sync_file_range_arrays) - $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean + $(call QUIET_CLEAN, Documentation) \ + $(MAKE) -C $(DOC_DIR) O=$(OUTPUT) clean >/dev/null # # To provide FEATURE-DUMP into $(FEATURE_DUMP_COPY)
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 16/24 perf jevents: Add some test events
In reply to Arnaldo Carvalho de MeloFrom: John Garry <[email protected]>
Add some test PMU events. The events are randomly chosen from x86 and arm64 JSONs. The events include CPU and uncore events.
--- .../pmu-events/arch/test/test_cpu/branch.json | 12 +++++++++ .../pmu-events/arch/test/test_cpu/other.json | 26 +++++++++++++++++++ .../pmu-events/arch/test/test_cpu/uncore.json | 21 +++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 tools/perf/pmu-events/arch/test/test_cpu/branch.json create mode 100644 tools/perf/pmu-events/arch/test/test_cpu/other.json create mode 100644 tools/perf/pmu-events/arch/test/test_cpu/uncore.json
tools/perf/pmu-events/arch/test/test_cpu/branch.json new file +12 -0
@@ -0,0 +1,12 @@ +[ + { + "EventName": "bp_l1_btb_correct", + "EventCode": "0x8a", + "BriefDescription": "L1 BTB Correction." + }, + { + "EventName": "bp_l2_btb_correct", + "EventCode": "0x8b", + "BriefDescription": "L2 BTB Correction." + } +]
tools/perf/pmu-events/arch/test/test_cpu/other.json new file +26 -0
@@ -0,0 +1,26 @@ +[ + { + "EventCode": "0x6", + "Counter": "0,1", + "UMask": "0x80", + "EventName": "SEGMENT_REG_LOADS.ANY", + "SampleAfterValue": "200000", + "BriefDescription": "Number of segment register loads." + }, + { + "EventCode": "0x9", + "Counter": "0,1", + "UMask": "0x20", + "EventName": "DISPATCH_BLOCKED.ANY", + "SampleAfterValue": "200000", + "BriefDescription": "Memory cluster signals to block micro-op dispatch for any reason" + }, + { + "EventCode": "0x3A", + "Counter": "0,1", + "UMask": "0x0", + "EventName": "EIST_TRANS", + "SampleAfterValue": "200000", + "BriefDescription": "Number of Enhanced Intel SpeedStep(R) Technology (EIST) transitions" + } +]
tools/perf/pmu-events/arch/test/test_cpu/uncore.json new file +21 -0
@@ -0,0 +1,21 @@ +[ + { + "EventCode": "0x02", + "EventName": "uncore_hisi_ddrc.flux_wcmd", + "BriefDescription": "DDRC write commands", + "PublicDescription": "DDRC write commands", + "Unit": "hisi_sccl,ddrc" + }, + { + "Unit": "CBO", + "EventCode": "0x22", + "UMask": "0x81", + "EventName": "UNC_CBO_XSNP_RESPONSE.MISS_EVICTION", + "BriefDescription": "A cross-core snoop resulted from L3 Eviction which misses in some processor core.", + "PublicDescription": "A cross-core snoop resulted from L3 Eviction which misses in some processor core.", + "Counter": "0,1", + "CounterMask": "0", + "Invert": "0", + "EdgeDetect": "0" + } +]
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 17/24 perf jevents: Support test events folder
In reply to Arnaldo Carvalho de MeloFrom: John Garry <[email protected]>
With the goal of supporting pmu-events test case, introduce support for a test events folder.
These test events can be used for testing generation of pmu-event tables and alias creation for any arch.
When running the pmu-events test case, these test events will be used as the platform-agnostic events, so aliases can be created per-PMU and validated against known expected values.
To support the test events, add a "testcpu" entry in pmu_events_map[]. The pmu-events test will be able to lookup the events map for "testcpu", to verify the generated tables against expected values.
The resultant generated pmu-events.c will now look like the following:
struct pmu_event pme_ampere_emag[] = {
{
.name = "ldrex_spec",
.event = "event=0x6c",
.desc = "Exclusive operation spe...",
.topic = "intrinsic",
.long_desc = "Exclusive operation ...",
},
...
};
struct pmu_event pme_test_cpu[] = {
{
.name = "uncore_hisi_ddrc.flux_wcmd",
.event = "event=0x2",
.desc = "DDRC write commands. Unit: hisi_sccl,ddrc ",
.topic = "uncore",
.long_desc = "DDRC write commands",
.pmu = "hisi_sccl,ddrc",
},
{
.name = "unc_cbo_xsnp_response.miss_eviction",
.event = "umask=0x81,event=0x22",
.desc = "Unit: uncore_cbox A cross-core snoop resulted ...",
.topic = "uncore",
.long_desc = "A cross-core snoop resulted from L3 ...",
.pmu = "uncore_cbox",
},
{
.name = "eist_trans",
.event = "umask=0x0,period=200000,event=0x3a",
.desc = "Number of Enhanced Intel SpeedStep(R) ...",
.topic = "other",
},
{
.name = 0,
},
};
struct pmu_events_map pmu_events_map[] = {
...
{
.cpuid = "0x00000000500f0000",
.version = "v1",
.type = "core",
.table = pme_ampere_emag
},
...
{
.cpuid = "testcpu",
.version = "v1",
.type = "core",
.table = pme_test_cpu,
},
{
.cpuid = 0,
.version = 0,
.type = 0,
.table = 0,
},
};--- tools/perf/pmu-events/jevents.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
tools/perf/pmu-events/jevents.c +30 -0
@@ -771,6 +771,19 @@ static void print_mapping_table_suffix(FILE *outfp)fprintf (outfp,"};\n" ); } +static void print_mapping_test_table (FILE *outfp) +{ +/* +* Print the terminating, NULL entry. +*/ +fprintf (outfp,"{\n" ); +fprintf (outfp,"\t.cpuid = \"testcpu\",\n" ); +fprintf (outfp,"\t.version = \"v1\",\n" ); +fprintf (outfp,"\t.type = \"core\",\n" ); +fprintf (outfp,"\t.table = pme_test_cpu,\n" ); +fprintf (outfp,"},\n" ); +} +static int process_mapfile (FILE *outfp,char *fpath) {int n =16384 ;
@@ -848,6 +861,7 @@ static int process_mapfile(FILE *outfp, char *fpath) } out: +print_mapping_test_table (outfp);print_mapping_table_suffix (outfp);fclose (mapfp);free (line);
@@ -1168,6 +1182,22 @@ int main(int argc, char *argv[]) goto empty_map; } +sprintf (ldirname,"%s/test" , start_dirname); + + rc =nftw (ldirname, process_one_file, maxfds,0 ); +if (rc && verbose) { +pr_info ("%s: Error walking file tree %s rc=%d for test\n" , + prog, ldirname, rc); + goto empty_map; + }else if (rc <0 ) { +/* Make build fail */ +free_arch_std_events (); + ret =1 ; + goto out_free_mapfile; + }else if (rc) { + goto empty_map; + } +if (close_table)print_events_table_suffix (eventsfp);
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 18/24 perf pmu: Refactor pmu_add_cpu_aliases()
In reply to Arnaldo Carvalho de MeloFrom: John Garry <[email protected]>
Create pmu_add_cpu_aliases_map() from pmu_add_cpu_aliases(), so the caller can pass the map; the pmu-events test would use this since there would be no CPUID matching to a mapfile there.
--- tools/perf/util/pmu.c | 21 +++++++++++++-------- tools/perf/util/pmu.h | 3 +++ 2 files changed, 16 insertions(+), 8 deletions(-)
tools/perf/util/pmu.c +13 -8
@@ -21,7 +21,6 @@#include "pmu.h" #include "parse-events.h" #include "header.h" -#include "pmu-events/pmu-events.h" #include "string2.h" #include "strbuf.h" #include "fncache.h"
@@ -744,16 +743,11 @@ static bool pmu_uncore_alias_match(const char *pmu_name, const char *name)* to the current running CPU. Then, add all PMU events from that table * as aliases. */ -static void pmu_add_cpu_aliases (struct list_head *head,struct perf_pmu *pmu) +void pmu_add_cpu_aliases_map (struct list_head *head,struct perf_pmu *pmu, +struct pmu_events_map *map) {int i; -struct pmu_events_map *map;const char *name = pmu->name; - - map =perf_pmu__find_map (pmu); -if (!map) -return ; -/* * Found a matching PMU events table. Create aliases */
@@ -788,6 +782,17 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu) } } +static void pmu_add_cpu_aliases (struct list_head *head,struct perf_pmu *pmu) +{ +struct pmu_events_map *map; + + map =perf_pmu__find_map (pmu); +if (!map) +return ; + +pmu_add_cpu_aliases_map (head, pmu, map); +} +struct perf_event_attr *__weak perf_pmu__get_default_config (struct perf_pmu *pmu__maybe_unused ) {
tools/perf/util/pmu.h +3 -0
@@ -7,6 +7,7 @@#include <linux/perf_event.h> #include <stdbool.h> #include "parse-events.h" +#include "pmu-events/pmu-events.h" struct perf_evsel_config_term ;
@@ -97,6 +98,8 @@ int perf_pmu__scan_file(struct perf_pmu *pmu, const char *name, const char *fmt,int perf_pmu__test (void );struct perf_event_attr *perf_pmu__get_default_config (struct perf_pmu *pmu); +void pmu_add_cpu_aliases_map (struct list_head *head,struct perf_pmu *pmu, +struct pmu_events_map *map);struct pmu_events_map *perf_pmu__find_map (struct perf_pmu *pmu);
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 19/24 perf test: Add pmu-events test
In reply to Arnaldo Carvalho de MeloFrom: John Garry <[email protected]>
The initial test will verify that the test tables in generated pmu-events.c match against known, expected values.
For known events added in pmu-events/arch/test, we need to add an entry in test_cpu_aliases_events[] or test_uncore_events[].
A sample run is as follows for x86:
john@linux-3c19:~/linux> tools/perf/perf test -vv 10
10: PMU event aliases :
--- start ---
test child forked, pid 5316
testing event table bp_l1_btb_correct: pass
testing event table bp_l2_btb_correct: pass
testing event table segment_reg_loads.any: pass testing event table dispatch_blocked.any: pass testing event table eist_trans: pass
testing event table uncore_hisi_ddrc.flux_wcmd: pass testing event table unc_cbo_xsnp_response.miss_eviction: pass test child finished with 0
---- end ----
PMU event aliases: Ok
--- tools/perf/tests/Build | 1 + tools/perf/tests/builtin-test.c | 4 + tools/perf/tests/pmu-events.c | 233 ++++++++++++++++++++++++++++++++ tools/perf/tests/tests.h | 1 + 4 files changed, 239 insertions(+) create mode 100644 tools/perf/tests/pmu-events.c
tools/perf/tests/Build +1 -0
@@ -14,6 +14,7 @@ perf-y += evsel-roundtrip-name.o perf-y += evsel-tp-sched.o perf-y += fdarray.o perf-y += pmu.o +perf-y += pmu-events.o perf-y += hists_common.o perf-y += hists_link.o perf-y += hists_filter.o
tools/perf/tests/builtin-test.c +4 -0
@@ -72,6 +72,10 @@ static struct test generic_tests[] = { .desc = "Parse perf pmu format", .func = test__pmu, }, + { + .desc = "PMU events", + .func = test__pmu_events, + }, { .desc = "DSO data read", .func = test__dso_data,
tools/perf/tests/pmu-events.c new file +233 -0
233 lines not on this page · raw message
tools/perf/tests/tests.h +1 -0
@@ -49,6 +49,7 @@ int test__perf_evsel__roundtrip_name_test(struct test *test, int subtest);int test__perf_evsel__tp_sched_test (struct test *test,int subtest);int test__syscall_openat_tp_fields (struct test *test,int subtest);int test__pmu (struct test *test,int subtest); +int test__pmu_events (struct test *test,int subtest);int test__attr (struct test *test,int subtest);int test__dso_data (struct test *test,int subtest);int test__dso_data_cache (struct test *test,int subtest);
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 20/24 perf pmu: Add is_pmu_core()
In reply to Arnaldo Carvalho de MeloFrom: John Garry <[email protected]>
Add a function to decide whether a PMU is a core PMU.
--- tools/perf/util/pmu.c | 5 +++++ tools/perf/util/pmu.h | 1 + 2 files changed, 6 insertions(+)
tools/perf/util/pmu.c +5 -0
@@ -1400,6 +1400,11 @@ static void wordwrap(char *s, int start, int max, int corr) } } +bool is_pmu_core (const char *name) +{ +return !strcmp (name,"cpu" ) ||is_arm_pmu_core (name); +} +void print_pmu_events (const char *event_glob,bool name_only,bool quiet_flag,bool long_desc,bool details_flag,bool deprecated) {
tools/perf/util/pmu.h +1 -0
@@ -88,6 +88,7 @@ int perf_pmu__format_parse(char *dir, struct list_head *head);struct perf_pmu *perf_pmu__scan (struct perf_pmu *pmu); +bool is_pmu_core (const char *name);void print_pmu_events (const char *event_glob,bool name_only,bool quiet,bool long_desc,bool details_flag,bool deprecated);
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 21/24 perf pmu: Make pmu_uncore_alias_match() public
In reply to Arnaldo Carvalho de MeloFrom: John Garry <[email protected]>
The perf pmu-events test will want to use pmu_uncore_alias_match(), so make it public.
--- tools/perf/util/pmu.c | 2 +- tools/perf/util/pmu.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/pmu.c +1 -1
@@ -698,7 +698,7 @@ struct pmu_events_map *perf_pmu__find_map(struct perf_pmu *pmu)return map; } -static bool pmu_uncore_alias_match (const char *pmu_name,const char *name) +bool pmu_uncore_alias_match (const char *pmu_name,const char *name) {char *tmp =NULL , *tok, *str;bool res;
tools/perf/util/pmu.h +1 -0
@@ -103,6 +103,7 @@ void pmu_add_cpu_aliases_map(struct list_head *head, struct perf_pmu *pmu, struct pmu_events_map *map);struct pmu_events_map *perf_pmu__find_map (struct perf_pmu *pmu); +bool pmu_uncore_alias_match (const char *pmu_name,const char *name);int perf_pmu__convert_scale (const char *scale,char **end,double *sval);
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 22/24 perf test: Test pmu-events aliases
In reply to Arnaldo Carvalho de MeloFrom: John Garry <[email protected]>
Add creating event aliases to the pmu-events test.
So currently we verify that the generated pmu-events.c is as expected for some test events. Now test that we generate aliases as expected for those events during normal operation.
For that, we cycle through each HW PMU in the system, and use the test events to create aliases, and verify those against known, expected values.
For core PMUs, we should create an alias for every event in test_cpu_events[].
However, for uncore PMUs, they need to be matched by the pmu_event.pmu member, so use test_uncore_events[]; so check the match beforehand with pmu_uncore_alias_match().
A sample run is as follows for my x86 machine:
john@linux-3c19:~/linux> tools/perf/perf test -vv 10
10: PMU events :
--- start ---
...
testing PMU uncore_arb aliases: no events to match
testing PMU cstate_pkg aliases: no events to match
skipping testing PMU breakpoint
testing aliases PMU uncore_cbox_1: matched event unc_cbo_xsnp_response.miss_eviction testing PMU uncore_cbox_1 aliases: pass
testing PMU power aliases: no events to match
testing aliases PMU cpu: matched event bp_l1_btb_correct
testing aliases PMU cpu: matched event bp_l2_btb_correct
testing aliases PMU cpu: matched event segment_reg_loads.any
testing aliases PMU cpu: matched event dispatch_blocked.any
testing aliases PMU cpu: matched event eist_trans
testing PMU cpu aliases: pass
testing PMU intel_pt aliases: no events to match
skipping testing PMU software
skipping testing PMU intel_bts
testing PMU uncore_imc aliases: no events to match
testing aliases PMU uncore_cbox_0: matched event unc_cbo_xsnp_response.miss_eviction testing PMU uncore_cbox_0 aliases: pass
testing PMU cstate_core aliases: no events to match
skipping testing PMU tracepoint
testing PMU msr aliases: no events to match
test child finished with 0
--- tools/perf/tests/pmu-events.c | 148 +++++++++++++++++++++++++++++++++- 1 file changed, 147 insertions(+), 1 deletion(-)
tools/perf/tests/pmu-events.c +147 -1
@@ -5,13 +5,24 @@#include <errno.h> #include <stdio.h> #include <linux/kernel.h> - +#include <linux/zalloc.h> #include "debug.h" #include "../pmu-events/pmu-events.h" struct perf_pmu_test_event {struct pmu_event event; + +/* extra events for aliases */ +const char *alias_str; + +/* +* Note: For when PublicDescription does not exist in the JSON, we +* will have no long_desc in pmu_event.long_desc, but long_desc may +* be set in the alias. +*/ +const char *alias_long_desc; }; +static struct perf_pmu_test_event test_cpu_events[] = { { .event = {
@@ -20,6 +31,8 @@ static struct perf_pmu_test_event test_cpu_events[] = { .desc = "L1 BTB Correction", .topic = "branch", }, + .alias_str = "event=0x8a", + .alias_long_desc = "L1 BTB Correction", }, { .event = {
@@ -28,6 +41,8 @@ static struct perf_pmu_test_event test_cpu_events[] = { .desc = "L2 BTB Correction", .topic = "branch", }, + .alias_str = "event=0x8b", + .alias_long_desc = "L2 BTB Correction", }, { .event = {
@@ -36,6 +51,8 @@ static struct perf_pmu_test_event test_cpu_events[] = { .desc = "Number of segment register loads", .topic = "other", }, + .alias_str = "umask=0x80,(null)=0x30d40,event=0x6", + .alias_long_desc = "Number of segment register loads", }, { .event = {
@@ -44,6 +61,8 @@ static struct perf_pmu_test_event test_cpu_events[] = { .desc = "Memory cluster signals to block micro-op dispatch for any reason", .topic = "other", }, + .alias_str = "umask=0x20,(null)=0x30d40,event=0x9", + .alias_long_desc = "Memory cluster signals to block micro-op dispatch for any reason", }, { .event = {
@@ -52,6 +71,8 @@ static struct perf_pmu_test_event test_cpu_events[] = { .desc = "Number of Enhanced Intel SpeedStep(R) Technology (EIST) transitions", .topic = "other", }, + .alias_str = "umask=0,(null)=0x30d40,event=0x3a", + .alias_long_desc = "Number of Enhanced Intel SpeedStep(R) Technology (EIST) transitions", }, {/* sentinel */ .event = {
@@ -70,6 +91,8 @@ static struct perf_pmu_test_event test_uncore_events[] = { .long_desc = "DDRC write commands", .pmu = "hisi_sccl,ddrc", }, + .alias_str = "event=0x2", + .alias_long_desc = "DDRC write commands", }, { .event = {
@@ -80,6 +103,8 @@ static struct perf_pmu_test_event test_uncore_events[] = { .long_desc = "A cross-core snoop resulted from L3 Eviction which misses in some processor core", .pmu = "uncore_cbox", }, + .alias_str = "umask=0x81,event=0x22", + .alias_long_desc = "A cross-core snoop resulted from L3 Eviction which misses in some processor core", }, {/* sentinel */ .event = {
@@ -223,11 +248,132 @@ static int __test_pmu_event_table(void)return 0 ; } + +static struct perf_pmu_alias *find_alias (const char *test_event,struct list_head *aliases) +{ +struct perf_pmu_alias *alias; + +list_for_each_entry (alias, aliases, list) +if (!strcmp (test_event, alias->name)) +return alias; + +return NULL ; +} + +/* Verify aliases are as expected */ +static int __test__pmu_event_aliases (char *pmu_name,int *count) +{ +struct perf_pmu_test_event *test; +struct pmu_event *te; +struct perf_pmu *pmu; +LIST_HEAD (aliases); +int res =0 ; +bool use_uncore_table; +struct pmu_events_map *map =__test_pmu_get_events_map (); + +if (!map) +return -1 ; + +if (is_pmu_core (pmu_name)) { + test = &test_cpu_events[0 ]; + use_uncore_table = false; + }else { + test = &test_uncore_events[0 ]; + use_uncore_table = true; + } + + pmu =zalloc (sizeof (*pmu)); +if (!pmu) +return -1 ; + + pmu->name = pmu_name; + +pmu_add_cpu_aliases_map (&aliases, pmu, map); + +for (te = &test->event; te->name; test++, te = &test->event) { +struct perf_pmu_alias *alias =find_alias (te->name, &aliases); + +if (!alias) { +bool uncore_match =pmu_uncore_alias_match (pmu_name, + te->pmu); + +if (use_uncore_table && !uncore_match) { +pr_debug3 ("testing aliases PMU %s: skip matching alias %s\n" , + pmu_name, te->name); +continue ; + } + +pr_debug2 ("testing aliases PMU %s: no alias, alias_table->name=%s\n" , + pmu_name, te->name); + res =-1 ; +break ; + } + +if (!is_same (alias->desc, te->desc)) { +pr_debug2 ("testing aliases PMU %s: mismatched desc, %s vs %s\n" , + pmu_name, alias->desc, te->desc); + res =-1 ; +break ; + } + +if (!is_same (alias->long_desc, test->alias_long_desc)) { +pr_debug2 ("testing aliases PMU %s: mismatched long_desc, %s vs %s\n" , + pmu_name, alias->long_desc, + test->alias_long_desc); + res =-1 ; +break ; + } + +if (!is_same (alias->str, test->alias_str)) { +pr_debug2 ("testing aliases PMU %s: mismatched str, %s vs %s\n" , + pmu_name, alias->str, test->alias_str); + res =-1 ; +break ; + } + +if (!is_same (alias->topic, te->topic)) { +pr_debug2 ("testing aliases PMU %s: mismatched topic, %s vs %s\n" , + pmu_name, alias->topic, te->topic); + res =-1 ; +break ; + } + + (*count)++; +pr_debug2 ("testing aliases PMU %s: matched event %s\n" , + pmu_name, alias->name); + } + +free (pmu); +return res; +} +int test__pmu_events (struct test *test__maybe_unused ,int subtest__maybe_unused ) { +struct perf_pmu *pmu =NULL ; +if (__test_pmu_event_table ())return -1 ; +while ((pmu =perf_pmu__scan (pmu)) !=NULL ) { +int count =0 ; + +if (list_empty (&pmu->format)) { +pr_debug2 ("skipping testing PMU %s\n" , pmu->name); +continue ; + } + +if (__test__pmu_event_aliases (pmu->name, &count)) { +pr_debug ("testing PMU %s aliases: failed\n" , pmu->name); +return -1 ; + } + +if (count ==0 ) +pr_debug3 ("testing PMU %s aliases: no events to match\n" , + pmu->name); +else +pr_debug ("testing PMU %s aliases: pass\n" , pmu->name); + } +return 0 ; }
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 23/24 perf cpumap: Fix snprintf overflow check
In reply to Arnaldo Carvalho de MeloFrom: Christophe JAILLET <[email protected]>
'snprintf' returns the number of characters which would be generated for the given input.
If the returned value is *greater than* or equal to the buffer size, it means that the output has been truncated.
Fix the overflow test accordingly.
--- tools/perf/util/cpumap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
tools/perf/util/cpumap.c +5 -5
@@ -317,7 +317,7 @@ static void set_max_cpu_num(void)/* get the highest possible cpu number for a sparse allocation */ ret =snprintf (path,PATH_MAX ,"%s/devices/system/cpu/possible" , mnt); -if (ret =PATH_MAX ) { +if (ret >=PATH_MAX ) {pr_err ("sysfs path crossed PATH_MAX(%d) size\n" ,PATH_MAX ); goto out; }
@@ -328,7 +328,7 @@ static void set_max_cpu_num(void)/* get the highest present cpu number for a sparse allocation */ ret =snprintf (path,PATH_MAX ,"%s/devices/system/cpu/present" , mnt); -if (ret =PATH_MAX ) { +if (ret >=PATH_MAX ) {pr_err ("sysfs path crossed PATH_MAX(%d) size\n" ,PATH_MAX ); goto out; }
@@ -356,7 +356,7 @@ static void set_max_node_num(void)/* get the highest possible cpu number for a sparse allocation */ ret =snprintf (path,PATH_MAX ,"%s/devices/system/node/possible" , mnt); -if (ret =PATH_MAX ) { +if (ret >=PATH_MAX ) {pr_err ("sysfs path crossed PATH_MAX(%d) size\n" ,PATH_MAX ); goto out; }
@@ -441,7 +441,7 @@ int cpu__setup_cpunode_map(void)return 0 ; n =snprintf (path,PATH_MAX ,"%s/devices/system/node" , mnt); -if (n =PATH_MAX ) { +if (n >=PATH_MAX ) {pr_err ("sysfs path crossed PATH_MAX(%d) size\n" ,PATH_MAX );return -1 ; }
@@ -456,7 +456,7 @@ int cpu__setup_cpunode_map(void)continue ; n =snprintf (buf,PATH_MAX ,"%s/%s" , path, dent1->d_name); -if (n =PATH_MAX ) { +if (n >=PATH_MAX ) {pr_err ("sysfs path crossed PATH_MAX(%d) size\n" ,PATH_MAX );continue ; }
Signature · 1 line
2.21.1
Arnaldo Carvalho de Melo
maintainerPATCH 24/24 perf dso: Fix dso comparison
In reply to Arnaldo Carvalho de MeloFrom: Ravi Bangoria <[email protected]>
Perf gets dso details from two different sources. 1st, from builid headers in perf.data and 2nd from MMAP2 samples. Dso from buildid header does not have dso_id detail. And dso from MMAP2 samples does not have buildid information. If detail of the same dso is present at both the places, filename is common.
Previously, __dsos__findnew_link_by_longname_id() used to compare only long or short names, but Commit 0e3149f86b99 ("perf dso: Move dso_id from 'struct map' to 'struct dso'") also added a dso_id comparison. Because of that, now perf is creating two different dso objects of the same file, one from buildid header (with dso_id but without buildid) and second from MMAP2 sample (with buildid but without dso_id).
This is causing issues with archive, buildid-list etc subcommands. Fix this by comparing dso_id only when it's present. And incase dso is present in 'dsos' list without dso_id, inject dso_id detail as well.
Before:
$ sudo ./perf buildid-list -H 0000000000000000000000000000000000000000 /usr/bin/ls 0000000000000000000000000000000000000000 /usr/lib64/ld-2.30.so 0000000000000000000000000000000000000000 /usr/lib64/libc-2.30.so
$ ./perf archive perf archive: no build-ids found
After:
$ ./perf buildid-list -H b6b1291d0cead046ed0fa5734037fa87a579adee /usr/bin/ls 641f0c90cfa15779352f12c0ec3c7a2b2b6f41e8 /usr/lib64/ld-2.30.so 675ace3ca07a0b863df01f461a7b0984c65c8b37 /usr/lib64/libc-2.30.so
$ ./perf archive Now please run:
$ tar xvf perf.data.tar.bz2 -C ~/.debug
wherever you need to run 'perf report' on.
Committer notes:
Renamed is_empty_dso_id() to dso_id__empty() and inject_dso_id() to dso__inject_id() to keep namespacing consistent.
--- tools/perf/util/dsos.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
tools/perf/util/dsos.c +21 -1
@@ -26,13 +26,29 @@ static int __dso_id__cmp(struct dso_id *a, struct dso_id *b)return 0 ; } +static bool dso_id__empty (struct dso_id *id) +{ +if (!id) +return true; + +return !id->maj && !id->min && !id->ino && !id->ino_generation; +} + +static void dso__inject_id (struct dso *dso,struct dso_id *id) +{ + dso->id.maj = id->maj; + dso->id.min = id->min; + dso->id.ino = id->ino; + dso->id.ino_generation = id->ino_generation; +} +static int dso_id__cmp (struct dso_id *a,struct dso_id *b) {/* * The second is always dso->id, so zeroes if not set, assume passing * NULL for a means a zeroed id */ -if (a ==NULL ) +if (dso_id__empty (a) ||dso_id__empty (b))return 0 ;return __dso_id__cmp (a, b);
@@ -249,6 +265,10 @@ struct dso *__dsos__addnew(struct dsos *dsos, const char *name)static struct dso *__dsos__findnew_id (struct dsos *dsos,const char *name,struct dso_id *id) {struct dso *dso =__dsos__find_id (dsos, name, id, false); + +if (dso &&dso_id__empty (&dso->id) && !dso_id__empty (id)) +dso__inject_id (dso, id); +return dso ? dso :__dsos__addnew_id (dsos, name, id); }
Signature · 1 line
2.21.1