perf/core improvements and fixes
Subsystems (8)
Arnaldo Carvalho de Melo
maintainerHi Ingo,
Please consider pulling,
- Arnaldo
Test results at the end of this message, as usual.
The following changes since commit ca3bb3d027f69ac3ab1dafb32bde2f5a3a44439c:
perf/ring_buffer: Convert ring_buffer.aux_refcount to refcount_t (2019-02-04 08:46:17 +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.1-20190206
for you to fetch changes up to 16bd4321c2425d37031a902cdbf183e2cd099946:
perf auxtrace: Add timestamp to auxtrace errors (2019-02-06 11:20:32 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:
Hardware tracing:
Adrian Hunter:
- Handle calls optimized into jumps to a different symbol
in the thread stack routines used to process hardware traces (Adrian Hunter)
Intel PT:
Adrian Hunter:
- Fix overlap calculation for padding.
- Fix CYC timestamp calculation after OVF.
- Packet splitting can only happen in 32-bit.
- Add timestamp to auxtrace errors.
ARM CoreSight:
Leo Yan:
- Add last instruction information in packet
- Set sample flags for instruction range, exception and return packets and for a trace discontinuity.
- Add exception number in exception packet
- Change tuple from traceID-CPU# to traceID-metadata
- Add traceID in packet
Mathieu Poirier:
- Add "sinks" group to PMU directory
- Use event attributes to send sink information to kernel
- Remove set_drv_config() API, no longer used.
perf annotate:
Jiri Olsa:
- Delay symbol annotation to the resort phase, speeding up 'perf report' startup.
perf record:
Alexey Budankov:
- Allow binding userspace buffers to NUMA nodes.
Symbols:
Adrian Hunter:
- Fix calculating of symbol sizes when splitting kallsyms into maps for kcore processing.
Vendor events:
William Cohen:
- Intel: Fix Load_Miss_Real_Latency on CLX
Misc:
Arnaldo Carvalho de Melo:
- Streamline headers, removing includes when all that is needed are just forward declarations, fixup the fallout for cases where headers should have been explicitely included but were instead obtained indirectly, by sheer luck.
- Add fallback versions for CPU_{OR,EQUAL}(), so that code using it continue to build on older systems where those were not yet introduced or in systems using some other libc than the GNU one where those helpers aren't present.
Documentation:
Changbin Du:
- Add documentation for BPF event selection.
----------------------------------------------------------------
Adrian Hunter (9):
perf tools: Fix split_kallsyms_for_kcore() for trampoline symbols
perf thread-stack: Tidy thread_stack__push_cp() usage
perf thread-stack: Tidy thread_stack__no_call_return() by adding more local variables perf thread-stack: Represent jmps to the start of a different symbol perf auxtrace: Define auxtrace record alignment
perf intel-pt: Fix overlap calculation for padding
perf intel-pt: Fix CYC timestamp calculation after OVF
perf intel-pt: Packet splitting can happen only on 32-bit
perf auxtrace: Add timestamp to auxtrace errors
Alexey Budankov (3):
perf record: Allocate affinity masks
perf record: Bind the AIO user space buffers to nodes perf record: Apply affinity masks when reading mmap buffers
Arnaldo Carvalho de Melo (21):
perf powerpc: Add missing headers to skip-callchain-idx.c
perf arm pmu: Add missing linux/string.h header
perf srccode: Move struct definition from map.h to srccode.h perf callchain: Uninline callchain_cursor_reset() to remove map.h dependency perf symbols: Introduce map_symbol.h
pref tools: Add missing map.h includes
perf map: Move structs and prototypes for map groups to a separate header perf tests: Add missing headers so far obtained indirectly
perf hist: Remove symbol.h from hist.h, just fwd decls are needed perf tools: Add missing include for symbols.h
perf evsel: No need to include symbol.h in evsel.h, symbol_conf.h is enough perf thread: Don't include symbol.h, symbol_conf.h is enough perf tools: Add missing include <callchain.h> in various places perf hist: Remove the needless callchain.h include from hist.h perf tests pmu: Add missing headers
perf pmu: Remove needless evsel.h include, only needs one fwd decl perf kvm stat: Replace kvm-stat.h includes with forward declarations perf powerpc kvm-stat: Add missing evlist.h header
perf bpf-loader: Remove unecessary includes from bpf-loader.h perf tools: Add fallback versions for CPU_{OR,EQUAL}()
perf clang: Do not use 'return std::move(something)'
Changbin Du (1):
perf tools: Add documentation for BPF event selection
Jiri Olsa (3):
perf hists: Add argument to hists__resort_cb_t callback perf evsel: Add output_resort_cb method
perf report: Move symbol annotation to the resort phase
Leo Yan (8):
perf cs-etm: Add last instruction information in packet perf cs-etm: Set sample flags for instruction range packet perf cs-etm: Set sample flags for trace discontinuity perf cs-etm: Add exception number in exception packet perf cs-etm: Change tuple from traceID-CPU# to traceID-metadata perf cs-etm: Add traceID in packet
perf cs-etm: Set sample flags for exception packet perf cs-etm: Set sample flags for exception return packet
Mathieu Poirier (7):
perf/aux: Make perf_event accessible to setup_aux()
coresight: perf: Add "sinks" group to PMU directory
coresight: Use event attributes for sink selection
perf pmu: Move EVENT_SOURCE_DEVICE_PATH to PMU header file perf arm cs-etm: Use event attributes to send sink information to kernel perf coresight: Remove set_drv_config() API
perf pmu: Remove set_drv_config API
William Cohen (1):
perf vendor events intel: Fix Load_Miss_Real_Latency on CLX
arch/s390/kernel/perf_cpum_sf.c | 6 +- arch/x86/events/intel/bts.c | 4 +- arch/x86/events/intel/pt.c | 5 +- drivers/hwtracing/coresight/coresight-etm-perf.c | 112 +++++- drivers/hwtracing/coresight/coresight-etm-perf.h | 6 +- drivers/hwtracing/coresight/coresight-priv.h | 1 + drivers/hwtracing/coresight/coresight.c | 60 ++++ drivers/perf/arm_spe_pmu.c | 6 +- include/linux/coresight.h | 7 +- include/linux/perf_event.h | 2 +- kernel/events/ring_buffer.c | 2 +- tools/perf/Documentation/perf-config.txt | 31 ++ tools/perf/Documentation/perf-record.txt | 14 + tools/perf/arch/arm/tests/dwarf-unwind.c | 1 + tools/perf/arch/arm/util/cs-etm.c | 98 +++-- tools/perf/arch/arm/util/cs-etm.h | 3 - tools/perf/arch/arm/util/pmu.c | 3 +- tools/perf/arch/arm64/tests/dwarf-unwind.c | 1 + tools/perf/arch/powerpc/tests/dwarf-unwind.c | 1 + tools/perf/arch/powerpc/util/kvm-stat.c | 2 + tools/perf/arch/powerpc/util/skip-callchain-idx.c | 3 + tools/perf/arch/s390/util/kvm-stat.c | 1 + tools/perf/arch/x86/tests/dwarf-unwind.c | 1 + tools/perf/arch/x86/util/kvm-stat.c | 1 + tools/perf/builtin-annotate.c | 1 + tools/perf/builtin-c2c.c | 9 +- tools/perf/builtin-inject.c | 2 + tools/perf/builtin-kallsyms.c | 1 + tools/perf/builtin-kmem.c | 1 + tools/perf/builtin-mem.c | 1 + tools/perf/builtin-record.c | 38 +- tools/perf/builtin-report.c | 22 +- tools/perf/builtin-script.c | 1 + tools/perf/builtin-stat.c | 9 - tools/perf/builtin-top.c | 14 +- tools/perf/builtin-trace.c | 2 + tools/perf/perf.h | 8 + .../arch/x86/cascadelakex/clx-metrics.json | 2 +- tools/perf/scripts/python/export-to-postgresql.py | 2 +- tools/perf/scripts/python/export-to-sqlite.py | 2 +- tools/perf/tests/code-reading.c | 2 + tools/perf/tests/dwarf-unwind.c | 1 + tools/perf/tests/hists_common.c | 1 + tools/perf/tests/hists_cumulate.c | 1 + tools/perf/tests/hists_filter.c | 1 + tools/perf/tests/hists_output.c | 1 + tools/perf/tests/mmap-thread-lookup.c | 1 + tools/perf/tests/pmu.c | 2 + tools/perf/tests/sample-parsing.c | 2 + tools/perf/tests/sdt.c | 1 + tools/perf/ui/browsers/annotate.c | 1 + tools/perf/ui/browsers/hists.c | 3 + tools/perf/ui/gtk/annotate.c | 2 + tools/perf/ui/gtk/hists.c | 1 + tools/perf/ui/hist.c | 1 + tools/perf/ui/stdio/hist.c | 4 + tools/perf/util/Build | 1 - tools/perf/util/annotate.c | 1 + tools/perf/util/auxtrace.c | 27 +- tools/perf/util/auxtrace.h | 5 +- tools/perf/util/bpf-loader.c | 1 + tools/perf/util/bpf-loader.h | 7 +- tools/perf/util/build-id.c | 1 + tools/perf/util/c++/clang.cpp | 2 +- tools/perf/util/callchain.c | 17 + tools/perf/util/callchain.h | 20 +- tools/perf/util/config.c | 1 + tools/perf/util/cpu-set-sched.h | 50 +++ tools/perf/util/cpumap.c | 10 + tools/perf/util/cpumap.h | 1 + tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 41 ++- tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 6 + tools/perf/util/cs-etm.c | 394 ++++++++++++++++++++- tools/perf/util/cs-etm.h | 53 ++- tools/perf/util/db-export.c | 1 + tools/perf/util/drv_configs.c | 78 ---- tools/perf/util/drv_configs.h | 26 -- tools/perf/util/dso.c | 1 + tools/perf/util/event.c | 2 + tools/perf/util/event.h | 3 +- tools/perf/util/evlist.c | 6 +- tools/perf/util/evlist.h | 2 +- tools/perf/util/evsel.h | 2 +- tools/perf/util/hist.c | 21 +- tools/perf/util/hist.h | 9 +- tools/perf/util/intel-bts.c | 6 +- .../perf/util/intel-pt-decoder/intel-pt-decoder.c | 39 +- tools/perf/util/intel-pt.c | 23 +- tools/perf/util/kvm-stat.h | 7 +- tools/perf/util/machine.c | 1 + tools/perf/util/machine.h | 2 +- tools/perf/util/map.c | 6 + tools/perf/util/map.h | 100 +----- tools/perf/util/map_groups.h | 91 +++++ tools/perf/util/map_symbol.h | 22 ++ tools/perf/util/mmap.c | 105 +++++- tools/perf/util/mmap.h | 3 +- tools/perf/util/pmu.c | 2 - tools/perf/util/pmu.h | 5 +- tools/perf/util/probe-event.c | 2 + tools/perf/util/s390-cpumsf.c | 7 +- .../perf/util/scripting-engines/trace-event-perl.c | 2 + .../util/scripting-engines/trace-event-python.c | 2 + tools/perf/util/session.c | 5 + tools/perf/util/setup.py | 5 + tools/perf/util/sort.c | 8 +- tools/perf/util/sort.h | 3 +- tools/perf/util/srccode.h | 13 + tools/perf/util/symbol-elf.c | 2 + tools/perf/util/symbol.c | 3 + tools/perf/util/symbol.h | 14 +- tools/perf/util/thread-stack.c | 78 ++-- tools/perf/util/thread-stack.h | 3 + tools/perf/util/thread.c | 1 + tools/perf/util/thread.h | 7 +- tools/perf/util/unwind-libdw.c | 2 + tools/perf/util/unwind-libunwind-local.c | 1 + tools/perf/util/unwind-libunwind.c | 1 + tools/perf/util/vdso.c | 1 + 119 files changed, 1399 insertions(+), 473 deletions(-) create mode 100644 tools/perf/util/cpu-set-sched.h delete mode 100644 tools/perf/util/drv_configs.c delete mode 100644 tools/perf/util/drv_configs.h create mode 100644 tools/perf/util/map_groups.h create mode 100644 tools/perf/util/map_symbol.h
Test results:
The first ones are container based builds of tools/perf with and without libelf support. Where clang is available, it is also used to build perf with/without libelf, and building with LIBCLANGLLVM=1 (built-in clang) with gcc and clang when clang and its devel libraries are installed.
The objtool and samples/bpf/ builds are disabled now that I'm switching from using the sources in a local volume to fetching them from a http server to build it inside the container, to make it easier to build in a container cluster. Those will come back later.
Several are cross builds, the ones with -x-ARCH and the android one, and those may not have all the features built, due to lack of multi-arch devel packages, available and being used so far on just a few, like debian:experimental-x-{arm64,mipsel}.
The 'perf test' one will perform a variety of tests exercising tools/perf/util/, tools/lib/{bpf,traceevent,etc}, as well as run perf commands with a variety of command line event specifications to then intercept the sys_perf_event syscall to check that the perf_event_attr fields are set up as expected, among a variety of other unit tests.
Then there is the 'make -C tools/perf build-test' ones, that build tools/perf/ with a variety of feature sets, exercising the build with an incomplete set of features as well as with a complete one. It is planned to have it run on each of the containers mentioned above, using some container orchestration infrastructure. Get in contact if interested in helping having this in place.
# export PERF_TARBALL=http://192.168.124.1/perf/perf-5.0.0-rc5.tar.xz # time dm 1 alpine:3.4 : Ok gcc (Alpine 5.3.0) 5.3.0 2 alpine:3.5 : Ok gcc (Alpine 6.2.1) 6.2.1 20160822 3 alpine:3.6 : Ok gcc (Alpine 6.3.0) 6.3.0 4 alpine:3.7 : Ok gcc (Alpine 6.4.0) 6.4.0 5 alpine:3.8 : Ok gcc (Alpine 6.4.0) 6.4.0 6 alpine:3.9 : Ok gcc (Alpine 8.2.0) 8.2.0 7 alpine:edge : Ok gcc (Alpine 8.2.0) 8.2.0 8 amazonlinux:1 : Ok gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28) 9 amazonlinux:2 : Ok gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5) 10 android-ndk:r12b-arm : Ok gcc (GCC) 8.2.1 20181215 (Red Hat 8.2.1-6) 11 android-ndk:r15c-arm : Ok gcc (GCC) 8.2.1 20181215 (Red Hat 8.2.1-6) 12 centos:5 : Ok gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55) 13 centos:6 : Ok gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23) 14 centos:7 : Ok gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36) 15 clearlinux:latest : Ok gcc (Clear Linux OS for Intel Architecture) 8.2.1 20180502 16 debian:7 : Ok gcc (Debian 4.7.2-5) 4.7.2 17 debian:8 : Ok gcc (Debian 4.9.2-10+deb8u2) 4.9.2 18 debian:9 : Ok gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516 19 debian:experimental : Ok gcc (Debian 8.2.0-16) 8.2.0 20 debian:experimental-x-arm64 : Ok gcc (Debian 8.2.0-16) 8.2.0 21 debian:experimental-x-mips : Ok gcc (Debian 8.2.0-16) 8.2.0 22 debian:experimental-x-mips64 : Ok gcc (Debian 8.2.0-16) 8.2.0 23 fedora:20 : Ok gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7) 24 fedora:21 : Ok gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6) 25 fedora:25 : Ok gcc (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1) 26 fedora:26 : Ok gcc (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2) 27 fedora:27 : Ok gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-6) 28 fedora:28 : Ok gcc (GCC) 8.2.1 20181215 (Red Hat 8.2.1-6) 29 fedora:29 : Ok gcc (GCC) 8.2.1 20181215 (Red Hat 8.2.1-6) 30 fedora:rawhide : Ok gcc (GCC) 9.0.0 20190119 (Red Hat 9.0.0-0.3) 31 gentoo-stage3-amd64:latest : Ok gcc (Gentoo 7.3.0-r3 p1.4) 7.3.0 32 mageia:5 : Ok gcc (GCC) 4.9.2 33 mageia:6 : Ok gcc (Mageia 5.5.0-1.mga6) 5.5.0 34 opensuse:13.2 : Ok gcc (SUSE Linux) 4.8.3 20140627 [gcc-4_8-branch revision 212064] 35 opensuse:15.0 : Ok gcc (SUSE Linux) 7.3.1 20180323 [gcc-7-branch revision 258812] 36 opensuse:15.1 : Ok gcc (SUSE Linux) 7.4.0 37 opensuse:42.1 : Ok gcc (SUSE Linux) 4.8.5 38 opensuse:42.2 : Ok gcc (SUSE Linux) 4.8.5 39 opensuse:42.3 : Ok gcc (SUSE Linux) 4.8.5 40 opensuse:tumbleweed : Ok gcc (SUSE Linux) 8.2.1 20190103 [gcc-8-branch revision 267549]
42 oraclelinux:7 : Ok gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36.0.1) 43 ubuntu:12.04.5 : Ok gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 44 ubuntu:14.04.4 : Ok gcc (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4 45 ubuntu:14.04.4-x-linaro-arm64 : Ok gcc (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4 46 ubuntu:16.04 : Ok gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609 47 ubuntu:16.04-x-arm : Ok gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609 48 ubuntu:16.04-x-arm64 : Ok gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609 49 ubuntu:16.04-x-powerpc : Ok gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609 50 ubuntu:16.04-x-powerpc64 : Ok gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609 51 ubuntu:16.04-x-powerpc64el : Ok gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609 52 ubuntu:16.04-x-s390 : Ok gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609 53 ubuntu:17.10 : Ok gcc (Ubuntu 7.2.0-8ubuntu3.2) 7.2.0 54 ubuntu:18.04 : Ok gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 55 ubuntu:18.04-x-arm : Ok gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 56 ubuntu:18.04-x-arm64 : Ok gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 57 ubuntu:18.04-x-m68k : Ok gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 58 ubuntu:18.04-x-powerpc : Ok gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 59 ubuntu:18.04-x-powerpc64 : Ok gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 60 ubuntu:18.04-x-powerpc64el : Ok gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 61 ubuntu:18.04-x-riscv64 : Ok gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 62 ubuntu:18.04-x-s390 : Ok gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 63 ubuntu:18.04-x-sh4 : Ok gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 64 ubuntu:18.04-x-sparc64 : Ok gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 65 ubuntu:18.10 : Ok gcc (Ubuntu 8.2.0-7ubuntu1) 8.2.0 66 ubuntu:19.04 : Ok gcc (Ubuntu 8.2.0-15ubuntu1) 8.2.0 67 ubuntu:19.04-x-alpha : Ok gcc (Ubuntu 8.2.0-15ubuntu1) 8.2.0 68 ubuntu:19.04-x-hppa : Ok gcc (Ubuntu 8.2.0-15ubuntu1) 8.2.0
#
# uname -a
Linux quaco 5.0.0-rc3+ #16 SMP Mon Jan 21 12:01:36 -03 2019 x86_64 x86_64 x86_64 GNU/Linux
# git log --oneline -1
16bd4321c242 perf auxtrace: Add timestamp to auxtrace errors
# perf version --build-options
perf version 5.0.rc5.g16bd43
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
# perf test
1: vmlinux symtab matches kallsyms : Ok
2: Detect openat syscall event : Ok
3: Detect openat syscall event on all cpus : Ok
4: Read samples using the mmap interface : Ok
5: Test data source output : Ok
6: Parse event definition strings : Ok
7: Simple expression parser : Ok
8: PERF_RECORD_* events & perf_sample fields : Ok
9: Parse perf pmu format : Ok
10: DSO data read : Ok
11: DSO data cache : Ok
12: DSO data reopen : Ok
13: Roundtrip evsel->name : Ok
14: Parse sched tracepoints fields : Ok
15: syscalls:sys_enter_openat event fields : Ok
16: Setup struct perf_event_attr : Ok
17: Match and link multiple hists : Ok
18: 'import perf' in python : Ok
19: Breakpoint overflow signal handler : Ok
20: Breakpoint overflow sampling : Ok
21: Breakpoint accounting : Ok
22: Watchpoint :
22.1: Read Only Watchpoint : Skip
22.2: Write Only Watchpoint : Ok
22.3: Read / Write Watchpoint : Ok
22.4: Modify Watchpoint : Ok
23: Number of exit events of a simple workload : Ok
24: Software clock events period values : Ok
25: Object code reading : Ok
26: Sample parsing : Ok
27: Use a dummy software event to keep tracking : Ok
28: Parse with no sample_id_all bit set : Ok
29: Filter hist entries : Ok
30: Lookup mmap thread : Ok
31: Share thread mg : Ok
32: Sort output of hist entries : Ok
33: Cumulate child hist entries : Ok
34: Track with sched_switch : Ok
35: Filter fds with revents mask in a fdarray : Ok
36: Add fd to a fdarray, making it autogrow : Ok
37: kmod_path__parse : Ok
38: Thread map : Ok
39: LLVM search and compile :
39.1: Basic BPF llvm compile : Ok
39.2: kbuild searching : Ok
39.3: Compile source for BPF prologue generation : Ok
39.4: Compile source for BPF relocation : Ok
40: Session topology : Ok
41: BPF filter :
41.1: Basic BPF filtering : Ok
41.2: BPF pinning : Ok
41.3: BPF prologue generation : Ok
41.4: BPF relocation checker : Ok
42: Synthesize thread map : Ok
43: Remove thread map : Ok
44: Synthesize cpu map : Ok
45: Synthesize stat config : Ok
46: Synthesize stat : Ok
47: Synthesize stat round : Ok
48: Synthesize attr update : Ok
49: Event times : Ok
50: Read backward ring buffer : Ok
51: Print cpu map : Ok
52: Probe SDT events : Ok
53: is_printable_array : Ok
54: Print bitmap : Ok
55: perf hooks : Ok
56: builtin clang support : Skip (not compiled in)
57: unit_number__scnprintf : Ok
58: mem2node : Ok
59: x86 rdpmc : Ok
60: Convert perf time to TSC : Ok
61: DWARF unwind : Ok
62: x86 instruction decoder - new instructions : Ok
63: x86 bp modify : Ok
64: probe libc's inet_pton & backtrace it with ping : Ok
65: Use vfs_getname probe to get syscall args filenames : Ok
66: Add vfs_getname probe to get syscall args filenames : Ok
67: Check open filename arg using perf trace + vfs_getname: Ok $ make -C tools/perf build-test
make: Entering directory '/home/acme/git/perf/tools/perf'
- tarpkg: ./tests/perf-targz-src-pkg .
make_no_ui_O: make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
make_no_backtrace_O: make NO_BACKTRACE=1
make_no_auxtrace_O: make NO_AUXTRACE=1
make_no_demangle_O: make NO_DEMANGLE=1
make_debug_O: make DEBUG=1
make_no_gtk2_O: make NO_GTK2=1
make_tags_O: make tags
make_clean_all_O: make clean all
make_install_prefix_O: make install prefix=/tmp/krava
make_no_scripts_O: make NO_LIBPYTHON=1 NO_LIBPERL=1
make_util_pmu_bison_o_O: make util/pmu-bison.o
make_install_prefix_slash_O: make install prefix=/tmp/krava/
make_no_libelf_O: make NO_LIBELF=1
make_cscope_O: make cscope
make_with_babeltrace_O: make LIBBABELTRACE=1
make_perf_o_O: make perf.o
make_help_O: make help
make_no_slang_O: make NO_SLANG=1
make_pure_O: make
make_static_O: make LDFLAGS=-static
make_no_libbpf_O: make NO_LIBBPF=1
make_no_libnuma_O: make NO_LIBNUMA=1
make_doc_O: make doc
make_install_O: make install
make_no_libpython_O: make NO_LIBPYTHON=1
make_no_libperl_O: make NO_LIBPERL=1
make_no_libaudit_O: make NO_LIBAUDIT=1
make_no_newt_O: make NO_NEWT=1
make_no_libdw_dwarf_unwind_O: make NO_LIBDW_DWARF_UNWIND=1
make_no_libunwind_O: make NO_LIBUNWIND=1
make_with_clangllvm_O: make LIBCLANGLLVM=1
make_util_map_o_O: make util/map.o
make_install_bin_O: make install-bin
make_no_libbionic_O: make NO_LIBBIONIC=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
OK
$Arnaldo Carvalho de Melo
maintainerPATCH 1/53 perf powerpc: Add missing headers to skip-callchain-idx.c
From: Arnaldo Carvalho de Melo <[email protected]>
It uses several structs but don't explicitely includes the headers where they are defined, getting them by sheer luck from one of the headers it includes, since those are being streamlined to avoid unnecessary rebuilds when changes are made to a random header, they will break, fix them now so that they continue to build.
--- tools/perf/arch/powerpc/util/skip-callchain-idx.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/arch/powerpc/util/skip-callchain-idx.c +3 -0
@@ -16,6 +16,9 @@#include "util/thread.h" #include "util/callchain.h" #include "util/debug.h" +#include "util/dso.h" +#include "util/map.h" +#include "util/symbol.h" /* * When saving the callchain on Power, the kernel conservatively saves
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 2/53 perf arm pmu: Add missing linux/string.h header
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
It uses strstarts(), that is defined in linux/string.h but that was being including by sheer luck, indirectly, fix it.
--- tools/perf/arch/arm/util/pmu.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/arch/arm/util/pmu.c +1 -0
@@ -7,6 +7,7 @@#include <string.h> #include <linux/coresight-pmu.h> #include <linux/perf_event.h> +#include <linux/string.h> #include "cs-etm.h" #include "arm-spe.h"
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 3/53 perf srccode: Move struct definition from map.h to srccode.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To reduce the header dependencies, since we already have a srccode.h header, then there is where the 'struct srccode_state' should be, and map.h, that is more widely used should have just a forward declaraion of 'struct srccode_state'.
--- tools/perf/util/map.h | 13 +------------ tools/perf/util/srccode.h | 13 +++++++++++++ tools/perf/util/thread.h | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-)
tools/perf/util/map.h +1 -12
@@ -174,18 +174,7 @@ char *map__srcline(struct map *map, u64 addr, struct symbol *sym);int map__fprintf_srcline (struct map *map,u64 addr,const char *prefix,FILE *fp); -struct srccode_state { -char *srcfile; -unsigned line; -}; - -static inline void srccode_state_init (struct srccode_state *state) -{ - state->srcfile =NULL ; - state->line =0 ; -} - -void srccode_state_free (struct srccode_state *state); +struct srccode_state ;int map__fprintf_srccode (struct map *map,u64 addr,FILE *fp,struct srccode_state *state);
tools/perf/util/srccode.h +13 -0
@@ -1,6 +1,19 @@#ifndef SRCCODE_H #define SRCCODE_H 1 +struct srccode_state { +char *srcfile; +unsigned line; +}; + +static inline void srccode_state_init (struct srccode_state *state) +{ + state->srcfile =NULL ; + state->line =0 ; +} + +void srccode_state_free (struct srccode_state *state); +/* Result is not 0 terminated */ char *find_sourceline (char *fn,unsigned line,int *lenp);
tools/perf/util/thread.h +1 -1
@@ -7,8 +7,8 @@#include <linux/list.h> #include <unistd.h> #include <sys/types.h> +#include "srccode.h" #include "symbol.h" -#include "map.h" #include <strlist.h> #include <intlist.h> #include "rwsem.h"
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 4/53 perf callchain: Uninline callchain_cursor_reset() to remove map.h dependency
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
That was the only thing that made including map.h in callchain.h a requiriment, so uninline it and just add a 'struct map' forward declaration.
--- tools/perf/ui/gtk/annotate.c | 1 + tools/perf/ui/stdio/hist.c | 1 + tools/perf/util/callchain.c | 15 +++++++++++++++ tools/perf/util/callchain.h | 18 +++--------------- 4 files changed, 20 insertions(+), 15 deletions(-)
tools/perf/ui/gtk/annotate.c +1 -0
@@ -4,6 +4,7 @@#include "util/debug.h" #include "util/annotate.h" #include "util/evsel.h" +#include "util/map.h" #include "ui/helpline.h" #include <inttypes.h> #include <signal.h>
tools/perf/ui/stdio/hist.c +1 -0
@@ -4,6 +4,7 @@#include "../../util/util.h" #include "../../util/hist.h" +#include "../../util/map.h" #include "../../util/sort.h" #include "../../util/evsel.h" #include "../../util/srcline.h"
tools/perf/util/callchain.c +15 -0
@@ -1577,3 +1577,18 @@ int callchain_cursor__copy(struct callchain_cursor *dst,return rc; } + +/* +* Initialize a cursor before adding entries inside, but keep +* the previously allocated entries as a cache. +*/ +void callchain_cursor_reset (struct callchain_cursor *cursor) +{ +struct callchain_cursor_node *node; + + cursor->nr =0 ; + cursor->last = &cursor->first; + +for (node = cursor->first; node !=NULL ; node = node->next) +map__zput (node->map); +}
tools/perf/util/callchain.h +3 -15
@@ -5,10 +5,11 @@#include <linux/list.h> #include <linux/rbtree.h> #include "event.h" -#include "map.h" #include "symbol.h" #include "branch.h" +struct map ; +#define HELP_PAD "\t\t\t\t"#define CALLCHAIN_HELP "setup and enables call-graph (stack chain/backtrace):\n\n"
@@ -187,20 +188,7 @@ int callchain_append(struct callchain_root *root,int callchain_merge (struct callchain_cursor *cursor,struct callchain_root *dst,struct callchain_root *src); -/* -* Initialize a cursor before adding entries inside, but keep -* the previously allocated entries as a cache. -*/ -static inline void callchain_cursor_reset (struct callchain_cursor *cursor) -{ -struct callchain_cursor_node *node; - - cursor->nr =0 ; - cursor->last = &cursor->first; - -for (node = cursor->first; node !=NULL ; node = node->next) -map__zput (node->map); -} +void callchain_cursor_reset (struct callchain_cursor *cursor); int callchain_cursor_append(struct callchain_cursor *cursor, u64 ip, struct map *map, struct symbol *sym,
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 5/53 perf symbols: Introduce map_symbol.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To allow headers just wanting this definition to be able to get it without all the things in symbol.h, to reduce the include dep tree.
--- tools/perf/util/callchain.h | 2 +- tools/perf/util/hist.h | 1 + tools/perf/util/map_symbol.h | 22 ++++++++++++++++++++++ tools/perf/util/sort.h | 3 ++- tools/perf/util/symbol.h | 14 +------------- 5 files changed, 27 insertions(+), 15 deletions(-) create mode 100644 tools/perf/util/map_symbol.h
tools/perf/util/callchain.h +1 -1
@@ -5,7 +5,7 @@#include <linux/list.h> #include <linux/rbtree.h> #include "event.h" -#include "symbol.h" +#include "map_symbol.h" #include "branch.h" struct map ;
tools/perf/util/hist.h +1 -0
@@ -8,6 +8,7 @@#include "evsel.h" #include "header.h" #include "color.h" +#include "symbol.h" #include "ui/progress.h" struct hist_entry ;
tools/perf/util/map_symbol.h new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef __PERF_MAP_SYMBOL +#define __PERF_MAP_SYMBOL 1 + +#include <linux/types.h> + +struct map ; +struct symbol ; + +struct map_symbol { +struct map *map; +struct symbol *sym; +}; + +struct addr_map_symbol { +struct map *map; +struct symbol *sym; +u64 addr; +u64 al_addr; +u64 phys_addr; +}; +#endif // __PERF_MAP_SYMBOL
tools/perf/util/sort.h +2 -1
@@ -9,7 +9,8 @@#include <linux/list.h> #include "cache.h" #include <linux/rbtree.h> -#include "symbol.h" +#include "map_symbol.h" +#include "symbol_conf.h" #include "string.h" #include "callchain.h" #include "values.h"
tools/perf/util/symbol.h +1 -13
@@ -8,6 +8,7 @@#include <linux/list.h> #include <linux/rbtree.h> #include <stdio.h> +#include "map_symbol.h" #include "branch.h" #include "path.h" #include "symbol_conf.h"
@@ -115,19 +116,6 @@ struct ref_reloc_sym {u64 unrelocated_addr; }; -struct map_symbol { -struct map *map; -struct symbol *sym; -}; - -struct addr_map_symbol { -struct map *map; -struct symbol *sym; -u64 addr; -u64 al_addr; -u64 phys_addr; -}; -struct branch_info {struct addr_map_symbol from;struct addr_map_symbol to;
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 6/53 pref tools: Add missing map.h includes
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Lots of places get the map.h file indirectly, and since we're going to remove it from machine.h, then those need to include it directly, do it now, before we remove that dep.
--- tools/perf/builtin-annotate.c | 1 + tools/perf/builtin-inject.c | 1 + tools/perf/builtin-kallsyms.c | 1 + tools/perf/builtin-kmem.c | 1 + tools/perf/builtin-mem.c | 1 + tools/perf/builtin-report.c | 1 + tools/perf/builtin-script.c | 1 + tools/perf/builtin-top.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/tests/code-reading.c | 1 + tools/perf/tests/hists_common.c | 1 + tools/perf/tests/hists_cumulate.c | 1 + tools/perf/tests/hists_filter.c | 1 + tools/perf/tests/hists_output.c | 1 + tools/perf/tests/mmap-thread-lookup.c | 1 + tools/perf/ui/browsers/annotate.c | 1 + tools/perf/ui/browsers/hists.c | 1 + tools/perf/util/annotate.c | 1 + tools/perf/util/build-id.c | 1 + tools/perf/util/callchain.c | 1 + tools/perf/util/db-export.c | 1 + tools/perf/util/dso.c | 1 + tools/perf/util/event.c | 1 + tools/perf/util/intel-bts.c | 1 + tools/perf/util/probe-event.c | 1 + tools/perf/util/scripting-engines/trace-event-perl.c | 1 + tools/perf/util/scripting-engines/trace-event-python.c | 1 + tools/perf/util/session.c | 1 + tools/perf/util/sort.c | 1 + tools/perf/util/symbol-elf.c | 1 + tools/perf/util/symbol.c | 1 + tools/perf/util/unwind-libdw.c | 1 + tools/perf/util/unwind-libunwind-local.c | 1 + tools/perf/util/unwind-libunwind.c | 1 + tools/perf/util/vdso.c | 1 + 35 files changed, 35 insertions(+)
tools/perf/builtin-annotate.c +1 -0
@@ -27,6 +27,7 @@#include "util/thread.h" #include "util/sort.h" #include "util/hist.h" +#include "util/map.h" #include "util/session.h" #include "util/tool.h" #include "util/data.h"
tools/perf/builtin-inject.c +1 -0
@@ -12,6 +12,7 @@#include "util/color.h" #include "util/evlist.h" #include "util/evsel.h" +#include "util/map.h" #include "util/session.h" #include "util/tool.h" #include "util/debug.h"
tools/perf/builtin-kallsyms.c +1 -0
@@ -13,6 +13,7 @@#include <subcmd/parse-options.h> #include "debug.h" #include "machine.h" +#include "map.h" #include "symbol.h" static int __cmd_kallsyms (int argc,const char **argv)
tools/perf/builtin-kmem.c +1 -0
@@ -6,6 +6,7 @@#include "util/evsel.h" #include "util/util.h" #include "util/config.h" +#include "util/map.h" #include "util/symbol.h" #include "util/thread.h" #include "util/header.h"
tools/perf/builtin-mem.c +1 -0
@@ -13,6 +13,7 @@#include "util/data.h" #include "util/mem-events.h" #include "util/debug.h" +#include "util/map.h" #include "util/symbol.h" #define MEM_OPERATION_LOAD 0x1
tools/perf/builtin-report.c +1 -0
@@ -16,6 +16,7 @@#include <linux/list.h> #include <linux/rbtree.h> #include <linux/err.h> +#include "util/map.h" #include "util/symbol.h" #include "util/callchain.h" #include "util/values.h"
tools/perf/builtin-script.c +1 -0
@@ -10,6 +10,7 @@#include "util/perf_regs.h" #include "util/session.h" #include "util/tool.h" +#include "util/map.h" #include "util/symbol.h" #include "util/thread.h" #include "util/trace-event.h"
tools/perf/builtin-top.c +1 -0
@@ -30,6 +30,7 @@#include "util/evsel.h" #include "util/event.h" #include "util/machine.h" +#include "util/map.h" #include "util/session.h" #include "util/symbol.h" #include "util/thread.h"
tools/perf/builtin-trace.c +1 -0
@@ -29,6 +29,7 @@#include "util/evlist.h" #include <subcmd/exec-cmd.h> #include "util/machine.h" +#include "util/map.h" #include "util/path.h" #include "util/session.h" #include "util/thread.h"
tools/perf/tests/code-reading.c +1 -0
@@ -15,6 +15,7 @@#include "thread_map.h" #include "cpumap.h" #include "machine.h" +#include "map.h" #include "event.h" #include "thread.h"
tools/perf/tests/hists_common.c +1 -0
@@ -2,6 +2,7 @@#include <inttypes.h> #include "perf.h" #include "util/debug.h" +#include "util/map.h" #include "util/symbol.h" #include "util/sort.h" #include "util/evsel.h"
tools/perf/tests/hists_cumulate.c +1 -0
@@ -2,6 +2,7 @@#include "perf.h" #include "util/debug.h" #include "util/event.h" +#include "util/map.h" #include "util/symbol.h" #include "util/sort.h" #include "util/evsel.h"
tools/perf/tests/hists_filter.c +1 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include "perf.h" #include "util/debug.h" +#include "util/map.h" #include "util/symbol.h" #include "util/sort.h" #include "util/evsel.h"
tools/perf/tests/hists_output.c +1 -0
@@ -2,6 +2,7 @@#include "perf.h" #include "util/debug.h" #include "util/event.h" +#include "util/map.h" #include "util/symbol.h" #include "util/sort.h" #include "util/evsel.h"
tools/perf/tests/mmap-thread-lookup.c +1 -0
@@ -11,6 +11,7 @@#include "tests.h" #include "machine.h" #include "thread_map.h" +#include "map.h" #include "symbol.h" #include "thread.h" #include "util.h"
tools/perf/ui/browsers/annotate.c +1 -0
@@ -7,6 +7,7 @@#include "../../util/annotate.h" #include "../../util/hist.h" #include "../../util/sort.h" +#include "../../util/map.h" #include "../../util/symbol.h" #include "../../util/evsel.h" #include "../../util/evlist.h"
tools/perf/ui/browsers/hists.c +1 -0
@@ -11,6 +11,7 @@#include "../../util/evsel.h" #include "../../util/evlist.h" #include "../../util/hist.h" +#include "../../util/map.h" #include "../../util/pstack.h" #include "../../util/sort.h" #include "../../util/util.h"
tools/perf/util/annotate.c +1 -0
@@ -17,6 +17,7 @@#include "color.h" #include "config.h" #include "cache.h" +#include "map.h" #include "symbol.h" #include "units.h" #include "debug.h"
tools/perf/util/build-id.c +1 -0
@@ -16,6 +16,7 @@#include "build-id.h" #include "event.h" #include "namespaces.h" +#include "map.h" #include "symbol.h" #include "thread.h" #include <linux/kernel.h>
tools/perf/util/callchain.c +1 -0
@@ -23,6 +23,7 @@#include "util.h" #include "sort.h" #include "machine.h" +#include "map.h" #include "callchain.h" #include "branch.h"
tools/perf/util/db-export.c +1 -0
@@ -20,6 +20,7 @@#include "thread.h" #include "comm.h" #include "symbol.h" +#include "map.h" #include "event.h" #include "util.h" #include "thread-stack.h"
tools/perf/util/dso.c +1 -0
@@ -12,6 +12,7 @@#include "compress.h" #include "namespaces.h" #include "path.h" +#include "map.h" #include "symbol.h" #include "srcline.h" #include "dso.h"
tools/perf/util/event.c +1 -0
@@ -21,6 +21,7 @@#include "thread.h" #include "thread_map.h" #include "sane_ctype.h" +#include "map.h" #include "symbol/kallsyms.h" #include "asm/bug.h" #include "stat.h"
tools/perf/util/intel-bts.c +1 -0
@@ -27,6 +27,7 @@#include "evsel.h" #include "evlist.h" #include "machine.h" +#include "map.h" #include "session.h" #include "util.h" #include "thread.h"
tools/perf/util/probe-event.c +1 -0
@@ -41,6 +41,7 @@#include "debug.h" #include "cache.h" #include "color.h" +#include "map.h" #include "symbol.h" #include "thread.h" #include <api/fs/fs.h>
tools/perf/util/scripting-engines/trace-event-perl.c +1 -0
@@ -37,6 +37,7 @@#include "../../perf.h" #include "../callchain.h" #include "../machine.h" +#include "../map.h" #include "../thread.h" #include "../event.h" #include "../trace-event.h"
tools/perf/util/scripting-engines/trace-event-python.c +1 -0
@@ -44,6 +44,7 @@#include "../thread-stack.h" #include "../trace-event.h" #include "../call-path.h" +#include "map.h" #include "thread_map.h" #include "cpumap.h" #include "print_binary.h"
tools/perf/util/session.c +1 -0
@@ -13,6 +13,7 @@#include "evlist.h" #include "evsel.h" #include "memswap.h" +#include "map.h" #include "session.h" #include "tool.h" #include "sort.h"
tools/perf/util/sort.c +1 -0
@@ -6,6 +6,7 @@#include "sort.h" #include "hist.h" #include "comm.h" +#include "map.h" #include "symbol.h" #include "thread.h" #include "evsel.h"
tools/perf/util/symbol-elf.c +1 -0
@@ -6,6 +6,7 @@#include <unistd.h> #include <inttypes.h> +#include "map.h" #include "symbol.h" #include "demangle-java.h" #include "demangle-rust.h"
tools/perf/util/symbol.c +1 -0
@@ -17,6 +17,7 @@#include "util.h" #include "debug.h" #include "machine.h" +#include "map.h" #include "symbol.h" #include "strlist.h" #include "intlist.h"
tools/perf/util/unwind-libdw.c +1 -0
@@ -8,6 +8,7 @@#include "unwind.h" #include "unwind-libdw.h" #include "machine.h" +#include "map.h" #include "thread.h" #include <linux/types.h> #include "event.h"
tools/perf/util/unwind-libunwind-local.c +1 -0
@@ -34,6 +34,7 @@#include "session.h" #include "perf_regs.h" #include "unwind.h" +#include "map.h" #include "symbol.h" #include "util.h" #include "debug.h"
tools/perf/util/unwind-libunwind.c +1 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include "unwind.h" +#include "map.h" #include "thread.h" #include "session.h" #include "debug.h"
tools/perf/util/vdso.c +1 -0
@@ -11,6 +11,7 @@#include "vdso.h" #include "util.h" +#include "map.h" #include "symbol.h" #include "machine.h" #include "thread.h"
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 7/53 perf map: Move structs and prototypes for map groups to a separate header
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
And since machine.h only needs what is in there, make it stop including map.h and instead include this newly introduced map_groups.h instead.
--- tools/perf/arch/arm/tests/dwarf-unwind.c | 1 + tools/perf/arch/arm64/tests/dwarf-unwind.c | 1 + tools/perf/arch/powerpc/tests/dwarf-unwind.c | 1 + tools/perf/arch/x86/tests/dwarf-unwind.c | 1 + tools/perf/ui/stdio/hist.c | 1 + tools/perf/util/machine.h | 2 +- tools/perf/util/map.c | 6 ++ tools/perf/util/map.h | 87 +------------------ tools/perf/util/map_groups.h | 91 ++++++++++++++++++++ tools/perf/util/probe-event.c | 1 + tools/perf/util/symbol-elf.c | 1 + 11 files changed, 106 insertions(+), 87 deletions(-) create mode 100644 tools/perf/util/map_groups.h
tools/perf/arch/arm/tests/dwarf-unwind.c +1 -0
@@ -3,6 +3,7 @@#include "perf_regs.h" #include "thread.h" #include "map.h" +#include "map_groups.h" #include "event.h" #include "debug.h" #include "tests/tests.h"
tools/perf/arch/arm64/tests/dwarf-unwind.c +1 -0
@@ -3,6 +3,7 @@#include "perf_regs.h" #include "thread.h" #include "map.h" +#include "map_groups.h" #include "event.h" #include "debug.h" #include "tests/tests.h"
tools/perf/arch/powerpc/tests/dwarf-unwind.c +1 -0
@@ -3,6 +3,7 @@#include "perf_regs.h" #include "thread.h" #include "map.h" +#include "map_groups.h" #include "event.h" #include "debug.h" #include "tests/tests.h"
tools/perf/arch/x86/tests/dwarf-unwind.c +1 -0
@@ -3,6 +3,7 @@#include "perf_regs.h" #include "thread.h" #include "map.h" +#include "map_groups.h" #include "event.h" #include "debug.h" #include "tests/tests.h"
tools/perf/ui/stdio/hist.c +1 -0
@@ -5,6 +5,7 @@#include "../../util/util.h" #include "../../util/hist.h" #include "../../util/map.h" +#include "../../util/map_groups.h" #include "../../util/sort.h" #include "../../util/evsel.h" #include "../../util/srcline.h"
tools/perf/util/machine.h +1 -1
@@ -4,7 +4,7 @@#include <sys/types.h> #include <linux/rbtree.h> -#include "map.h" +#include "map_groups.h" #include "dso.h" #include "event.h" #include "rwsem.h"
tools/perf/util/map.c +6 -0
@@ -557,6 +557,12 @@ void map_groups__init(struct map_groups *mg, struct machine *machine)refcount_set (&mg->refcnt,1 ); } +void map_groups__insert (struct map_groups *mg,struct map *map) +{ +maps__insert (&mg->maps, map); + map->groups = mg; +} +static void __maps__purge (struct maps *maps) {struct rb_root *root = &maps->entries;
tools/perf/util/map.h +1 -86
112 lines not on this page · raw message
tools/perf/util/map_groups.h new file +91 -0
91 lines not on this page · raw message
tools/perf/util/probe-event.c +1 -0
@@ -42,6 +42,7 @@#include "cache.h" #include "color.h" #include "map.h" +#include "map_groups.h" #include "symbol.h" #include "thread.h" #include <api/fs/fs.h>
tools/perf/util/symbol-elf.c +1 -0
@@ -7,6 +7,7 @@#include <inttypes.h> #include "map.h" +#include "map_groups.h" #include "symbol.h" #include "demangle-java.h" #include "demangle-rust.h"
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 8/53 perf tests: Add missing headers so far obtained indirectly
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
We're going to remove symbol.h from some places and this breaks some of the perf tests, fix it by adding the required includes.
--- tools/perf/tests/sample-parsing.c | 2 ++ tools/perf/tests/sdt.c | 1 + 2 files changed, 3 insertions(+)
tools/perf/tests/sample-parsing.c +2 -0
@@ -1,9 +1,11 @@// SPDX-License-Identifier: GPL-2.0 #include <stdbool.h> #include <inttypes.h> +#include <linux/bitops.h> #include <linux/kernel.h> #include <linux/types.h> +#include "branch.h" #include "util.h" #include "event.h" #include "evsel.h"
tools/perf/tests/sdt.c +1 -0
@@ -3,6 +3,7 @@#include <stdio.h> #include <sys/epoll.h> #include <util/evlist.h> +#include <util/symbol.h> #include <linux/filter.h> #include "tests.h" #include "debug.h"
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 9/53 perf hist: Remove symbol.h from hist.h, just fwd decls are needed
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To reduce the includes dependencies.
--- tools/perf/ui/gtk/annotate.c | 1 + tools/perf/util/auxtrace.c | 1 + tools/perf/util/callchain.c | 1 + tools/perf/util/hist.h | 3 ++- 4 files changed, 5 insertions(+), 1 deletion(-)
tools/perf/ui/gtk/annotate.c +1 -0
@@ -5,6 +5,7 @@#include "util/annotate.h" #include "util/evsel.h" #include "util/map.h" +#include "util/symbol.h" #include "ui/helpline.h" #include <inttypes.h> #include <signal.h>
tools/perf/util/auxtrace.c +1 -0
@@ -41,6 +41,7 @@#include "pmu.h" #include "evsel.h" #include "cpumap.h" +#include "symbol.h" #include "thread_map.h" #include "asm/bug.h" #include "auxtrace.h"
tools/perf/util/callchain.c +1 -0
@@ -26,6 +26,7 @@#include "map.h" #include "callchain.h" #include "branch.h" +#include "symbol.h" #define CALLCHAIN_PARAM_DEFAULT \ .mode = CHAIN_GRAPH_ABS, \
tools/perf/util/hist.h +2 -1
@@ -8,12 +8,13 @@#include "evsel.h" #include "header.h" #include "color.h" -#include "symbol.h" #include "ui/progress.h" struct hist_entry ;struct hist_entry_ops ;struct addr_location ; +struct mem_info ; +struct branch_info ;struct symbol ;enum hist_filter {
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 10/53 perf tools: Add missing include for symbols.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Several places were using definitions found in symbols.h but not including it, getting it by sheer luck from some other headers that now are in the process of removing that include because they don't need it or because simply having struct forward declarations is enough, fix it.
--- tools/perf/builtin-c2c.c | 1 + tools/perf/builtin-inject.c | 1 + tools/perf/builtin-trace.c | 1 + tools/perf/tests/code-reading.c | 1 + tools/perf/tests/dwarf-unwind.c | 1 + tools/perf/ui/browsers/hists.c | 1 + tools/perf/ui/stdio/hist.c | 1 + tools/perf/util/event.c | 1 + tools/perf/util/hist.c | 1 + tools/perf/util/intel-bts.c | 1 + tools/perf/util/machine.c | 1 + tools/perf/util/scripting-engines/trace-event-perl.c | 1 + tools/perf/util/scripting-engines/trace-event-python.c | 1 + tools/perf/util/session.c | 1 + tools/perf/util/thread.c | 1 + tools/perf/util/unwind-libdw.c | 1 + 16 files changed, 16 insertions(+)
tools/perf/builtin-c2c.c +1 -0
@@ -33,6 +33,7 @@#include "ui/browsers/hists.h" #include "thread.h" #include "mem2node.h" +#include "symbol.h" struct c2c_hists {struct hists hists;
tools/perf/builtin-inject.c +1 -0
@@ -20,6 +20,7 @@#include "util/data.h" #include "util/auxtrace.h" #include "util/jit.h" +#include "util/symbol.h" #include "util/thread.h" #include <subcmd/parse-options.h>
tools/perf/builtin-trace.c +1 -0
@@ -30,6 +30,7 @@#include <subcmd/exec-cmd.h> #include "util/machine.h" #include "util/map.h" +#include "util/symbol.h" #include "util/path.h" #include "util/session.h" #include "util/thread.h"
tools/perf/tests/code-reading.c +1 -0
@@ -16,6 +16,7 @@#include "cpumap.h" #include "machine.h" #include "map.h" +#include "symbol.h" #include "event.h" #include "thread.h"
tools/perf/tests/dwarf-unwind.c +1 -0
@@ -10,6 +10,7 @@#include "../util/unwind.h" #include "perf_regs.h" #include "map.h" +#include "symbol.h" #include "thread.h" #include "callchain.h"
tools/perf/ui/browsers/hists.c +1 -0
@@ -12,6 +12,7 @@#include "../../util/evlist.h" #include "../../util/hist.h" #include "../../util/map.h" +#include "../../util/symbol.h" #include "../../util/pstack.h" #include "../../util/sort.h" #include "../../util/util.h"
tools/perf/ui/stdio/hist.c +1 -0
@@ -6,6 +6,7 @@#include "../../util/hist.h" #include "../../util/map.h" #include "../../util/map_groups.h" +#include "../../util/symbol.h" #include "../../util/sort.h" #include "../../util/evsel.h" #include "../../util/srcline.h"
tools/perf/util/event.c +1 -0
@@ -22,6 +22,7 @@#include "thread_map.h" #include "sane_ctype.h" #include "map.h" +#include "symbol.h" #include "symbol/kallsyms.h" #include "asm/bug.h" #include "stat.h"
tools/perf/util/hist.c +1 -0
@@ -11,6 +11,7 @@#include "evsel.h" #include "annotate.h" #include "srcline.h" +#include "symbol.h" #include "thread.h" #include "ui/progress.h" #include <errno.h>
tools/perf/util/intel-bts.c +1 -0
@@ -28,6 +28,7 @@#include "evlist.h" #include "machine.h" #include "map.h" +#include "symbol.h" #include "session.h" #include "util.h" #include "thread.h"
tools/perf/util/machine.c +1 -0
@@ -10,6 +10,7 @@#include "hist.h" #include "machine.h" #include "map.h" +#include "symbol.h" #include "sort.h" #include "strlist.h" #include "thread.h"
tools/perf/util/scripting-engines/trace-event-perl.c +1 -0
@@ -38,6 +38,7 @@#include "../callchain.h" #include "../machine.h" #include "../map.h" +#include "../symbol.h" #include "../thread.h" #include "../event.h" #include "../trace-event.h"
tools/perf/util/scripting-engines/trace-event-python.c +1 -0
@@ -45,6 +45,7 @@#include "../trace-event.h" #include "../call-path.h" #include "map.h" +#include "symbol.h" #include "thread_map.h" #include "cpumap.h" #include "print_binary.h"
tools/perf/util/session.c +1 -0
@@ -14,6 +14,7 @@#include "evsel.h" #include "memswap.h" #include "map.h" +#include "symbol.h" #include "session.h" #include "tool.h" #include "sort.h"
tools/perf/util/thread.c +1 -0
@@ -12,6 +12,7 @@#include "debug.h" #include "namespaces.h" #include "comm.h" +#include "symbol.h" #include "unwind.h" #include <api/fs/fs.h>
tools/perf/util/unwind-libdw.c +1 -0
@@ -9,6 +9,7 @@#include "unwind-libdw.h" #include "machine.h" #include "map.h" +#include "symbol.h" #include "thread.h" #include <linux/types.h> #include "event.h"
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 11/53 perf evsel: No need to include symbol.h in evsel.h, symbol_conf.h is enough
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To reduce the header dependency and avoid unnecessary rebuilds when things change in symbol.h.
--- tools/perf/util/evsel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/evsel.h +1 -1
@@ -8,7 +8,7 @@#include <linux/perf_event.h> #include <linux/types.h> #include "xyarray.h" -#include "symbol.h" +#include "symbol_conf.h" #include "cpumap.h" #include "counts.h"
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 12/53 perf thread: Don't include symbol.h, symbol_conf.h is enough
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Also add stdio.h to get the FILE definition.
--- tools/perf/util/thread.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/thread.h +4 -1
@@ -5,14 +5,17 @@#include <linux/refcount.h> #include <linux/rbtree.h> #include <linux/list.h> +#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include "srccode.h" -#include "symbol.h" +#include "symbol_conf.h" #include <strlist.h> #include <intlist.h> #include "rwsem.h" +struct addr_location ; +struct map ;struct namespaces_event ;struct thread_stack ;struct unwind_libunwind_ops ;
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 13/53 perf tools: Add missing include <callchain.h> in various places
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Its getting it from hist.h and that will go away, as that header doesn't need callchain.h at all.
--- tools/perf/ui/browsers/hists.c | 1 + tools/perf/ui/gtk/hists.c | 1 + tools/perf/ui/hist.c | 1 + tools/perf/ui/stdio/hist.c | 1 + tools/perf/util/config.c | 1 + tools/perf/util/hist.c | 1 + 6 files changed, 6 insertions(+)
tools/perf/ui/browsers/hists.c +1 -0
@@ -8,6 +8,7 @@#include <linux/rbtree.h> #include <sys/ttydefaults.h> +#include "../../util/callchain.h" #include "../../util/evsel.h" #include "../../util/evlist.h" #include "../../util/hist.h"
tools/perf/ui/gtk/hists.c +1 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include "../evlist.h" #include "../cache.h" +#include "../callchain.h" #include "../evsel.h" #include "../sort.h" #include "../hist.h"
tools/perf/ui/hist.c +1 -0
@@ -3,6 +3,7 @@#include <math.h> #include <linux/compiler.h> +#include "../util/callchain.h" #include "../util/hist.h" #include "../util/util.h" #include "../util/sort.h"
tools/perf/ui/stdio/hist.c +1 -0
@@ -2,6 +2,7 @@#include <stdio.h> #include <linux/string.h> +#include "../../util/callchain.h" #include "../../util/util.h" #include "../../util/hist.h" #include "../../util/map.h"
tools/perf/util/config.c +1 -0
@@ -13,6 +13,7 @@#include <sys/param.h> #include "util.h" #include "cache.h" +#include "callchain.h" #include <subcmd/exec-cmd.h> #include "util/event.h" /* proc_map_timeout */ #include "util/hist.h" /* perf_hist_config */
tools/perf/util/hist.c +1 -0
@@ -1,4 +1,5 @@// SPDX-License-Identifier: GPL-2.0 +#include "callchain.h" #include "util.h" #include "build-id.h" #include "hist.h"
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 14/53 perf hist: Remove the needless callchain.h include from hist.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Nothing that is provided by callchain.h is used there, just things that should've be directly included in hist.h, such as rbtree.h and a map_symbol forward declaration.
Remove it so that we reduce the headers dependency tree.
--- tools/perf/util/hist.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/hist.h +2 -1
@@ -2,9 +2,9 @@#ifndef __PERF_HIST_H#define __PERF_HIST_H +#include <linux/rbtree.h> #include <linux/types.h> #include <pthread.h> -#include "callchain.h" #include "evsel.h" #include "header.h" #include "color.h"
@@ -13,6 +13,7 @@struct hist_entry ;struct hist_entry_ops ;struct addr_location ; +struct map_symbol ;struct mem_info ;struct branch_info ;struct symbol ;
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 15/53 perf tests pmu: Add missing headers
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
It needs the definitions for PATH_MAX and snprintf, was getting it by luck from headers it included and that are now being sanitized.
--- tools/perf/tests/pmu.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/tests/pmu.c +2 -0
@@ -4,7 +4,9 @@#include "util.h" #include "tests.h" #include <errno.h> +#include <stdio.h> #include <linux/kernel.h> +#include <linux/limits.h> /* Simulated format definitions. */ static struct test_format {
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 16/53 perf pmu: Remove needless evsel.h include, only needs one fwd decl
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To reduce the header dependency tree.
--- tools/perf/util/pmu.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/pmu.h +2 -1
@@ -6,9 +6,10 @@#include <linux/compiler.h> #include <linux/perf_event.h> #include <stdbool.h> -#include "evsel.h" #include "parse-events.h" +struct perf_evsel_config_term ; +enum {PERF_PMU_FORMAT_VALUE_CONFIG ,PERF_PMU_FORMAT_VALUE_CONFIG1 ,
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 17/53 perf kvm stat: Replace kvm-stat.h includes with forward declarations
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To reduce the include header dependency tree and speed up perf builds.
--- tools/perf/arch/powerpc/util/kvm-stat.c | 1 + tools/perf/arch/s390/util/kvm-stat.c | 1 + tools/perf/arch/x86/util/kvm-stat.c | 1 + tools/perf/util/kvm-stat.h | 7 ++++--- 4 files changed, 7 insertions(+), 3 deletions(-)
tools/perf/arch/powerpc/util/kvm-stat.c +1 -0
@@ -3,6 +3,7 @@#include "util/kvm-stat.h" #include "util/parse-events.h" #include "util/debug.h" +#include "util/evsel.h" #include "book3s_hv_exits.h" #include "book3s_hcalls.h"
tools/perf/arch/s390/util/kvm-stat.c +1 -0
@@ -11,6 +11,7 @@#include <errno.h> #include "../../util/kvm-stat.h" +#include "../../util/evsel.h" #include <asm/sie.h> define_exit_reasons_table (sie_exit_reasons, sie_intercept_code);
tools/perf/arch/x86/util/kvm-stat.c +1 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include <errno.h> #include "../../util/kvm-stat.h" +#include "../../util/evsel.h" #include <asm/svm.h> #include <asm/vmx.h> #include <asm/kvm.h>
tools/perf/util/kvm-stat.h +4 -3
@@ -3,12 +3,13 @@#define __PERF_KVM_STAT_H#include "../perf.h" -#include "evsel.h" -#include "evlist.h" -#include "session.h" #include "tool.h" #include "stat.h" +struct perf_evsel ; +struct perf_evlist ; +struct perf_session ; +struct event_key {#define INVALID_KEY (~0ULL)u64 key;
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 18/53 perf powerpc kvm-stat: Add missing evlist.h header
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
This header was being obtained indirectly, by sheer luck, add it.
--- tools/perf/arch/powerpc/util/kvm-stat.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/arch/powerpc/util/kvm-stat.c +1 -0
@@ -4,6 +4,7 @@#include "util/parse-events.h" #include "util/debug.h" #include "util/evsel.h" +#include "util/evlist.h" #include "book3s_hv_exits.h" #include "book3s_hcalls.h"
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 19/53 perf bpf-loader: Remove unecessary includes from bpf-loader.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To cut the header dep tree, to get unecessary object rebuilds to be reduced when a change happens in headers.
--- tools/perf/util/bpf-loader.c | 1 + tools/perf/util/bpf-loader.h | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-)
tools/perf/util/bpf-loader.c +1 -0
@@ -15,6 +15,7 @@#include <errno.h> #include "perf.h" #include "debug.h" +#include "evlist.h" #include "bpf-loader.h" #include "bpf-prologue.h" #include "probe-event.h"
tools/perf/util/bpf-loader.h +3 -4
@@ -8,11 +8,7 @@#include <linux/compiler.h> #include <linux/err.h> -#include <string.h> #include <bpf/libbpf.h> -#include "probe-event.h" -#include "evlist.h" -#include "debug.h" enum bpf_loader_errno { __BPF_LOADER_ERRNO__START = __LIBBPF_ERRNO__START -100 ,
@@ -44,6 +40,7 @@ enum bpf_loader_errno { };struct perf_evsel ; +struct perf_evlist ;struct bpf_object ;struct parse_events_term ;#define PERF_BPF_PROBE_GROUP "perf_bpf_probe"
@@ -87,6 +84,8 @@ struct perf_evsel *bpf__setup_output_event(struct perf_evlist *evlist, const chaint bpf__strerror_setup_output_event (struct perf_evlist *evlist,int err,char *buf,size_t size);#else #include <errno.h> +#include <string.h> +#include "debug.h" static inline struct bpf_object * bpf__prepare_load(const char *filename __maybe_unused,
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 20/53 perf/aux: Make perf_event accessible to setup_aux()
In reply to Arnaldo Carvalho de MeloFrom: Mathieu Poirier <[email protected]>
When pmu::setup_aux() is called the coresight PMU needs to know which sink to use for the session by looking up the information in the event's attr::config2 field.
As such simply replace the cpu information by the complete perf_event structure and change all affected customers.
--- arch/s390/kernel/perf_cpum_sf.c | 6 +++--- arch/x86/events/intel/bts.c | 4 +++- arch/x86/events/intel/pt.c | 5 +++-- drivers/hwtracing/coresight/coresight-etm-perf.c | 6 +++--- drivers/perf/arm_spe_pmu.c | 6 +++--- include/linux/perf_event.h | 2 +- kernel/events/ring_buffer.c | 2 +- 7 files changed, 17 insertions(+), 14 deletions(-)
arch/s390/kernel/perf_cpum_sf.c +3 -3
@@ -1600,7 +1600,7 @@ static void aux_sdb_init(unsigned long sdb)/* * aux_buffer_setup() - Setup AUX buffer for diagnostic mode sampling -* @cpu: On which to allocate, -1 means current +* @event: Event the buffer is setup for, event->cpu == -1 means current * @pages: Array of pointers to buffer pages passed from perf core * @nr_pages: Total pages * @snapshot: Flag for snapshot mode
@@ -1612,8 +1612,8 @@ static void aux_sdb_init(unsigned long sdb)* * Return the private AUX buffer structure if success or NULL if fails. */ -static void *aux_buffer_setup (int cpu,void **pages,int nr_pages, -bool snapshot) +static void *aux_buffer_setup (struct perf_event *event,void **pages, +int nr_pages,bool snapshot) {struct sf_buffer *sfb;struct aux_buffer *aux;
arch/x86/events/intel/bts.c +3 -1
@@ -77,10 +77,12 @@ static size_t buf_size(struct page *page) }static void * -bts_buffer_setup_aux (int cpu,void **pages,int nr_pages,bool overwrite) +bts_buffer_setup_aux (struct perf_event *event,void **pages, +int nr_pages,bool overwrite) {struct bts_buffer *buf;struct page *page; +int cpu = event->cpu;int node = (cpu ==-1 ) ? cpu :cpu_to_node (cpu);unsigned long offset;size_t size = nr_pages <<PAGE_SHIFT ;
arch/x86/events/intel/pt.c +3 -2
@@ -1114,10 +1114,11 @@ static int pt_buffer_init_topa(struct pt_buffer *buf, unsigned long nr_pages,* Return: Our private PT buffer structure. */ static void * -pt_buffer_setup_aux (int cpu,void **pages,int nr_pages,bool snapshot) +pt_buffer_setup_aux (struct perf_event *event,void **pages, +int nr_pages,bool snapshot) {struct pt_buffer *buf; -int node, ret; +int node, ret, cpu = event->cpu;if (!nr_pages)return NULL ;
drivers/hwtracing/coresight/coresight-etm-perf.c +3 -3
@@ -177,15 +177,15 @@ static void etm_free_aux(void *data)schedule_work (&event_data->work); } -static void *etm_setup_aux (int event_cpu,void **pages, +static void *etm_setup_aux (struct perf_event *event,void **pages,int nr_pages,bool overwrite) { -int cpu; +int cpu = event->cpu;cpumask_t *mask;struct coresight_device *sink;struct etm_event_data *event_data =NULL ; - event_data =alloc_event_data (event_cpu); + event_data =alloc_event_data (cpu);if (!event_data)return NULL ;INIT_WORK (&event_data->work, free_event_data);
drivers/perf/arm_spe_pmu.c +3 -3
@@ -824,10 +824,10 @@ static void arm_spe_pmu_read(struct perf_event *event) { } -static void *arm_spe_pmu_setup_aux (int cpu,void **pages,int nr_pages, -bool snapshot) +static void *arm_spe_pmu_setup_aux (struct perf_event *event,void **pages, +int nr_pages,bool snapshot) { -int i; +int i, cpu = event->cpu;struct page **pglist;struct arm_spe_pmu_buf *buf;
include/linux/perf_event.h +1 -1
@@ -410,7 +410,7 @@ struct pmu {/* * Set up pmu-private data structures for an AUX area */ -void *(*setup_aux) (int cpu,void **pages, +void *(*setup_aux) (struct perf_event *event,void **pages,int nr_pages,bool overwrite);/* optional */
kernel/events/ring_buffer.c +1 -1
@@ -657,7 +657,7 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event, goto out; } - rb->aux_priv = event->pmu->setup_aux (event->cpu, rb->aux_pages, nr_pages, + rb->aux_priv = event->pmu->setup_aux (event, rb->aux_pages, nr_pages, overwrite);if (!rb->aux_priv) goto out;
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 21/53 coresight: perf: Add "sinks" group to PMU directory
In reply to Arnaldo Carvalho de MeloFrom: Mathieu Poirier <[email protected]>
Add a "sinks" directory entry so that users can see all the sinks available in the system in a single place. Individual sink are added as they are registered with the coresight bus.
Committer tests:
Test built on a ubuntu 18.04 container with a cross build environment to arm64, the new field is there, need to find a machine with this feature to do further testing in the future.
root@d15263e5734a:/git/perf# grep CORESIGHT /tmp/build/v5.0-rc2+/.config CONFIG_CORESIGHT=y CONFIG_CORESIGHT_LINKS_AND_SINKS=y CONFIG_CORESIGHT_LINK_AND_SINK_TMC=y CONFIG_CORESIGHT_CATU=y CONFIG_CORESIGHT_SINK_TPIU=y CONFIG_CORESIGHT_SINK_ETBV10=y CONFIG_CORESIGHT_SOURCE_ETM4X=y CONFIG_CORESIGHT_DYNAMIC_REPLICATOR=y CONFIG_CORESIGHT_STM=y CONFIG_CORESIGHT_CPU_DEBUG=m root@d15263e5734a:/git/perf# root@d15263e5734a:/git/perf# file /tmp/build/v5.0-rc2+/drivers/hwtracing/coresight/*.o .../coresight/coresight-catu.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-cpu-debug.mod.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-cpu-debug.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-dynamic-replicator.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-etb10.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-etm-perf.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-etm4x-sysfs.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-etm4x.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-funnel.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-replicator.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-stm.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-tmc-etf.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-tmc-etr.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-tmc.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight-tpiu.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/coresight.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped .../coresight/of_coresight.o: ELF 64-bit MSB relocatable, ARM aarch64, version 1 (SYSV), not stripped root@d15263e5734a:/git/perf#
root@d15263e5734a:/git/perf# pahole -C coresight_device /tmp/build/v5.0-rc2+/drivers/hwtracing/coresight/coresight.o
struct coresight_device {
struct coresight_connection * conns; /* 0 8 */
int nr_inport; /* 8 4 */
int nr_outport; /* 12 4 */
enum coresight_dev_type type; /* 16 4 */
union coresight_dev_subtype subtype; /* 20 8 *//* XXX 4 bytes hole, try to pack */
const struct coresight_ops * ops; /* 32 8 */
struct device dev; /* 40 1408 */
/* XXX last struct has 7 bytes of padding */
/* --- cacheline 22 boundary (1408 bytes) was 40 bytes ago --- */
atomic_t * refcnt; /* 1448 8 */
bool orphan; /* 1456 1 */
bool enable; /* 1457 1 */
bool activated; /* 1458 1 */
/* XXX 5 bytes hole, try to pack */
struct dev_ext_attribute * ea; /* 1464 8 */
/* size: 1472, cachelines: 23, members: 12 */ /* sum members: 1463, holes: 2, sum holes: 9 */ /* paddings: 1, sum paddings: 7 */
};
root@d15263e5734a:/git/perf#
--- .../hwtracing/coresight/coresight-etm-perf.c | 82 +++++++++++++++++++ .../hwtracing/coresight/coresight-etm-perf.h | 6 +- drivers/hwtracing/coresight/coresight.c | 18 ++++ include/linux/coresight.h | 7 +- 4 files changed, 110 insertions(+), 3 deletions(-)
drivers/hwtracing/coresight/coresight-etm-perf.c +82 -0
@@ -14,6 +14,7 @@#include <linux/perf_event.h> #include <linux/percpu-defs.h> #include <linux/slab.h> +#include <linux/stringhash.h> #include <linux/types.h> #include <linux/workqueue.h>
@@ -43,8 +44,18 @@ static const struct attribute_group etm_pmu_format_group = { .attrs = etm_config_formats_attr, }; +static struct attribute *etm_config_sinks_attr[] = { +NULL , +}; + +static const struct attribute_group etm_pmu_sinks_group = { + .name ="sinks" , + .attrs = etm_config_sinks_attr, +}; +static const struct attribute_group *etm_pmu_attr_groups[] = { &etm_pmu_format_group, + &etm_pmu_sinks_group,NULL , };
@@ -479,6 +490,77 @@ int etm_perf_symlink(struct coresight_device *csdev, bool link)return 0 ; } +static ssize_t etm_perf_sink_name_show (struct device *dev, +struct device_attribute *dattr, +char *buf) +{ +struct dev_ext_attribute *ea; + + ea = container_of(dattr, struct dev_ext_attribute, attr); +return scnprintf (buf,PAGE_SIZE ,"0x%lx\n" , (unsigned long )(ea->var)); +} + +int etm_perf_add_symlink_sink (struct coresight_device *csdev) +{ +int ret; +unsigned long hash; +const char *name; +struct device *pmu_dev = etm_pmu.dev; +struct device *pdev = csdev->dev.parent; +struct dev_ext_attribute *ea; + +if (csdev->type !=CORESIGHT_DEV_TYPE_SINK && + csdev->type !=CORESIGHT_DEV_TYPE_LINKSINK ) +return -EINVAL ; + +if (csdev->ea !=NULL ) +return -EINVAL ; + +if (!etm_perf_up) +return -EPROBE_DEFER ; + + ea =devm_kzalloc (pdev,sizeof (*ea),GFP_KERNEL ); +if (!ea) +return -ENOMEM ; + + name =dev_name (pdev); +/* See function coresight_get_sink_by_id() to know where this is used */ + hash =hashlen_hash (hashlen_string (NULL , name)); + + ea->attr.attr.name =devm_kstrdup (pdev, name,GFP_KERNEL ); +if (!ea->attr.attr.name) +return -ENOMEM ; + + ea->attr.attr.mode =0444 ; + ea->attr.show = etm_perf_sink_name_show; + ea->var = (unsigned long *)hash; + + ret =sysfs_add_file_to_group (&pmu_dev->kobj, + &ea->attr.attr,"sinks" ); + +if (!ret) + csdev->ea = ea; + +return ret; +} + +void etm_perf_del_symlink_sink (struct coresight_device *csdev) +{ +struct device *pmu_dev = etm_pmu.dev; +struct dev_ext_attribute *ea = csdev->ea; + +if (csdev->type !=CORESIGHT_DEV_TYPE_SINK && + csdev->type !=CORESIGHT_DEV_TYPE_LINKSINK ) +return ; + +if (!ea) +return ; + +sysfs_remove_file_from_group (&pmu_dev->kobj, + &ea->attr.attr,"sinks" ); + csdev->ea =NULL ; +} +static int __init etm_perf_init (void ) {int ret;
drivers/hwtracing/coresight/coresight-etm-perf.h +5 -1
@@ -59,6 +59,8 @@ struct etm_event_data {#ifdef CONFIG_CORESIGHT int etm_perf_symlink (struct coresight_device *csdev,bool link); +int etm_perf_add_symlink_sink (struct coresight_device *csdev); +void etm_perf_del_symlink_sink (struct coresight_device *csdev);static inline void *etm_perf_sink_config (struct perf_output_handle *handle) {struct etm_event_data *data =perf_get_aux (handle);
@@ -70,7 +72,9 @@ static inline void *etm_perf_sink_config(struct perf_output_handle *handle)#else static inline int etm_perf_symlink (struct coresight_device *csdev,bool link) {return -EINVAL ; } - +int etm_perf_add_symlink_sink (struct coresight_device *csdev) +{return -EINVAL ; } +void etm_perf_del_symlink_sink (struct coresight_device *csdev) {}static inline void *etm_perf_sink_config (struct perf_output_handle *handle) {return NULL ;
drivers/hwtracing/coresight/coresight.c +18 -0
@@ -18,6 +18,7 @@#include <linux/delay.h> #include <linux/pm_runtime.h> +#include "coresight-etm-perf.h" #include "coresight-priv.h" static DEFINE_MUTEX (coresight_mutex);
@@ -1167,6 +1168,22 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) goto err_out; } +if (csdev->type ==CORESIGHT_DEV_TYPE_SINK || + csdev->type ==CORESIGHT_DEV_TYPE_LINKSINK ) { + ret =etm_perf_add_symlink_sink (csdev); + +if (ret) { +device_unregister (&csdev->dev); +/* +* As with the above, all resources are free'd +* explicitly via coresight_device_release() triggered +* from put_device(), which is in turn called from +* function device_unregister(). +*/ + goto err_out; + } + } +mutex_lock (&coresight_mutex);coresight_fixup_device_conns (csdev);
@@ -1185,6 +1202,7 @@ EXPORT_SYMBOL_GPL(coresight_register);void coresight_unregister (struct coresight_device *csdev) { +etm_perf_del_symlink_sink (csdev);/* Remove references of that device in the topology */ coresight_remove_conns (csdev);device_unregister (&csdev->dev);
include/linux/coresight.h +5 -2
@@ -154,8 +154,9 @@ struct coresight_connection {* @orphan: true if the component has connections that haven't been linked. * @enable: 'true' if component is currently part of an active path. * @activated: 'true' only if a _sink_ has been activated. A sink can be -activated but not yet enabled. Enabling for a _sink_ -happens when a source has been selected for that it. +* activated but not yet enabled. Enabling for a _sink_ +* appens when a source has been selected for that it. +* @ea: Device attribute for sink representation under PMU directory. */ struct coresight_device {struct coresight_connection *conns;
@@ -168,7 +169,9 @@ struct coresight_device {atomic_t *refcnt;bool orphan;bool enable;/* true only if configured as part of a path */ +/* sink specific fields */ bool activated;/* true only if a sink is part of a path */ +struct dev_ext_attribute *ea; };#define to_coresight_device (d) container_of(d, struct coresight_device, dev)
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 22/53 coresight: Use event attributes for sink selection
In reply to Arnaldo Carvalho de MeloFrom: Mathieu Poirier <[email protected]>
This patch uses the information conveyed by perf_event::attr::config2 to select a sink to use for the session. That way a sink can easily be selected to be used by more than one source, something that isn't currently possible with the sysfs implementation.
--- .../hwtracing/coresight/coresight-etm-perf.c | 24 +++++------ drivers/hwtracing/coresight/coresight-priv.h | 1 + drivers/hwtracing/coresight/coresight.c | 42 +++++++++++++++++++ 3 files changed, 55 insertions(+), 12 deletions(-)
drivers/hwtracing/coresight/coresight-etm-perf.c +12 -12
@@ -31,11 +31,14 @@ static DEFINE_PER_CPU(struct coresight_device *, csdev_src);PMU_FORMAT_ATTR (cycacc,"config:" __stringify(ETM_OPT_CYCACC ));PMU_FORMAT_ATTR (timestamp,"config:" __stringify(ETM_OPT_TS ));PMU_FORMAT_ATTR (retstack,"config:" __stringify(ETM_OPT_RETSTK )); +/* Sink ID - same for all ETMs */ +PMU_FORMAT_ATTR (sinkid,"config2:0-31" );static struct attribute *etm_config_formats_attr[] = { &format_attr_cycacc.attr, &format_attr_timestamp.attr, &format_attr_retstack.attr, + &format_attr_sinkid.attr,NULL , };
@@ -191,6 +194,7 @@ static void etm_free_aux(void *data)static void *etm_setup_aux (struct perf_event *event,void **pages,int nr_pages,bool overwrite) { +u32 id;int cpu = event->cpu;cpumask_t *mask;struct coresight_device *sink;
@@ -201,18 +205,14 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,return NULL ;INIT_WORK (&event_data->work, free_event_data); -/* -* In theory nothing prevent tracers in a trace session from being -* associated with different sinks, nor having a sink per tracer. But -* until we have HW with this kind of topology we need to assume tracers -* in a trace session are using the same sink. Therefore go through -* the coresight bus and pick the first enabled sink. -* -* When operated from sysFS users are responsible to enable the sink -* while from perf, the perf tools will do it based on the choice made -* on the cmd line. As such the "enable_sink" flag in sysFS is reset. -*/ - sink =coresight_get_enabled_sink (true); +/* First get the selected sink from user space. */ +if (event->attr.config2) { + id = (u32 )event->attr.config2; + sink =coresight_get_sink_by_id (id); + }else { + sink =coresight_get_enabled_sink (true); + } +if (!sink || !sink_ops (sink)->alloc_buffer) goto err;
drivers/hwtracing/coresight/coresight-priv.h +1 -0
@@ -147,6 +147,7 @@ void coresight_disable_path(struct list_head *path);int coresight_enable_path (struct list_head *path,u32 mode,void *sink_data);struct coresight_device *coresight_get_sink (struct list_head *path);struct coresight_device *coresight_get_enabled_sink (bool reset); +struct coresight_device *coresight_get_sink_by_id (u32 id);struct list_head *coresight_build_path (struct coresight_device *csdev,struct coresight_device *sink);void coresight_release_path (struct list_head *path);
drivers/hwtracing/coresight/coresight.c +42 -0
54 lines not on this page · raw message
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 23/53 perf pmu: Move EVENT_SOURCE_DEVICE_PATH to PMU header file
In reply to Arnaldo Carvalho de MeloFrom: Mathieu Poirier <[email protected]>
Move definition of EVENT_SOURCE_DEVICE_PATH to pmu.h so that it can be used by other files than pmu.c
--- tools/perf/util/pmu.c | 2 -- tools/perf/util/pmu.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/pmu.c +0 -2
@@ -29,8 +29,6 @@ struct perf_pmu_format {struct list_head list; }; -#define EVENT_SOURCE_DEVICE_PATH "/bus/event_source/devices/" -int perf_pmu_parse (struct list_head *list,char *name);extern FILE *perf_pmu_in;
tools/perf/util/pmu.h +1 -0
@@ -17,6 +17,7 @@ enum { };#define PERF_PMU_FORMAT_BITS 64 +#define EVENT_SOURCE_DEVICE_PATH "/bus/event_source/devices/"struct perf_event_attr ;
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 24/53 perf arm cs-etm: Use event attributes to send sink information to kernel
In reply to Arnaldo Carvalho de MeloFrom: Mathieu Poirier <[email protected]>
The communication of sink information for a trace session doesn't work when more than on CPU is involved in the scenario due to the static nature of sysfs. As such communicate the sink information to each event by using the perf_event::attr:config2 attribute. The information sent to the kernel is an hash of the sink's name, which is unique in a system.
--- tools/perf/arch/arm/util/cs-etm.c | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
tools/perf/arch/arm/util/cs-etm.c +44 -0
@@ -5,6 +5,7 @@*/ #include <api/fs/fs.h> +#include <linux/bits.h> #include <linux/bitops.h> #include <linux/compiler.h> #include <linux/coresight-pmu.h>
@@ -22,6 +23,7 @@#include "../../util/thread_map.h" #include "../../util/cs-etm.h" +#include <errno.h> #include <stdlib.h> #include <sys/stat.h>
@@ -60,10 +62,48 @@ static int cs_etm_parse_snapshot_options(struct auxtrace_record *itr,return 0 ; } +static int cs_etm_set_sink_attr (struct perf_pmu *pmu, +struct perf_evsel *evsel) +{ +char msg[BUFSIZ ], path[PATH_MAX ], *sink; +struct perf_evsel_config_term *term; +int ret = -EINVAL ; +u32 hash; + +if (evsel->attr.config2 &GENMASK (31 ,0 )) +return 0 ; + +list_for_each_entry (term, &evsel->config_terms, list) { +if (term->type !=PERF_EVSEL__CONFIG_TERM_DRV_CFG ) +continue ; + + sink = term->val.drv_cfg; +snprintf (path,PATH_MAX ,"sinks/%s" , sink); + + ret =perf_pmu__scan_file (pmu, path,"%x" , &hash); +if (ret !=1 ) { +pr_err ("failed to set sink \"%s\" on event %s with %d (%s)\n" , + sink,perf_evsel__name (evsel), errno, +str_error_r (errno, msg,sizeof (msg))); +return ret; + } + + evsel->attr.config2 |= hash; +return 0 ; + } + +/* +* No sink was provided on the command line - for _now_ treat +* this as an error. +*/ +return ret; +} +static int cs_etm_recording_options (struct auxtrace_record *itr,struct perf_evlist *evlist,struct record_opts *opts) { +int ret;struct cs_etm_recording *ptr = container_of(itr, struct cs_etm_recording, itr);struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu;
@@ -92,6 +132,10 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,if (!cs_etm_evsel)return 0 ; + ret =cs_etm_set_sink_attr (cs_etm_pmu, cs_etm_evsel); +if (ret) +return ret; +if (opts->use_clockid) {pr_err ("Cannot use clockid (-k option) with %s\n" ,CORESIGHT_ETM_PMU_NAME );
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 25/53 perf coresight: Remove set_drv_config() API
In reply to Arnaldo Carvalho de MeloFrom: Mathieu Poirier <[email protected]>
Now that the event's config2 attribute is used to communicate sink selection to the kernel, remove the old set_drv_config() implementation since it is no longer needed.
--- tools/perf/arch/arm/util/cs-etm.c | 54 ------------------------------- tools/perf/arch/arm/util/cs-etm.h | 3 -- tools/perf/arch/arm/util/pmu.c | 2 -- 3 files changed, 59 deletions(-)
tools/perf/arch/arm/util/cs-etm.c +0 -54
@@ -27,9 +27,6 @@#include <stdlib.h> #include <sys/stat.h> -#define ENABLE_SINK_MAX 128 -#define CS_BUS_DEVICE_PATH "/bus/coresight/devices/" -struct cs_etm_recording {struct auxtrace_record itr;struct perf_pmu *cs_etm_pmu;
@@ -642,54 +639,3 @@ struct auxtrace_record *cs_etm_record_init(int *err) out:return NULL ; } - -static FILE *cs_device__open_file (const char *name) -{ -struct stat st; -char path[PATH_MAX ]; -const char *sysfs; - - sysfs =sysfs__mountpoint (); -if (!sysfs) -return NULL ; - -snprintf (path,PATH_MAX , -"%s" CS_BUS_DEVICE_PATH "%s" , sysfs, name); - -if (stat (path, &st) <0 ) -return NULL ; - -return fopen (path,"w" ); - -} - -static int __printf(2, 3) cs_device__print_file(const char *name, const char *fmt, ...) -{ - va_list args; -FILE *file; -int ret = -EINVAL ; - - va_start(args, fmt); - file =cs_device__open_file (name); - if (file) { - ret =vfprintf (file, fmt, args); -fclose (file); - } -va_end (args); -return ret; -} - -int cs_etm_set_drv_config (struct perf_evsel_config_term *term) -{ -int ret; -char enable_sink[ENABLE_SINK_MAX ]; - -snprintf (enable_sink,ENABLE_SINK_MAX ,"%s/%s" , - term->val.drv_cfg,"enable_sink" ); - - ret =cs_device__print_file (enable_sink,"%d" ,1 ); -if (ret <0 ) -return ret; - -return 0 ; -}
tools/perf/arch/arm/util/cs-etm.h +0 -3
@@ -7,9 +7,6 @@#ifndef INCLUDE__PERF_CS_ETM_H__ #define INCLUDE__PERF_CS_ETM_H__ -#include "../../util/evsel.h" -struct auxtrace_record *cs_etm_record_init (int *err); -int cs_etm_set_drv_config (struct perf_evsel_config_term *term);#endif
tools/perf/arch/arm/util/pmu.c +0 -2
@@ -9,7 +9,6 @@#include <linux/perf_event.h> #include <linux/string.h> -#include "cs-etm.h" #include "arm-spe.h" #include "../../util/pmu.h"
@@ -20,7 +19,6 @@ struct perf_event_attrif (!strcmp (pmu->name,CORESIGHT_ETM_PMU_NAME )) {/* add ETM default config here */ pmu->selectable = true; - pmu->set_drv_config = cs_etm_set_drv_config;#if defined(__aarch64__) } else if (strstarts(pmu->name, ARM_SPE_PMU_NAME)) {return arm_spe_pmu_default_config (pmu);
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 26/53 perf pmu: Remove set_drv_config API
In reply to Arnaldo Carvalho de MeloFrom: Mathieu Poirier <[email protected]>
CoreSight was the only client of the PMU's set_drv_config() API. Now that it is no longer needed by CoreSight remove it from the code base.
--- tools/perf/builtin-record.c | 10 ----- tools/perf/builtin-stat.c | 9 ---- tools/perf/builtin-top.c | 13 ------ tools/perf/util/Build | 1 - tools/perf/util/drv_configs.c | 78 ----------------------------------- tools/perf/util/drv_configs.h | 26 ------------ tools/perf/util/pmu.h | 1 - 7 files changed, 138 deletions(-) delete mode 100644 tools/perf/util/drv_configs.c delete mode 100644 tools/perf/util/drv_configs.h
tools/perf/builtin-record.c +0 -10
@@ -23,7 +23,6 @@#include "util/evlist.h" #include "util/evsel.h" #include "util/debug.h" -#include "util/drv_configs.h" #include "util/session.h" #include "util/tool.h" #include "util/symbol.h"
@@ -567,7 +566,6 @@ static int record__open(struct record *rec)struct perf_evlist *evlist = rec->evlist;struct perf_session *session = rec->session;struct record_opts *opts = &rec->opts; -struct perf_evsel_config_term *err_term;int rc =0 ;/*
@@ -620,14 +618,6 @@ static int record__open(struct record *rec) goto out; } -if (perf_evlist__apply_drv_configs (evlist, &pos, &err_term)) { -pr_err ("failed to set config \"%s\" on event %s with %d (%s)\n" , - err_term->val.drv_cfg,perf_evsel__name (pos), errno, -str_error_r (errno, msg,sizeof (msg))); - rc =-1 ; - goto out; - } - rc =record__mmap (rec);if (rc) goto out;
tools/perf/builtin-stat.c +0 -9
@@ -52,7 +52,6 @@#include "util/evlist.h" #include "util/evsel.h" #include "util/debug.h" -#include "util/drv_configs.h" #include "util/color.h" #include "util/stat.h" #include "util/header.h"
@@ -417,7 +416,6 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)int status =0 ;const bool forks = (argc >0 );bool is_pipe =STAT_RECORD ? perf_stat.data.is_pipe : false; -struct perf_evsel_config_term *err_term;if (interval) { ts.tv_sec = interval /USEC_PER_MSEC ;
@@ -514,13 +512,6 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)return -1 ; } -if (perf_evlist__apply_drv_configs (evsel_list, &counter, &err_term)) { -pr_err ("failed to set config \"%s\" on event %s with %d (%s)\n" , - err_term->val.drv_cfg,perf_evsel__name (counter), errno, -str_error_r (errno, msg,sizeof (msg))); -return -1 ; - } -if (STAT_RECORD ) {int err, fd =perf_data__fd (&perf_stat.data);
tools/perf/builtin-top.c +0 -13
@@ -25,7 +25,6 @@#include "util/bpf-event.h" #include "util/config.h" #include "util/color.h" -#include "util/drv_configs.h" #include "util/evlist.h" #include "util/evsel.h" #include "util/event.h"
@@ -1186,10 +1185,6 @@ static void init_process_thread(struct perf_top *top)static int __cmd_top (struct perf_top *top) { -char msg[512 ]; -struct perf_evsel *pos; -struct perf_evsel_config_term *err_term; -struct perf_evlist *evlist = top->evlist;struct record_opts *opts = &top->record_opts;pthread_t thread, thread_process;int ret;
@@ -1240,14 +1235,6 @@ static int __cmd_top(struct perf_top *top)if (ret) goto out_delete; - ret =perf_evlist__apply_drv_configs (evlist, &pos, &err_term); -if (ret) { -pr_err ("failed to set config \"%s\" on event %s with %d (%s)\n" , - err_term->val.drv_cfg,perf_evsel__name (pos), errno, -str_error_r (errno, msg,sizeof (msg))); - goto out_delete; - } - top->session->evlist = top->evlist;perf_session__set_id_hdr_size (top->session);
tools/perf/util/Build +0 -1
@@ -107,7 +107,6 @@ libperf-y += term.o libperf-y += help-unknown-cmd.o libperf-y += mem-events.o libperf-y += vsprintf.o -libperf-y += drv_configs.o libperf-y += units.o libperf-y += time-utils.o libperf-y += expr-bison.o
tools/perf/util/drv_configs.c deleted +0 -78
78 lines not on this page · raw message
tools/perf/util/drv_configs.h deleted +0 -26
@@ -1,26 +0,0 @@ -/* -* drv_configs.h: Interface to apply PMU specific configuration -* Copyright (c) 2016-2018, Linaro Ltd. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -*/ - -#ifndef __PERF_DRV_CONFIGS_H -#define __PERF_DRV_CONFIGS_H - -#include "drv_configs.h" -#include "evlist.h" -#include "evsel.h" - -int perf_evlist__apply_drv_configs (struct perf_evlist *evlist, -struct perf_evsel **err_evsel, -struct perf_evsel_config_term **term); -#endif
tools/perf/util/pmu.h +0 -1
@@ -31,7 +31,6 @@ struct perf_pmu {struct list_head format;/* HEAD struct perf_pmu_format -> list */ struct list_head aliases;/* HEAD struct perf_pmu_alias -> list */ struct list_head list;/* ELEM */ -int (*set_drv_config) (struct perf_evsel_config_term *term); };struct perf_pmu_info {
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 27/53 perf record: Allocate affinity masks
In reply to Arnaldo Carvalho de MeloFrom: Alexey Budankov <[email protected]>
Allocate affinity option and masks for mmap data buffers and record thread as well as initialize allocated objects.
--- tools/perf/builtin-record.c | 13 ++++++++++++- tools/perf/perf.h | 8 ++++++++ tools/perf/util/evlist.c | 6 +++--- tools/perf/util/evlist.h | 2 +- tools/perf/util/mmap.c | 2 ++ tools/perf/util/mmap.h | 3 ++- 6 files changed, 28 insertions(+), 6 deletions(-)
tools/perf/builtin-record.c +12 -1
@@ -81,12 +81,17 @@ struct record {bool timestamp_boundary;struct switch_output switch_output;unsigned long long samples; +cpu_set_t affinity_mask; };static volatile int auxtrace_record__snapshot_started;static DEFINE_TRIGGER (auxtrace_snapshot_trigger);static DEFINE_TRIGGER (switch_output_trigger); +static const char *affinity_tags[PERF_AFFINITY_MAX ] = { +"SYS" ,"NODE" ,"CPU" +}; +static bool switch_output_signal (struct record *rec) { return rec->switch_output.signal &&
@@ -533,7 +538,8 @@ static int record__mmap_evlist(struct record *rec,if (perf_evlist__mmap_ex (evlist, opts->mmap_pages, opts->auxtrace_mmap_pages, - opts->auxtrace_snapshot_mode, opts->nr_cblocks) <0 ) { + opts->auxtrace_snapshot_mode, + opts->nr_cblocks, opts->affinity) <0 ) {if (errno ==EPERM ) {pr_err ("Permission error mapping pages.\n" "Consider increasing "
@@ -1977,6 +1983,9 @@ int cmd_record(int argc, const char **argv)# undef REASON#endif +CPU_ZERO (&rec->affinity_mask); + rec->opts.affinity =PERF_AFFINITY_SYS ; + rec->evlist =perf_evlist__new ();if (rec->evlist ==NULL )return -ENOMEM ;
@@ -2140,6 +2149,8 @@ int cmd_record(int argc, const char **argv)if (verbose >0 )pr_info ("nr_cblocks: %d\n" , rec->opts.nr_cblocks); +pr_debug ("affinity: %s\n" , affinity_tags[rec->opts.affinity]); + err =__cmd_record (&record, argc, argv); out:perf_evlist__delete (rec->evlist);
tools/perf/perf.h +8 -0
@@ -84,6 +84,14 @@ struct record_opts {clockid_t clockid;u64 clockid_res_ns;int nr_cblocks; +int affinity; +}; + +enum perf_affinity { +PERF_AFFINITY_SYS =0 , +PERF_AFFINITY_NODE , +PERF_AFFINITY_CPU , +PERF_AFFINITY_MAX };struct option ;
tools/perf/util/evlist.c +3 -3
@@ -1022,7 +1022,7 @@ int perf_evlist__parse_mmap_pages(const struct option *opt, const char *str,*/ int perf_evlist__mmap_ex (struct perf_evlist *evlist,unsigned int pages,unsigned int auxtrace_pages, -bool auxtrace_overwrite,int nr_cblocks) +bool auxtrace_overwrite,int nr_cblocks,int affinity) {struct perf_evsel *evsel;const struct cpu_map *cpus = evlist->cpus;
@@ -1032,7 +1032,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,* Its value is decided by evsel's write_backward. * So &mp should not be passed through const pointer. */ -struct mmap_params mp = { .nr_cblocks = nr_cblocks }; +struct mmap_params mp = { .nr_cblocks = nr_cblocks, .affinity = affinity };if (!evlist->mmap) evlist->mmap =perf_evlist__alloc_mmap (evlist, false);
@@ -1064,7 +1064,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages,int perf_evlist__mmap (struct perf_evlist *evlist,unsigned int pages) { -return perf_evlist__mmap_ex (evlist, pages,0 , false,0 ); +return perf_evlist__mmap_ex (evlist, pages,0 , false,0 ,PERF_AFFINITY_SYS ); }int perf_evlist__create_maps (struct perf_evlist *evlist,struct target *target)
tools/perf/util/evlist.h +1 -1
@@ -165,7 +165,7 @@ unsigned long perf_event_mlock_kb_in_pages(void);int perf_evlist__mmap_ex (struct perf_evlist *evlist,unsigned int pages,unsigned int auxtrace_pages, -bool auxtrace_overwrite,int nr_cblocks); +bool auxtrace_overwrite,int nr_cblocks,int affinity);int perf_evlist__mmap (struct perf_evlist *evlist,unsigned int pages);void perf_evlist__munmap (struct perf_evlist *evlist);
tools/perf/util/mmap.c +2 -0
@@ -343,6 +343,8 @@ int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd, int c map->fd = fd; map->cpu = cpu; +CPU_ZERO (&map->affinity_mask); +if (auxtrace_mmap__mmap (&map->auxtrace_mmap, &mp->auxtrace_mp, map->base, fd))return -1 ;
tools/perf/util/mmap.h +2 -1
@@ -38,6 +38,7 @@ struct perf_mmap { int nr_cblocks; } aio;#endif +cpu_set_t affinity_mask; };/*
@@ -69,7 +70,7 @@ enum bkw_mmap_state { };struct mmap_params { -int prot, mask, nr_cblocks; +int prot, mask, nr_cblocks, affinity;struct auxtrace_mmap_params auxtrace_mp; };
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 28/53 perf record: Bind the AIO user space buffers to nodes
In reply to Arnaldo Carvalho de MeloFrom: Alexey Budankov <[email protected]>
Allocate and bind AIO user space buffers to the memory nodes that mmap kernel buffers are bound to.
--- tools/perf/util/mmap.c | 77 +++++++++++++++++++++++++++++++++++++--- tools/perf/util/setup.py | 5 +++ 2 files changed, 78 insertions(+), 4 deletions(-)
tools/perf/util/mmap.c +73 -4
@@ -10,6 +10,9 @@#include <sys/mman.h> #include <inttypes.h> #include <asm/bug.h> +#ifdef HAVE_LIBNUMA_SUPPORT +#include <numaif.h> +#endif #include "debug.h" #include "event.h" #include "mmap.h"
@@ -154,9 +157,72 @@ void __weak auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp __mayb }#ifdef HAVE_AIO_SUPPORT + +#ifdef HAVE_LIBNUMA_SUPPORT +static int perf_mmap__aio_alloc (struct perf_mmap *map,int idx) +{ + map->aio.data[idx] =mmap (NULL ,perf_mmap__mmap_len (map),PROT_READ |PROT_WRITE , +MAP_PRIVATE |MAP_ANONYMOUS ,0 ,0 ); +if (map->aio.data[idx] ==MAP_FAILED ) { + map->aio.data[idx] =NULL ; +return -1 ; + } + +return 0 ; +} + +static void perf_mmap__aio_free (struct perf_mmap *map,int idx) +{ +if (map->aio.data[idx]) { +munmap (map->aio.data[idx],perf_mmap__mmap_len (map)); + map->aio.data[idx] =NULL ; + } +} + +static int perf_mmap__aio_bind (struct perf_mmap *map,int idx,int cpu,int affinity) +{ +void *data; +size_t mmap_len; +unsigned long node_mask; + +if (affinity !=PERF_AFFINITY_SYS &&cpu__max_node () >1 ) { + data = map->aio.data[idx]; + mmap_len =perf_mmap__mmap_len (map); + node_mask =1UL <<cpu__get_node (cpu); +if (mbind (data, mmap_len,MPOL_BIND , &node_mask,1 ,0 )) { +pr_err ("Failed to bind [%p-%p] AIO buffer to node %d: error %m\n" , + data, data + mmap_len,cpu__get_node (cpu)); +return -1 ; + } + } + +return 0 ; +} +#else +static int perf_mmap__aio_alloc (struct perf_mmap *map,int idx) +{ + map->aio.data[idx] =malloc (perf_mmap__mmap_len (map)); +if (map->aio.data[idx] ==NULL ) +return -1 ; + +return 0 ; +} + +static void perf_mmap__aio_free (struct perf_mmap *map,int idx) +{ +zfree (&(map->aio.data[idx])); +} + +static int perf_mmap__aio_bind (struct perf_mmap *map__maybe_unused ,int idx__maybe_unused , +int cpu__maybe_unused ,int affinity__maybe_unused ) +{ +return 0 ; +} +#endif +static int perf_mmap__aio_mmap (struct perf_mmap *map,struct mmap_params *mp) { -int delta_max, i, prio; +int delta_max, i, prio, ret; map->aio.nr_cblocks = mp->nr_cblocks;if (map->aio.nr_cblocks) {
@@ -177,11 +243,14 @@ static int perf_mmap__aio_mmap(struct perf_mmap *map, struct mmap_params *mp) } delta_max =sysconf (_SC_AIO_PRIO_DELTA_MAX);for (i =0 ; i < map->aio.nr_cblocks; ++i) { - map->aio.data[i] =malloc (perf_mmap__mmap_len (map)); -if (!map->aio.data[i]) { + ret =perf_mmap__aio_alloc (map, i); +if (ret ==-1 ) {pr_debug2 ("failed to allocate data buffer area, error %m" );return -1 ; } + ret =perf_mmap__aio_bind (map, i, map->cpu, mp->affinity); +if (ret ==-1 ) +return -1 ;/* * Use cblock.aio_fildes value different from -1 * to denote started aio write operation on the
@@ -210,7 +279,7 @@ static void perf_mmap__aio_munmap(struct perf_mmap *map)int i;for (i =0 ; i < map->aio.nr_cblocks; ++i) -zfree (&map->aio.data[i]); +perf_mmap__aio_free (map, i);if (map->aio.data)zfree (&map->aio.data);zfree (&map->aio.cblocks);
tools/perf/util/setup.py +5 -0
@@ -53,9 +53,14 @@ ext_sources = [f.strip() for f in open('util/python-ext-sources') # use full paths with source files ext_sources = list(map(lambda x: '%s/%s' % (src_perf, x) , ext_sources)) +extra_libraries = [] +if '-DHAVE_LIBNUMA_SUPPORT' in cflags: + extra_libraries = [ 'numa' ] + perf = Extension('perf', sources = ext_sources, include_dirs = ['util/include'], + libraries = extra_libraries, extra_compile_args = cflags, extra_objects = [libtraceevent, libapikfs], )
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 29/53 perf tools: Add fallback versions for CPU_{OR,EQUAL}()
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
From the glibc sources, so that we can keep the tooling buildable in older systems while using recent sched.h CPU_ macros.
--- tools/perf/util/cpu-set-sched.h | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tools/perf/util/cpu-set-sched.h
tools/perf/util/cpu-set-sched.h new file +50 -0
@@ -0,0 +1,50 @@ +// SPDX-License-Identifier: LGPL-2.1 +// Definitions taken from glibc for use with older systems, same licensing. +#ifndef _CPU_SET_SCHED_PERF_H +#define _CPU_SET_SCHED_PERF_H + +#include <features.h> +#include <sched.h> + +#ifndef CPU_EQUAL +#ifndef __CPU_EQUAL_S +#if __GNUC_PREREQ (2 ,91 ) +# define __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2) \ + (__builtin_memcmp (cpusetp1, cpusetp2, setsize) == 0) +#else +# define __CPU_EQUAL_S (setsize, cpusetp1, cpusetp2) \ + (__extension__ \ + ({ const __cpu_mask *__arr1 = (cpusetp1)->__bits; \ + const __cpu_mask *__arr2 = (cpusetp2)->__bits; \ + size_t __imax = (setsize) / sizeof (__cpu_mask); \ + size_t __i; \ + for (__i = 0; __i < __imax; ++__i) \ + if (__arr1[__i] != __arr2[__i]) \ + break; \ + __i == __imax; })) +#endif +#endif // __CPU_EQUAL_S + +#define CPU_EQUAL (cpusetp1, cpusetp2) \ + __CPU_EQUAL_S (sizeof (cpu_set_t), cpusetp1, cpusetp2) +#endif // CPU_EQUAL + +#ifndef CPU_OR +#ifndef __CPU_OP_S +#define __CPU_OP_S (setsize, destset, srcset1, srcset2, op) \ + (__extension__ \ + ({ cpu_set_t *__dest = (destset); \ + const __cpu_mask *__arr1 = (srcset1)->__bits; \ + const __cpu_mask *__arr2 = (srcset2)->__bits; \ + size_t __imax = (setsize) / sizeof (__cpu_mask); \ + size_t __i; \ + for (__i = 0; __i < __imax; ++__i) \ + ((__cpu_mask *) __dest->__bits)[__i] = __arr1[__i] op __arr2[__i]; \ + __dest; })) +#endif // __CPU_OP_S + +#define CPU_OR (destset, srcset1, srcset2) \ + __CPU_OP_S (sizeof (cpu_set_t), destset, srcset1, srcset2, |) +#endif // CPU_OR + +#endif // _CPU_SET_SCHED_PERF_H
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 30/53 perf record: Apply affinity masks when reading mmap buffers
In reply to Arnaldo Carvalho de MeloFrom: Alexey Budankov <[email protected]>
Build node cpu masks for mmap data buffers. Apply node cpu masks to tool thread every time it references data buffers cross node or cross cpu.
--- tools/perf/builtin-record.c | 15 +++++++++++++++ tools/perf/util/cpumap.c | 10 ++++++++++ tools/perf/util/cpumap.h | 1 + tools/perf/util/mmap.c | 28 +++++++++++++++++++++++++++- 4 files changed, 53 insertions(+), 1 deletion(-)
tools/perf/builtin-record.c +15 -0
@@ -38,6 +38,7 @@#include "util/bpf-loader.h" #include "util/trigger.h" #include "util/perf-hooks.h" +#include "util/cpu-set-sched.h" #include "util/time-utils.h" #include "util/units.h" #include "util/bpf-event.h"
@@ -536,6 +537,9 @@ static int record__mmap_evlist(struct record *rec,struct record_opts *opts = &rec->opts;char msg[512 ]; +if (opts->affinity !=PERF_AFFINITY_SYS ) +cpu__setup_cpunode_map (); + if (perf_evlist__mmap_ex(evlist, opts->mmap_pages, opts->auxtrace_mmap_pages, opts->auxtrace_snapshot_mode,
@@ -719,6 +723,16 @@ static struct perf_event_header finished_round_event = { .type = PERF_RECORD_FINISHED_ROUND, }; +static void record__adjust_affinity (struct record *rec,struct perf_mmap *map) +{ +if (rec->opts.affinity !=PERF_AFFINITY_SYS && + !CPU_EQUAL (&rec->affinity_mask, &map->affinity_mask)) { +CPU_ZERO (&rec->affinity_mask); +CPU_OR (&rec->affinity_mask, &rec->affinity_mask, &map->affinity_mask); +sched_setaffinity (0 ,sizeof (rec->affinity_mask), &rec->affinity_mask); + } +} +static int record__mmap_read_evlist (struct record *rec,struct perf_evlist *evlist,bool overwrite) {
@@ -746,6 +760,7 @@ static int record__mmap_read_evlist(struct record *rec, struct perf_evlist *evlistruct perf_mmap *map = &maps[i];if (map->base) { +record__adjust_affinity (rec, map);if (!record__aio_enabled (rec)) {if (perf_mmap__push (map, rec, record__pushfn) !=0 ) { rc =-1 ;
tools/perf/util/cpumap.c +10 -0
@@ -730,3 +730,13 @@ size_t cpu_map__snprint_mask(struct cpu_map *map, char *buf, size_t size) buf[size -1 ] ='\0' ;return ptr - buf; } + +const struct cpu_map *cpu_map__online (void )/* thread unsafe */ +{ +static const struct cpu_map *online =NULL ; + +if (!online) + online =cpu_map__new (NULL );/* from /sys/devices/system/cpu/online */ + +return online; +}
tools/perf/util/cpumap.h +1 -0
@@ -29,6 +29,7 @@ int cpu_map__get_core_id(int cpu);int cpu_map__get_core (struct cpu_map *map,int idx,void *data);int cpu_map__build_socket_map (struct cpu_map *cpus,struct cpu_map **sockp);int cpu_map__build_core_map (struct cpu_map *cpus,struct cpu_map **corep); +const struct cpu_map *cpu_map__online (void );/* thread unsafe */ struct cpu_map *cpu_map__get (struct cpu_map *map);void cpu_map__put (struct cpu_map *map);
tools/perf/util/mmap.c +27 -1
@@ -383,6 +383,32 @@ void perf_mmap__munmap(struct perf_mmap *map)auxtrace_mmap__munmap (&map->auxtrace_mmap); } +static void build_node_mask (int node,cpu_set_t *mask) +{ +int c, cpu, nr_cpus; +const struct cpu_map *cpu_map =NULL ; + + cpu_map =cpu_map__online (); +if (!cpu_map) +return ; + + nr_cpus =cpu_map__nr (cpu_map); +for (c =0 ; c < nr_cpus; c++) { + cpu = cpu_map->map[c];/* map c index to online cpu index */ +if (cpu__get_node (cpu) == node) +CPU_SET (cpu, mask); + } +} + +static void perf_mmap__setup_affinity_mask (struct perf_mmap *map,struct mmap_params *mp) +{ +CPU_ZERO (&map->affinity_mask); +if (mp->affinity ==PERF_AFFINITY_NODE &&cpu__max_node () >1 ) +build_node_mask (cpu__get_node (map->cpu), &map->affinity_mask); +else if (mp->affinity ==PERF_AFFINITY_CPU ) +CPU_SET (map->cpu, &map->affinity_mask); +} +int perf_mmap__mmap (struct perf_mmap *map,struct mmap_params *mp,int fd,int cpu) {/*
@@ -412,7 +438,7 @@ int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd, int c map->fd = fd; map->cpu = cpu; -CPU_ZERO (&map->affinity_mask); +perf_mmap__setup_affinity_mask (map, mp);if (auxtrace_mmap__mmap (&map->auxtrace_mmap, &mp->auxtrace_mp, map->base, fd))
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 31/53 perf clang: Do not use 'return std::move(something)'
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
It prevents copy elision, generating this warning when building with fedora:rawhide's clang:
clang version 7.0.1 (Fedora 7.0.1-2.fc30)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/9 Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/9 Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/9 Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
$ make -C tools/perf CC=clang LIBCLANGLLVM=1
<SNIP>
util/c++/clang.cpp: In function 'std::unique_ptr<llvm::SmallVectorImpl<char> > perf::getBPFObjectFromModule(llvm::Module*)':
util/c++/clang.cpp:163:18: error: moving a local object in a return statement prevents copy elision [-Werror=pessimizing-move]
163 | return std::move(Buffer);
| ~~~~~~~~~^~~~~~~~
util/c++/clang.cpp:163:18: note: remove 'std::move' call
cc1plus: all warnings being treated as errors
<SNIP>References:
http://www.cplusplus.com/forum/general/186411/#msg908572
https://en.cppreference.com/w/cpp/language/return#Notes
https://en.cppreference.com/w/cpp/language/copy_elision
--- tools/perf/util/c++/clang.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/c++/clang.cpp +1 -1
@@ -160,7 +160,7 @@ getBPFObjectFromModule(llvm::Module *Module) } PM.run(*Module); - return std::move(Buffer); + return Buffer; } }
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 32/53 perf hists: Add argument to hists__resort_cb_t callback
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Add argument to hists__resort_cb_t so that we can pass data from upper layers to the callback function. It will be used in the following patches.
--- tools/perf/builtin-c2c.c | 8 ++++---- tools/perf/util/hist.c | 11 ++++++----- tools/perf/util/hist.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-)
tools/perf/builtin-c2c.c +4 -4
@@ -1970,7 +1970,7 @@ static void calc_width(struct c2c_hist_entry *c2c_he)set_nodestr (c2c_he); } -static int filter_cb (struct hist_entry *he) +static int filter_cb (struct hist_entry *he,void *arg__maybe_unused ) {struct c2c_hist_entry *c2c_he;
@@ -1987,7 +1987,7 @@ static int filter_cb(struct hist_entry *he)return 0 ; } -static int resort_cl_cb (struct hist_entry *he) +static int resort_cl_cb (struct hist_entry *he,void *arg__maybe_unused ) {struct c2c_hist_entry *c2c_he;struct c2c_hists *c2c_hists;
@@ -2074,7 +2074,7 @@ static int setup_nodes(struct perf_session *session)#define HAS_HITMS (__h) ((__h)->stats.lcl_hitm || (__h)->stats.rmt_hitm) -static int resort_hitm_cb (struct hist_entry *he) +static int resort_hitm_cb (struct hist_entry *he,void *arg__maybe_unused ) {struct c2c_hist_entry *c2c_he; c2c_he = container_of(he, struct c2c_hist_entry, he);
@@ -2096,7 +2096,7 @@ static int hists__iterate_cb(struct hists *hists, hists__resort_cb_t cb)struct hist_entry *he; he = rb_entry(next, struct hist_entry, rb_node); - ret =cb (he); + ret =cb (he,NULL );if (ret)break ; next =rb_next (&he->rb_node);
tools/perf/util/hist.c +6 -5
@@ -1721,7 +1721,8 @@ static void __hists__insert_output_entry(struct rb_root_cached *entries, }static void output_resort (struct hists *hists,struct ui_progress *prog, -bool use_callchain,hists__resort_cb_t cb) +bool use_callchain,hists__resort_cb_t cb, +void *cb_arg) {struct rb_root_cached *root;struct rb_node *next;
@@ -1760,7 +1761,7 @@ static void output_resort(struct hists *hists, struct ui_progress *prog, n = rb_entry(next, struct hist_entry, rb_node_in); next =rb_next (&n->rb_node_in); -if (cb &&cb (n)) +if (cb &&cb (n, cb_arg))continue ;__hists__insert_output_entry (&hists->entries, n, min_callchain_hits, use_callchain);
@@ -1785,18 +1786,18 @@ void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *pro use_callchain |= symbol_conf.show_branchflag_count; -output_resort (evsel__hists (evsel), prog, use_callchain,NULL ); +output_resort (evsel__hists (evsel), prog, use_callchain,NULL ,NULL ); }void hists__output_resort (struct hists *hists,struct ui_progress *prog) { -output_resort (hists, prog, symbol_conf.use_callchain,NULL ); +output_resort (hists, prog, symbol_conf.use_callchain,NULL ,NULL ); }void hists__output_resort_cb (struct hists *hists,struct ui_progress *prog,hists__resort_cb_t cb) { -output_resort (hists, prog, symbol_conf.use_callchain, cb); +output_resort (hists, prog, symbol_conf.use_callchain, cb,NULL ); }static bool can_goto_child (struct hist_entry *he,enum hierarchy_move_dir hmd)
tools/perf/util/hist.h +1 -1
@@ -163,7 +163,7 @@ int hist_entry__snprintf_alignment(struct hist_entry *he, struct perf_hpp *hpp, struct perf_hpp_fmt *fmt, int printed);void hist_entry__delete (struct hist_entry *he); -typedef int (*hists__resort_cb_t )(struct hist_entry *he); +typedef int (*hists__resort_cb_t )(struct hist_entry *he,void *arg);void perf_evsel__output_resort (struct perf_evsel *evsel,struct ui_progress *prog);void hists__output_resort (struct hists *hists,struct ui_progress *prog);
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 33/53 perf evsel: Add output_resort_cb method
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Add perf_evsel__output_resort_cb() so we have an interface with a callback for each hist entry. It will be used in the following patch.
--- tools/perf/util/hist.c | 10 ++++++++-- tools/perf/util/hist.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-)
tools/perf/util/hist.c +8 -2
@@ -1775,7 +1775,8 @@ static void output_resort(struct hists *hists, struct ui_progress *prog, } } -void perf_evsel__output_resort (struct perf_evsel *evsel,struct ui_progress *prog) +void perf_evsel__output_resort_cb (struct perf_evsel *evsel,struct ui_progress *prog, +hists__resort_cb_t cb,void *cb_arg) {bool use_callchain;
@@ -1786,7 +1787,12 @@ void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *pro use_callchain |= symbol_conf.show_branchflag_count; -output_resort (evsel__hists (evsel), prog, use_callchain,NULL ,NULL ); +output_resort (evsel__hists (evsel), prog, use_callchain, cb, cb_arg); +} + +void perf_evsel__output_resort (struct perf_evsel *evsel,struct ui_progress *prog) +{ +return perf_evsel__output_resort_cb (evsel, prog,NULL ,NULL ); }void hists__output_resort (struct hists *hists,struct ui_progress *prog)
tools/perf/util/hist.h +2 -0
@@ -165,6 +165,8 @@ void hist_entry__delete(struct hist_entry *he);typedef int (*hists__resort_cb_t )(struct hist_entry *he,void *arg); +void perf_evsel__output_resort_cb (struct perf_evsel *evsel,struct ui_progress *prog, +hists__resort_cb_t cb,void *cb_arg);void perf_evsel__output_resort (struct perf_evsel *evsel,struct ui_progress *prog);void hists__output_resort (struct hists *hists,struct ui_progress *prog); void hists__output_resort_cb(struct hists *hists, struct ui_progress *prog,
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 34/53 perf report: Move symbol annotation to the resort phase
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
Currently we make the annotation for the IPC column during the entry display, already outside of the progress bar scope, so it appears like 'perf report' is stuck.
Move the annotation retrieval to the resort phase, so that all the data are ready for display.
--- tools/perf/builtin-report.c | 21 +++++++++++++++++++-- tools/perf/util/sort.c | 7 ------- 2 files changed, 19 insertions(+), 9 deletions(-)
tools/perf/builtin-report.c +19 -2
@@ -616,6 +616,21 @@ static int report__collapse_hists(struct report *rep)return ret; } +static int hists__resort_cb (struct hist_entry *he,void *arg) +{ +struct report *rep = arg; +struct symbol *sym = he->ms.sym; + +if (rep->symbol_ipc && sym && !sym->annotate2) { +struct perf_evsel *evsel =hists_to_evsel (he->hists); + +symbol__annotate2 (sym, he->ms.map, evsel, + &annotation__default_options,NULL ); + } + +return 0 ; +} +static void report__output_resort (struct report *rep) {struct ui_progress prog;
@@ -623,8 +638,10 @@ static void report__output_resort(struct report *rep)ui_progress__init (&prog, rep->nr_entries,"Sorting events for output..." ); -evlist__for_each_entry (rep->session->evlist, pos) -perf_evsel__output_resort (pos, &prog); +evlist__for_each_entry (rep->session->evlist, pos) { +perf_evsel__output_resort_cb (pos, &prog, + hists__resort_cb, rep); + }ui_progress__finish (); }
tools/perf/util/sort.c +0 -7
@@ -429,8 +429,6 @@ static int hist_entry__sym_ipc_snprintf(struct hist_entry *he, char *bf, {struct symbol *sym = he->ms.sym; -struct map *map = he->ms.map; -struct perf_evsel *evsel =hists_to_evsel (he->hists);struct annotation *notes;double ipc =0.0 , coverage =0.0 ;char tmp[64 ];
@@ -438,11 +436,6 @@ static int hist_entry__sym_ipc_snprintf(struct hist_entry *he, char *bf,if (!sym)return repsep_snprintf (bf, size,"%-*s" , width,"-" ); -if (!sym->annotate2 &&symbol__annotate2 (sym, map, evsel, - &annotation__default_options,NULL ) <0 ) { -return 0 ; - } - notes =symbol__annotation (sym);if (notes->hit_cycles)
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 35/53 perf tools: Add documentation for BPF event selection
In reply to Arnaldo Carvalho de MeloFrom: Changbin Du <[email protected]>
Add documentation for how to pass a BPF program as a perf event.
--- tools/perf/Documentation/perf-config.txt | 31 ++++++++++++++++++++++++ tools/perf/Documentation/perf-record.txt | 14 +++++++++++ 2 files changed, 45 insertions(+)
tools/perf/Documentation/perf-config.txt +31 -0
@@ -120,6 +120,10 @@ Given a $HOME/.perfconfig like this: children = true group = true + [llvm] + dump-obj = true + clang-opt = -g + You can hide source code of annotate feature setting the config to false with % perf config annotate.hide_src_code=true
@@ -553,6 +557,33 @@ trace.*:: trace.show_zeros:: Do not suppress syscall arguments that are equal to zero. +llvm.*:: + llvm.clang-path:: + Path to clang. If omit, search it from $PATH. + + llvm.clang-bpf-cmd-template:: + Cmdline template. Below lines show its default value. Environment + variable is used to pass options. + "$CLANG_EXEC -D__KERNEL__ $CLANG_OPTIONS $KERNEL_INC_OPTIONS \ + -Wno-unused-value -Wno-pointer-sign -working-directory \ + $WORKING_DIR -c $CLANG_SOURCE -target bpf -O2 -o -" + + llvm.clang-opt:: + Options passed to clang. + + llvm.kbuild-dir:: + kbuild directory. If not set, use /lib/modules/`uname -r`/build. + If set to "" deliberately, skip kernel header auto-detector. + + llvm.kbuild-opts:: + Options passed to 'make' when detecting kernel header options. + + llvm.dump-obj:: + Enable perf dump BPF object files compiled by LLVM. + + llvm.opts:: + Options passed to llc. + SEE ALSO -------- linkperf:perf[1]
tools/perf/Documentation/perf-record.txt +14 -0
@@ -88,6 +88,20 @@ OPTIONS If you want to profile write accesses in [0x1000~1008), just set 'mem:0x1000/8:w'. + - a BPF source file (ending in .c) or a precompiled object file (ending + in .o) selects one or more BPF events. + The BPF program can attach to various perf events based on the ELF section + names. + + When processing a '.c' file, perf searches an installed LLVM to compile it + into an object file first. Optional clang options can be passed via the + '--clang-opt' command line option, e.g.: + + perf record --clang-opt "-DLINUX_VERSION_CODE=0x50000" \ + -e tests/bpf-script-example.c + + Note: '--clang-opt' must be placed before '--event/-e'. + - a group of events surrounded by a pair of brace ("{event1,event2,...}"). Each event is separated by commas and the group should be quoted to prevent the shell interpretation. You also need to use --group on
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 36/53 perf cs-etm: Add last instruction information in packet
In reply to Arnaldo Carvalho de MeloFrom: Leo Yan <[email protected]>
Decoder provides last instruction related information, these information can be used for trace analysis; specifically we can get to know what kind of branch instruction has been executed, mainly the information are contained in three element fields:
last_i_type: this is significant type for waypoint calculation, it indicates the last instruction is one of immediate branch instruction, indirect branch instruction, instruction barrier (ISB), or data barrier (DSB/DMB).
last_i_subtype: this is used for instruction sub type, it can be branch with link, ARMv8 return instruction, ARMv8 eret instruction (return from exception), or ARMv7 instruction which could imply return (e.g. MOV PC, LR; POP { ,PC}).
last_instr_cond: it indicates if the last instruction was conditional.
But these three fields are not saved into cs_etm_packet struct, thus cs-etm layer don't know related information and cannot generate sample flags for branch instructions.
This patch add corresponding three new fields in cs_etm_packet struct and save related value into the packet structure, it is preparation for supporting sample flags.
--- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 9 +++++++++ tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 3 +++ 2 files changed, 12 insertions(+)
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +9 -0
@@ -290,6 +290,9 @@ static void cs_etm_decoder__clear_buffer(struct cs_etm_decoder *decoder) decoder->packet_buffer[i].instr_count =0 ; decoder->packet_buffer[i].last_instr_taken_branch = false; decoder->packet_buffer[i].last_instr_size =0 ; + decoder->packet_buffer[i].last_instr_type =0 ; + decoder->packet_buffer[i].last_instr_subtype =0 ; + decoder->packet_buffer[i].last_instr_cond =0 ; decoder->packet_buffer[i].cpu =INT_MIN ; } }
@@ -323,6 +326,9 @@ cs_etm_decoder__buffer_packet(struct cs_etm_decoder *decoder, decoder->packet_buffer[et].instr_count =0 ; decoder->packet_buffer[et].last_instr_taken_branch = false; decoder->packet_buffer[et].last_instr_size =0 ; + decoder->packet_buffer[et].last_instr_type =0 ; + decoder->packet_buffer[et].last_instr_subtype =0 ; + decoder->packet_buffer[et].last_instr_cond =0 ;if (decoder->packet_count ==MAX_BUFFER -1 )return OCSD_RESP_WAIT ;
@@ -366,6 +372,9 @@ cs_etm_decoder__buffer_range(struct cs_etm_decoder *decoder, packet->start_addr = elem->st_addr; packet->end_addr = elem->en_addr; packet->instr_count = elem->num_instr_range; + packet->last_instr_type = elem->last_i_type; + packet->last_instr_subtype = elem->last_i_subtype; + packet->last_instr_cond = elem->last_instr_cond;switch (elem->last_i_type) {case OCSD_INSTR_BR :
tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +3 -0
@@ -43,6 +43,9 @@ struct cs_etm_packet {u64 start_addr;u64 end_addr;u32 instr_count; +u32 last_instr_type; +u32 last_instr_subtype; +u8 last_instr_cond;u8 last_instr_taken_branch;u8 last_instr_size;int cpu;
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 37/53 perf cs-etm: Set sample flags for instruction range packet
In reply to Arnaldo Carvalho de MeloFrom: Leo Yan <[email protected]>
The perf sample data contains flags to indicate the hardware trace data is belonging to which type branch instruction, thus this can be used to print out the human readable string. Arm CoreSight ETM sample data is missed to set flags and it is always set to zeros, this results in perf tool skips to print string for instruction types.
This patch is to set branch instruction flags for instruction range packet.
--- .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 2 + .../perf/util/cs-etm-decoder/cs-etm-decoder.h | 1 + tools/perf/util/cs-etm.c | 90 ++++++++++++++++++- 3 files changed, 91 insertions(+), 2 deletions(-)
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +2 -0
@@ -293,6 +293,7 @@ static void cs_etm_decoder__clear_buffer(struct cs_etm_decoder *decoder) decoder->packet_buffer[i].last_instr_type =0 ; decoder->packet_buffer[i].last_instr_subtype =0 ; decoder->packet_buffer[i].last_instr_cond =0 ; + decoder->packet_buffer[i].flags =0 ; decoder->packet_buffer[i].cpu =INT_MIN ; } }
@@ -329,6 +330,7 @@ cs_etm_decoder__buffer_packet(struct cs_etm_decoder *decoder, decoder->packet_buffer[et].last_instr_type =0 ; decoder->packet_buffer[et].last_instr_subtype =0 ; decoder->packet_buffer[et].last_instr_cond =0 ; + decoder->packet_buffer[et].flags =0 ;if (decoder->packet_count ==MAX_BUFFER -1 )return OCSD_RESP_WAIT ;
tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +1 -0
@@ -45,6 +45,7 @@ struct cs_etm_packet {u32 instr_count;u32 last_instr_type;u32 last_instr_subtype; +u32 flags;u8 last_instr_cond;u8 last_instr_taken_branch;u8 last_instr_size;
tools/perf/util/cs-etm.c +88 -2
120 lines not on this page · raw message
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 38/53 perf cs-etm: Set sample flags for trace discontinuity
In reply to Arnaldo Carvalho de MeloFrom: Leo Yan <[email protected]>
In the middle of trace stream, it might be interrupted thus the trace data is not continuous, the trace stream firstly is ended for previous trace block and restarted for next block.
To display related information for showing trace is restarted, this patch set sample flags for trace discontinuity:
- If one discontinuity packet is coming, append flag PERF_IP_FLAG_TRACE_END to the previous packet to indicate the trace has been ended;
- If one instruction packet is following discontinuity packet, this instruction packet is the first one packet to restarting trace. So set flag PERF_IP_FLAG_TRACE_START to discontinuity packet, this flag will be used to generate sample when connect with the sequential instruction packet.
--- tools/perf/util/cs-etm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
tools/perf/util/cs-etm.c +19 -0
@@ -1111,6 +1111,7 @@ static int cs_etm__end_block(struct cs_etm_queue *etmq)static int cs_etm__set_sample_flags (struct cs_etm_queue *etmq) {struct cs_etm_packet *packet = etmq->packet; +struct cs_etm_packet *prev_packet = etmq->prev_packet;switch (packet->sample_type) {case CS_ETM_RANGE :
@@ -1170,8 +1171,26 @@ static int cs_etm__set_sample_flags(struct cs_etm_queue *etmq) packet->last_instr_subtype == OCSD_S_INSTR_V8_RET) packet->flags = PERF_IP_FLAG_BRANCH |PERF_IP_FLAG_RETURN ; + +/* +* Decoder might insert a discontinuity in the middle of +* instruction packets, fixup prev_packet with flag +* PERF_IP_FLAG_TRACE_BEGIN to indicate restarting trace. +*/ +if (prev_packet->sample_type ==CS_ETM_DISCONTINUITY ) + prev_packet->flags |=PERF_IP_FLAG_BRANCH | +PERF_IP_FLAG_TRACE_BEGIN ;break ;case CS_ETM_DISCONTINUITY : +/* +* The trace is discontinuous, if the previous packet is +* instruction packet, set flag PERF_IP_FLAG_TRACE_END +* for previous packet. +*/ +if (prev_packet->sample_type ==CS_ETM_RANGE ) + prev_packet->flags |=PERF_IP_FLAG_BRANCH | +PERF_IP_FLAG_TRACE_END ; +break ;case CS_ETM_EXCEPTION :case CS_ETM_EXCEPTION_RET :case CS_ETM_EMPTY :
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 39/53 perf cs-etm: Add exception number in exception packet
In reply to Arnaldo Carvalho de MeloFrom: Leo Yan <[email protected]>
When an exception packet comes, it contains the information for exception number; the exception number indicates the exception types, so from it we can know if the exception is taken for interrupt, system call or other traps, etc.
This patch simply adds a field in cs_etm_packet struct, it records exception number for exception packet that will then be used to properly identify exception types to the perf synthesize mechanic.
--- .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 20 +++++++++++++++---- .../perf/util/cs-etm-decoder/cs-etm-decoder.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-)
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +16 -4
@@ -294,6 +294,7 @@ static void cs_etm_decoder__clear_buffer(struct cs_etm_decoder *decoder) decoder->packet_buffer[i].last_instr_subtype =0 ; decoder->packet_buffer[i].last_instr_cond =0 ; decoder->packet_buffer[i].flags =0 ; + decoder->packet_buffer[i].exception_number =UINT32_MAX ; decoder->packet_buffer[i].cpu =INT_MIN ; } }
@@ -331,6 +332,7 @@ cs_etm_decoder__buffer_packet(struct cs_etm_decoder *decoder, decoder->packet_buffer[et].last_instr_subtype =0 ; decoder->packet_buffer[et].last_instr_cond =0 ; decoder->packet_buffer[et].flags =0 ; + decoder->packet_buffer[et].exception_number =UINT32_MAX ;if (decoder->packet_count ==MAX_BUFFER -1 )return OCSD_RESP_WAIT ;
@@ -406,10 +408,20 @@ cs_etm_decoder__buffer_discontinuity(struct cs_etm_decoder *decoder,static ocsd_datapath_resp_t cs_etm_decoder__buffer_exception (struct cs_etm_decoder *decoder, +const ocsd_generic_trace_elem *elem,const uint8_t trace_chan_id) -{ -return cs_etm_decoder__buffer_packet (decoder, trace_chan_id, -CS_ETM_EXCEPTION ); +{int ret =0 ; +struct cs_etm_packet *packet; + + ret =cs_etm_decoder__buffer_packet (decoder, trace_chan_id, +CS_ETM_EXCEPTION ); +if (ret !=OCSD_RESP_CONT && ret !=OCSD_RESP_WAIT ) +return ret; + + packet = &decoder->packet_buffer[decoder->tail]; + packet->exception_number = elem->exception_number; + +return ret; } static ocsd_datapath_resp_t
@@ -443,7 +455,7 @@ static ocsd_datapath_resp_t cs_etm_decoder__gen_trace_elem_printer( trace_chan_id);break ;case OCSD_GEN_TRC_ELEM_EXCEPTION : - resp =cs_etm_decoder__buffer_exception (decoder, + resp =cs_etm_decoder__buffer_exception (decoder, elem, trace_chan_id);break ;case OCSD_GEN_TRC_ELEM_EXCEPTION_RET :
tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +1 -0
@@ -46,6 +46,7 @@ struct cs_etm_packet {u32 last_instr_type;u32 last_instr_subtype;u32 flags; +u32 exception_number;u8 last_instr_cond;u8 last_instr_taken_branch;u8 last_instr_size;
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 40/53 perf cs-etm: Change tuple from traceID-CPU# to traceID-metadata
In reply to Arnaldo Carvalho de MeloFrom: Leo Yan <[email protected]>
If packet processing wants to know the packet is bound with which ETM version, it needs to access metadata to decide that based on metadata magic number; but we cannot simply to use CPU logic ID number as index to access metadata sequential array, especially when system have hotplugged off CPUs, the metadata array are only allocated for online CPUs but not offline CPUs, so the CPU logic number doesn't match with its index in the array.
This patch is to change tuple from traceID-CPU# to traceID-metadata, thus it can use the tuple to retrieve metadata pointer according to traceID.
For safe accessing metadata fields, this patch provides helper function cs_etm__get_cpu() which is used to return CPU number according to traceID; cs_etm_decoder__buffer_packet() is the first consumer for this helper function.
--- .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 8 +++--- tools/perf/util/cs-etm.c | 26 ++++++++++++++----- tools/perf/util/cs-etm.h | 9 ++++++- 3 files changed, 31 insertions(+), 12 deletions(-)
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +3 -5
@@ -305,14 +305,12 @@ cs_etm_decoder__buffer_packet(struct cs_etm_decoder *decoder, enum cs_etm_sample_type sample_type) {u32 et =0 ; -struct int_node *inode =NULL ; +int cpu;if (decoder->packet_count >=MAX_BUFFER -1 )return OCSD_RESP_FATAL_SYS_ERR ; -/* Search the RB tree for the cpu associated with this traceID */ - inode =intlist__find (traceid_list, trace_chan_id); -if (!inode) +if (cs_etm__get_cpu (trace_chan_id, &cpu) <0 )return OCSD_RESP_FATAL_SYS_ERR ; et = decoder->tail;
@@ -322,7 +320,7 @@ cs_etm_decoder__buffer_packet(struct cs_etm_decoder *decoder, decoder->packet_buffer[et].sample_type = sample_type; decoder->packet_buffer[et].isa =CS_ETM_ISA_UNKNOWN ; - decoder->packet_buffer[et].cpu = *((int *)inode->priv); + decoder->packet_buffer[et].cpu = cpu; decoder->packet_buffer[et].start_addr =CS_ETM_INVAL_ADDR ; decoder->packet_buffer[et].end_addr =CS_ETM_INVAL_ADDR ; decoder->packet_buffer[et].instr_count =0 ;
tools/perf/util/cs-etm.c +20 -6
@@ -97,6 +97,20 @@ static u32 cs_etm__get_v7_protocol_version(u32 etmidr)return CS_ETM_PROTO_ETMV3 ; } +int cs_etm__get_cpu (u8 trace_chan_id,int *cpu) +{ +struct int_node *inode; +u64 *metadata; + + inode =intlist__find (traceid_list, trace_chan_id); +if (!inode) +return -EINVAL ; + + metadata = inode->priv; + *cpu = (int )metadata[CS_ETM_CPU ]; +return 0 ; +} +static void cs_etm__packet_dump (const char *pkt_string) {const char *color =PERF_COLOR_BLUE ;
@@ -252,7 +266,7 @@ static void cs_etm__free(struct perf_session *session)cs_etm__free_events (session); session->auxtrace =NULL ; -/* First remove all traceID/CPU# nodes for the RB tree */ +/* First remove all traceID/metadata nodes for the RB tree */ intlist__for_each_entry_safe (inode, tmp, traceid_list)intlist__remove (traceid_list, inode);/* Then the RB tree itself */
@@ -1519,9 +1533,9 @@ int cs_etm__process_auxtrace_info(union perf_event *event, 0xffffffff);/* -* Create an RB tree for traceID-CPU# tuple. Since the conversion has -* to be made for each packet that gets decoded, optimizing access in -* anything other than a sequential array is worth doing. +* Create an RB tree for traceID-metadata tuple. Since the conversion +* has to be made for each packet that gets decoded, optimizing access +* in anything other than a sequential array is worth doing. */ traceid_list =intlist__new (NULL );if (!traceid_list) {
@@ -1587,8 +1601,8 @@ int cs_etm__process_auxtrace_info(union perf_event *event, err = -EINVAL ; goto err_free_metadata; } -/* All good, associate the traceID with the CPU# */ - inode->priv = &metadata[j][CS_ETM_CPU ]; +/* All good, associate the traceID with the metadata pointer */ + inode->priv = metadata[j]; }/*
tools/perf/util/cs-etm.h +8 -1
@@ -53,7 +53,7 @@ enum { CS_ETMV4_PRIV_MAX, }; -/* RB tree for quick conversion between traceID and CPUs */ +/* RB tree for quick conversion between traceID and metadata pointers */ struct intlist *traceid_list;#define KiB (x) ((x) * 1024)
@@ -69,6 +69,7 @@ static const u64 __perf_cs_etmv4_magic = 0x4040404040404040ULL;#ifdef HAVE_CSTRACE_SUPPORT int cs_etm__process_auxtrace_info (union perf_event *event,struct perf_session *session); +int cs_etm__get_cpu (u8 trace_chan_id,int *cpu);#else static inline int cs_etm__process_auxtrace_info(union perf_event *event __maybe_unused,
@@ -76,6 +77,12 @@ cs_etm__process_auxtrace_info(union perf_event *event __maybe_unused, {return -1 ; } + +static inline int cs_etm__get_cpu (u8 trace_chan_id__maybe_unused , +int *cpu__maybe_unused ) +{ +return -1 ; +}#endif #endif
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 41/53 perf cs-etm: Add traceID in packet
In reply to Arnaldo Carvalho de MeloFrom: Leo Yan <[email protected]>
Add traceID in packet, thus we can use traceID to retrieve metadata pointer from traceID-metadata tuple.
--- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 2 ++ tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 1 + 2 files changed, 3 insertions(+)
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +2 -0
@@ -295,6 +295,7 @@ static void cs_etm_decoder__clear_buffer(struct cs_etm_decoder *decoder) decoder->packet_buffer[i].last_instr_cond =0 ; decoder->packet_buffer[i].flags =0 ; decoder->packet_buffer[i].exception_number =UINT32_MAX ; + decoder->packet_buffer[i].trace_chan_id =UINT8_MAX ; decoder->packet_buffer[i].cpu =INT_MIN ; } }
@@ -331,6 +332,7 @@ cs_etm_decoder__buffer_packet(struct cs_etm_decoder *decoder, decoder->packet_buffer[et].last_instr_cond =0 ; decoder->packet_buffer[et].flags =0 ; decoder->packet_buffer[et].exception_number =UINT32_MAX ; + decoder->packet_buffer[et].trace_chan_id = trace_chan_id;if (decoder->packet_count ==MAX_BUFFER -1 )return OCSD_RESP_WAIT ;
tools/perf/util/cs-etm-decoder/cs-etm-decoder.h +1 -0
@@ -50,6 +50,7 @@ struct cs_etm_packet {u8 last_instr_cond;u8 last_instr_taken_branch;u8 last_instr_size; +u8 trace_chan_id;int cpu; };
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 42/53 perf cs-etm: Set sample flags for exception packet
In reply to Arnaldo Carvalho de MeloFrom: Leo Yan <[email protected]>
The exception taken and returning are typical flow for instruction jump but it needs to be handled with exception packets. This patch is to set sample flags for exception packet.
Since the exception packet contains the exception number, according to the exception number this patch makes decision for belonging to which exception types.
The decoder have defined different exception number for ETMv3 and ETMv4 separately, hence this patch needs firstly decide the ETM version by using the metadata magic number, and this patch adds helper function cs_etm__get_magic() for easily getting magic number.
Based on different ETM version, the exception packet contains the exception number, according to the exception number this patch makes decision for the exception belonging to which exception types.
In this patch, it introduces helper function cs_etm__is_svc_instr(); for ETMv4 CS_ETMV4_EXC_CALL covers SVC, SMC and HVC cases in the single exception number, thus need to use cs_etm__is_svc_instr() to decide an exception taken for system call.
--- tools/perf/util/cs-etm.c | 215 +++++++++++++++++++++++++++++++++++++++ tools/perf/util/cs-etm.h | 44 ++++++++ 2 files changed, 259 insertions(+)
tools/perf/util/cs-etm.c +215 -0
@@ -97,6 +97,20 @@ static u32 cs_etm__get_v7_protocol_version(u32 etmidr)return CS_ETM_PROTO_ETMV3 ; } +static int cs_etm__get_magic (u8 trace_chan_id,u64 *magic) +{ +struct int_node *inode; +u64 *metadata; + + inode =intlist__find (traceid_list, trace_chan_id); +if (!inode) +return -EINVAL ; + + metadata = inode->priv; + *magic = metadata[CS_ETM_MAGIC ]; +return 0 ; +} +int cs_etm__get_cpu (u8 trace_chan_id,int *cpu) {struct int_node *inode;
@@ -1122,10 +1136,174 @@ static int cs_etm__end_block(struct cs_etm_queue *etmq)return 0 ; } +static bool cs_etm__is_svc_instr (struct cs_etm_queue *etmq, +struct cs_etm_packet *packet, +u64 end_addr) +{ +u16 instr16; +u32 instr32; +u64 addr; + +switch (packet->isa) { +case CS_ETM_ISA_T32 : +/* +* The SVC of T32 is defined in ARM DDI 0487D.a, F5.1.247: +* +* b'15 b'8 +* +-----------------+--------+ +* | 1 1 0 1 1 1 1 1 | imm8 | +* +-----------------+--------+ +* +* According to the specifiction, it only defines SVC for T32 +* with 16 bits instruction and has no definition for 32bits; +* so below only read 2 bytes as instruction size for T32. +*/ + addr = end_addr -2 ; +cs_etm__mem_access (etmq, addr,sizeof (instr16), (u8 *)&instr16); +if ((instr16 &0xFF00 ) ==0xDF00 ) +return true; + +break ; +case CS_ETM_ISA_A32 : +/* +* The SVC of A32 is defined in ARM DDI 0487D.a, F5.1.247: +* +* b'31 b'28 b'27 b'24 +* +---------+---------+-------------------------+ +* | !1111 | 1 1 1 1 | imm24 | +* +---------+---------+-------------------------+ +*/ + addr = end_addr -4 ; +cs_etm__mem_access (etmq, addr,sizeof (instr32), (u8 *)&instr32); +if ((instr32 &0x0F000000 ) ==0x0F000000 && + (instr32 &0xF0000000 ) !=0xF0000000 ) +return true; + +break ; +case CS_ETM_ISA_A64 : +/* +* The SVC of A64 is defined in ARM DDI 0487D.a, C6.2.294: +* +* b'31 b'21 b'4 b'0 +* +-----------------------+---------+-----------+ +* | 1 1 0 1 0 1 0 0 0 0 0 | imm16 | 0 0 0 0 1 | +* +-----------------------+---------+-----------+ +*/ + addr = end_addr -4 ; +cs_etm__mem_access (etmq, addr,sizeof (instr32), (u8 *)&instr32); +if ((instr32 &0xFFE0001F ) ==0xd4000001 ) +return true; + +break ; +case CS_ETM_ISA_UNKNOWN : +default : +break ; + } + +return false; +} + +static bool cs_etm__is_syscall (struct cs_etm_queue *etmq,u64 magic) +{ +struct cs_etm_packet *packet = etmq->packet; +struct cs_etm_packet *prev_packet = etmq->prev_packet; + +if (magic == __perf_cs_etmv3_magic) +if (packet->exception_number ==CS_ETMV3_EXC_SVC ) +return true; + +/* +* ETMv4 exception type CS_ETMV4_EXC_CALL covers SVC, SMC and +* HVC cases; need to check if it's SVC instruction based on +* packet address. +*/ +if (magic == __perf_cs_etmv4_magic) { +if (packet->exception_number ==CS_ETMV4_EXC_CALL && +cs_etm__is_svc_instr (etmq, prev_packet, + prev_packet->end_addr)) +return true; + } + +return false; +} + +static bool cs_etm__is_async_exception (struct cs_etm_queue *etmq,u64 magic) +{ +struct cs_etm_packet *packet = etmq->packet; + +if (magic == __perf_cs_etmv3_magic) +if (packet->exception_number ==CS_ETMV3_EXC_DEBUG_HALT || + packet->exception_number ==CS_ETMV3_EXC_ASYNC_DATA_ABORT || + packet->exception_number ==CS_ETMV3_EXC_PE_RESET || + packet->exception_number ==CS_ETMV3_EXC_IRQ || + packet->exception_number ==CS_ETMV3_EXC_FIQ ) +return true; + +if (magic == __perf_cs_etmv4_magic) +if (packet->exception_number ==CS_ETMV4_EXC_RESET || + packet->exception_number ==CS_ETMV4_EXC_DEBUG_HALT || + packet->exception_number ==CS_ETMV4_EXC_SYSTEM_ERROR || + packet->exception_number ==CS_ETMV4_EXC_INST_DEBUG || + packet->exception_number ==CS_ETMV4_EXC_DATA_DEBUG || + packet->exception_number ==CS_ETMV4_EXC_IRQ || + packet->exception_number ==CS_ETMV4_EXC_FIQ ) +return true; + +return false; +} + +static bool cs_etm__is_sync_exception (struct cs_etm_queue *etmq,u64 magic) +{ +struct cs_etm_packet *packet = etmq->packet; +struct cs_etm_packet *prev_packet = etmq->prev_packet; + +if (magic == __perf_cs_etmv3_magic) +if (packet->exception_number ==CS_ETMV3_EXC_SMC || + packet->exception_number ==CS_ETMV3_EXC_HYP || + packet->exception_number ==CS_ETMV3_EXC_JAZELLE_THUMBEE || + packet->exception_number ==CS_ETMV3_EXC_UNDEFINED_INSTR || + packet->exception_number ==CS_ETMV3_EXC_PREFETCH_ABORT || + packet->exception_number ==CS_ETMV3_EXC_DATA_FAULT || + packet->exception_number ==CS_ETMV3_EXC_GENERIC ) +return true; + +if (magic == __perf_cs_etmv4_magic) { +if (packet->exception_number ==CS_ETMV4_EXC_TRAP || + packet->exception_number ==CS_ETMV4_EXC_ALIGNMENT || + packet->exception_number ==CS_ETMV4_EXC_INST_FAULT || + packet->exception_number ==CS_ETMV4_EXC_DATA_FAULT ) +return true; + +/* +* For CS_ETMV4_EXC_CALL, except SVC other instructions +* (SMC, HVC) are taken as sync exceptions. +*/ +if (packet->exception_number ==CS_ETMV4_EXC_CALL && + !cs_etm__is_svc_instr (etmq, prev_packet, + prev_packet->end_addr)) +return true; + +/* +* ETMv4 has 5 bits for exception number; if the numbers +* are in the range ( CS_ETMV4_EXC_FIQ, CS_ETMV4_EXC_END ] +* they are implementation defined exceptions. +* +* For this case, simply take it as sync exception. +*/ +if (packet->exception_number >CS_ETMV4_EXC_FIQ && + packet->exception_number <=CS_ETMV4_EXC_END ) +return true; + } + +return false; +} +static int cs_etm__set_sample_flags (struct cs_etm_queue *etmq) {struct cs_etm_packet *packet = etmq->packet;struct cs_etm_packet *prev_packet = etmq->prev_packet; +u64 magic; +int ret;switch (packet->sample_type) {case CS_ETM_RANGE :
@@ -1206,6 +1384,43 @@ static int cs_etm__set_sample_flags(struct cs_etm_queue *etmq)PERF_IP_FLAG_TRACE_END ;break ;case CS_ETM_EXCEPTION : + ret =cs_etm__get_magic (packet->trace_chan_id, &magic); +if (ret) +return ret; + +/* The exception is for system call. */ +if (cs_etm__is_syscall (etmq, magic)) + packet->flags =PERF_IP_FLAG_BRANCH | +PERF_IP_FLAG_CALL | +PERF_IP_FLAG_SYSCALLRET ; +/* +* The exceptions are triggered by external signals from bus, +* interrupt controller, debug module, PE reset or halt. +*/ +else if (cs_etm__is_async_exception (etmq, magic)) + packet->flags =PERF_IP_FLAG_BRANCH | +PERF_IP_FLAG_CALL | +PERF_IP_FLAG_ASYNC | +PERF_IP_FLAG_INTERRUPT ; +/* +* Otherwise, exception is caused by trap, instruction & +* data fault, or alignment errors. +*/ +else if (cs_etm__is_sync_exception (etmq, magic)) + packet->flags =PERF_IP_FLAG_BRANCH | +PERF_IP_FLAG_CALL | +PERF_IP_FLAG_INTERRUPT ; + +/* +* When the exception packet is inserted, since exception +* packet is not used standalone for generating samples +* and it's affiliation to the previous instruction range +* packet; so set previous range packet flags to tell perf +* it is an exception taken branch. +*/ +if (prev_packet->sample_type ==CS_ETM_RANGE ) + prev_packet->flags = packet->flags; +break ;case CS_ETM_EXCEPTION_RET :case CS_ETM_EMPTY :default :
tools/perf/util/cs-etm.h +44 -0
50 lines not on this page · raw message
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 43/53 perf cs-etm: Set sample flags for exception return packet
In reply to Arnaldo Carvalho de MeloFrom: Leo Yan <[email protected]>
When return from exception, we need to distinguish if it's system call return or for other type exceptions for setting sample flags. Due to the exception return packet doesn't contain exception number, so we cannot decide sample flags based on exception number.
On the other hand, the exception return packet is followed by an instruction range packet; this range packet deliveries the start address after exception handling, we can check if it is a SVC instruction just before the start address. If there has one SVC instruction is found ahead the return address, this means it's an exception return for system call; otherwise it is an normal return for other exceptions.
This patch is to set sample flags for exception return packet, firstly it simply set sample flags as PERF_IP_FLAG_INTERRUPT for all exception returns since at this point it doesn't know what's exactly the exception type. We will defer to decide if it's an exception return for system call when the next instruction range packet comes, it checks if there has one SVC instruction prior to the start address and if so we will change sample flags to PERF_IP_FLAG_SYSCALLRET for system call return.
--- tools/perf/util/cs-etm.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
tools/perf/util/cs-etm.c +44 -0
@@ -1372,6 +1372,20 @@ static int cs_etm__set_sample_flags(struct cs_etm_queue *etmq)if (prev_packet->sample_type ==CS_ETM_DISCONTINUITY ) prev_packet->flags |=PERF_IP_FLAG_BRANCH |PERF_IP_FLAG_TRACE_BEGIN ; + +/* +* If the previous packet is an exception return packet +* and the return address just follows SVC instuction, +* it needs to calibrate the previous packet sample flags +* as PERF_IP_FLAG_SYSCALLRET. +*/ +if (prev_packet->flags == (PERF_IP_FLAG_BRANCH | +PERF_IP_FLAG_RETURN | +PERF_IP_FLAG_INTERRUPT ) && +cs_etm__is_svc_instr (etmq, packet, packet->start_addr)) + prev_packet->flags =PERF_IP_FLAG_BRANCH | +PERF_IP_FLAG_RETURN | +PERF_IP_FLAG_SYSCALLRET ;break ;case CS_ETM_DISCONTINUITY :/*
@@ -1422,6 +1436,36 @@ static int cs_etm__set_sample_flags(struct cs_etm_queue *etmq) prev_packet->flags = packet->flags;break ;case CS_ETM_EXCEPTION_RET : +/* +* When the exception return packet is inserted, since +* exception return packet is not used standalone for +* generating samples and it's affiliation to the previous +* instruction range packet; so set previous range packet +* flags to tell perf it is an exception return branch. +* +* The exception return can be for either system call or +* other exception types; unfortunately the packet doesn't +* contain exception type related info so we cannot decide +* the exception type purely based on exception return packet. +* If we record the exception number from exception packet and +* reuse it for excpetion return packet, this is not reliable +* due the trace can be discontinuity or the interrupt can +* be nested, thus the recorded exception number cannot be +* used for exception return packet for these two cases. +* +* For exception return packet, we only need to distinguish the +* packet is for system call or for other types. Thus the +* decision can be deferred when receive the next packet which +* contains the return address, based on the return address we +* can read out the previous instruction and check if it's a +* system call instruction and then calibrate the sample flag +* as needed. +*/ +if (prev_packet->sample_type ==CS_ETM_RANGE ) + prev_packet->flags =PERF_IP_FLAG_BRANCH | +PERF_IP_FLAG_RETURN | +PERF_IP_FLAG_INTERRUPT ; +break ;case CS_ETM_EMPTY :default :break ;
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 44/53 perf vendor events intel: Fix Load_Miss_Real_Latency on CLX
In reply to Arnaldo Carvalho de MeloFrom: William Cohen <[email protected]>
Fix incorrect event names for the Load_Miss_Real_Latency metric for Cascadelake server in the same manner as commit 91b2b97025 for SKL/SKX.
--- tools/perf/pmu-events/arch/x86/cascadelakex/clx-metrics.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/pmu-events/arch/x86/cascadelakex/clx-metrics.json +1 -1
@@ -73,7 +73,7 @@ }, { "BriefDescription": "Actual Average Latency for L1 data-cache miss demand loads", - "MetricExpr": "L1D_PEND_MISS.PENDING / ( MEM_LOAD_RETIRED.L1_MISS_PS + MEM_LOAD_RETIRED.FB_HIT_PS )", + "MetricExpr": "L1D_PEND_MISS.PENDING / ( MEM_LOAD_RETIRED.L1_MISS + MEM_LOAD_RETIRED.FB_HIT )", "MetricGroup": "Memory_Bound;Memory_Lat", "MetricName": "Load_Miss_Real_Latency" },
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 45/53 perf tools: Fix split_kallsyms_for_kcore() for trampoline symbols
In reply to Arnaldo Carvalho de MeloFrom: Adrian Hunter <[email protected]>
Kallsyms symbols do not have a size, so the size becomes the distance to the next symbol.
Consequently the recently added trampoline symbols end up with large sizes because the trampolines are some distance from one another and the main kernel map.
However, symbols that end outside their map can disrupt the symbol tree because, after mapping, it can appear incorrectly that they overlap other symbols.
Add logic to truncate symbol size to the end of the corresponding map.
--- tools/perf/util/symbol.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/symbol.c +2 -0
@@ -718,6 +718,8 @@ static int map_groups__split_kallsyms_for_kcore(struct map_groups *kmaps, struct } pos->start -= curr_map->start - curr_map->pgoff; +if (pos->end > curr_map->end) + pos->end = curr_map->end;if (pos->end) pos->end -= curr_map->start - curr_map->pgoff;symbols__insert (&curr_map->dso->symbols, pos);
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 46/53 perf thread-stack: Tidy thread_stack__push_cp() usage
In reply to Arnaldo Carvalho de MeloFrom: Adrian Hunter <[email protected]>
If 'cp' is checked in thread_stack__push_cp() a number of error checks can be removed, reducing code size and improving readability.
--- tools/perf/util/thread-stack.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
tools/perf/util/thread-stack.c +3 -10
@@ -493,6 +493,9 @@ static int thread_stack__push_cp(struct thread_stack *ts, u64 ret_addr,struct thread_stack_entry *tse;int err; +if (!cp) +return -ENOMEM ; +if (ts->cnt == ts->sz) { err =thread_stack__grow (ts);if (err)
@@ -576,8 +579,6 @@ static int thread_stack__bottom(struct thread_stack *ts, cp =call_path__findnew (cpr, &cpr->call_path, sym, ip, ts->kernel_start); -if (!cp) -return -ENOMEM ;return thread_stack__push_cp (ts, ip, sample->time, ref, cp, true, false);
@@ -609,8 +610,6 @@ static int thread_stack__no_call_return(struct thread *thread, cp =call_path__findnew (cpr, &cpr->call_path, to_al->sym, sample->addr, ts->kernel_start); -if (!cp) -return -ENOMEM ;return thread_stack__push_cp (ts,0 , sample->time, ref, cp, true, false); }
@@ -633,8 +632,6 @@ static int thread_stack__no_call_return(struct thread *thread,/* This 'return' had no 'call', so push and pop top of stack */ cp =call_path__findnew (cpr, parent, from_al->sym, sample->ip, ts->kernel_start); -if (!cp) -return -ENOMEM ; err =thread_stack__push_cp (ts, sample->addr, sample->time, ref, cp, true, false);
@@ -680,8 +677,6 @@ static int thread_stack__trace_end(struct thread_stack *ts, cp =call_path__findnew (cpr, ts->stack[ts->cnt -1 ].cp,NULL ,0 , ts->kernel_start); -if (!cp) -return -ENOMEM ; ret_addr = sample->ip + sample->insn_len;
@@ -745,8 +740,6 @@ int thread_stack__process(struct thread *thread, struct comm *comm, cp =call_path__findnew (cpr, ts->stack[ts->cnt -1 ].cp, to_al->sym, sample->addr, ts->kernel_start); -if (!cp) -return -ENOMEM ; err =thread_stack__push_cp (ts, ret_addr, sample->time, ref, cp, false, trace_end); }else if (sample->flags &PERF_IP_FLAG_RETURN ) {
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 47/53 perf thread-stack: Tidy thread_stack__no_call_return() by adding more local variables
In reply to Arnaldo Carvalho de MeloFrom: Adrian Hunter <[email protected]>
Make thread_stack__no_call_return() more readable by adding more local variables.
--- tools/perf/util/thread-stack.c | 35 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 18 deletions(-)
tools/perf/util/thread-stack.c +17 -18
@@ -591,34 +591,36 @@ static int thread_stack__no_call_return(struct thread *thread, struct addr_location *to_al, u64 ref) {struct call_path_root *cpr = ts->crp->cpr; +struct call_path *root = &cpr->call_path; +struct symbol *fsym = from_al->sym; +struct symbol *tsym = to_al->sym;struct call_path *cp, *parent;u64 ks = ts->kernel_start; +u64 addr = sample->addr; +u64 tm = sample->time; +u64 ip = sample->ip;int err; -if (sample->ip >= ks && sample->addr < ks) { +if (ip >= ks && addr < ks) {/* Return to userspace, so pop all kernel addresses */ while (thread_stack__in_kernel (ts)) { err =thread_stack__call_return (thread, ts, --ts->cnt, - sample->time, ref, - true); + tm, ref, true);if (err)return err; }/* If the stack is empty, push the userspace address */ if (!ts->cnt) { - cp =call_path__findnew (cpr, &cpr->call_path, - to_al->sym, sample->addr, - ts->kernel_start); -return thread_stack__push_cp (ts,0 , sample->time, ref, - cp, true, false); + cp =call_path__findnew (cpr, root, tsym, addr, ks); +return thread_stack__push_cp (ts,0 , tm, ref, cp, true, + false); } - }else if (thread_stack__in_kernel (ts) && sample->ip < ks) { + }else if (thread_stack__in_kernel (ts) && ip < ks) {/* Return to userspace, so pop all kernel addresses */ while (thread_stack__in_kernel (ts)) { err =thread_stack__call_return (thread, ts, --ts->cnt, - sample->time, ref, - true); + tm, ref, true);if (err)return err; }
@@ -627,19 +629,16 @@ static int thread_stack__no_call_return(struct thread *thread,if (ts->cnt) parent = ts->stack[ts->cnt -1 ].cp;else - parent = &cpr->call_path; + parent = root;/* This 'return' had no 'call', so push and pop top of stack */ - cp =call_path__findnew (cpr, parent, from_al->sym, sample->ip, - ts->kernel_start); + cp =call_path__findnew (cpr, parent, fsym, ip, ks); - err =thread_stack__push_cp (ts, sample->addr, sample->time, ref, cp, - true, false); + err =thread_stack__push_cp (ts, addr, tm, ref, cp, true, false);if (err)return err; -return thread_stack__pop_cp (thread, ts, sample->addr, sample->time, ref, - to_al->sym); +return thread_stack__pop_cp (thread, ts, addr, tm, ref, tsym); } static int thread_stack__trace_begin(struct thread *thread,
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 48/53 perf thread-stack: Represent jmps to the start of a different symbol
In reply to Arnaldo Carvalho de MeloFrom: Adrian Hunter <[email protected]>
The compiler might optimize a call/ret combination by making it a jmp. However the thread-stack does not presently cater for that, so that such control flow is not visible in the call graph. Make it visible by recording on the stack a branch to the start of a different symbol. Note, that means when a ret pops the stack, all jmps must be popped off first.
Example:
$ cat jmp-to-fn.c
__attribute__((noinline)) int bar(void)
{
return -1;
} __attribute__((noinline)) int foo(void)
{
return bar() + 1;
} int main()
{
return foo();
}
$ gcc -ggdb3 -Wall -Wextra -O2 -o jmp-to-fn jmp-to-fn.c
$ objdump -d jmp-to-fn
<SNIP>
0000000000001040 <main>:
1040: 31 c0 xor %eax,%eax
1042: e9 09 01 00 00 jmpq 1150 <foo>
<SNIP>
0000000000001140 <bar>:
1140: b8 ff ff ff ff mov $0xffffffff,%eax
1145: c3 retq
<SNIP>
0000000000001150 <foo>:
1150: 31 c0 xor %eax,%eax
1152: e8 e9 ff ff ff callq 1140 <bar>
1157: 83 c0 01 add $0x1,%eax
115a: c3 retq
<SNIP>
$ perf record -o jmp-to-fn.perf.data -e intel_pt/cyc/u ./jmp-to-fn
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0,017 MB jmp-to-fn.perf.data ]
$ perf script -i jmp-to-fn.perf.data --itrace=be -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py jmp-to-fn.db branches calls
2019-01-08 13:24:58.783069 Creating database...
2019-01-08 13:24:58.794650 Writing records...
2019-01-08 13:24:59.008050 Adding indexes
2019-01-08 13:24:59.015802 Done
$ ~/libexec/perf-core/scripts/python/exported-sql-viewer.py jmp-to-fn.dbBefore:
main
-> barAfter:
main
-> foo
-> barCommitter testing:
Install the python2-pyside package, then select these menu options on the GUI:
"Reports"
"Context sensitive callgraphs"
Then go on expanding the symbols, to get, full picture when doing this on a fedora:29 with gcc version 8.2.1 20181215 (Red Hat 8.2.1-6) (GCC):
jmp-to-fn
PID:TID
_start (ld-2.28.so)
__libc_start_main
main
foo
barTo verify that indeed, this fixes the problem.
--- .../scripts/python/export-to-postgresql.py | 2 +- tools/perf/scripts/python/export-to-sqlite.py | 2 +- tools/perf/util/thread-stack.c | 30 +++++++++++++++++-- tools/perf/util/thread-stack.h | 3 ++ 4 files changed, 33 insertions(+), 4 deletions(-)
tools/perf/scripts/python/export-to-postgresql.py +1 -1
@@ -478,7 +478,7 @@ if perf_db_export_calls: 'branch_count,' 'call_id,' 'return_id,' - 'CASE WHEN flags=1 THEN \'no call\' WHEN flags=2 THEN \'no return\' WHEN flags=3 THEN \'no call/return\' ELSE \'\' END AS flags,' + 'CASE WHEN flags=0 THEN \'\' WHEN flags=1 THEN \'no call\' WHEN flags=2 THEN \'no return\' WHEN flags=3 THEN \'no call/return\' WHEN flags=6 THEN \'jump\' ELSE flags END AS flags,' 'parent_call_path_id' ' FROM calls INNER JOIN call_paths ON call_paths.id = call_path_id')
tools/perf/scripts/python/export-to-sqlite.py +1 -1
@@ -320,7 +320,7 @@ if perf_db_export_calls: 'branch_count,' 'call_id,' 'return_id,' - 'CASE WHEN flags=1 THEN \'no call\' WHEN flags=2 THEN \'no return\' WHEN flags=3 THEN \'no call/return\' ELSE \'\' END AS flags,' + 'CASE WHEN flags=0 THEN \'\' WHEN flags=1 THEN \'no call\' WHEN flags=2 THEN \'no return\' WHEN flags=3 THEN \'no call/return\' WHEN flags=6 THEN \'jump\' ELSE flags END AS flags,' 'parent_call_path_id' ' FROM calls INNER JOIN call_paths ON call_paths.id = call_path_id')
tools/perf/util/thread-stack.c +28 -2
@@ -38,6 +38,7 @@* @cp: call path * @no_call: a 'call' was not seen * @trace_end: a 'call' but trace ended +* @non_call: a branch but not a 'call' to the start of a different symbol */ struct thread_stack_entry {u64 ret_addr;
@@ -47,6 +48,7 @@ struct thread_stack_entry {struct call_path *cp;bool no_call;bool trace_end; +bool non_call; };/**
@@ -268,6 +270,8 @@ static int thread_stack__call_return(struct thread *thread, cr.flags |=CALL_RETURN_NO_CALL ;if (no_return) cr.flags |=CALL_RETURN_NO_RETURN ; +if (tse->non_call) + cr.flags |=CALL_RETURN_NON_CALL ;return crp->process (&cr, crp->data); }
@@ -510,6 +514,7 @@ static int thread_stack__push_cp(struct thread_stack *ts, u64 ret_addr, tse->cp = cp; tse->no_call = no_call; tse->trace_end = trace_end; + tse->non_call = false;return 0 ; }
@@ -531,14 +536,16 @@ static int thread_stack__pop_cp(struct thread *thread, struct thread_stack *ts, timestamp, ref, false); } -if (ts->stack[ts->cnt -1 ].ret_addr == ret_addr) { +if (ts->stack[ts->cnt -1 ].ret_addr == ret_addr && + !ts->stack[ts->cnt -1 ].non_call) {return thread_stack__call_return (thread, ts, --ts->cnt, timestamp, ref, false); }else {size_t i = ts->cnt -1 ;while (i--) { -if (ts->stack[i].ret_addr != ret_addr) +if (ts->stack[i].ret_addr != ret_addr || + ts->stack[i].non_call)continue ; i +=1 ;while (ts->cnt > i) {
@@ -757,6 +764,25 @@ int thread_stack__process(struct thread *thread, struct comm *comm, err =thread_stack__trace_begin (thread, ts, sample->time, ref); }else if (sample->flags &PERF_IP_FLAG_TRACE_END ) { err =thread_stack__trace_end (ts, sample, ref); + }else if (sample->flags &PERF_IP_FLAG_BRANCH && + from_al->sym != to_al->sym && to_al->sym && + to_al->addr == to_al->sym->start) { +struct call_path_root *cpr = ts->crp->cpr; +struct call_path *cp; + +/* +* The compiler might optimize a call/ret combination by making +* it a jmp. Make that visible by recording on the stack a +* branch to the start of a different symbol. Note, that means +* when a ret pops the stack, all jmps must be popped off first. +*/ + cp =call_path__findnew (cpr, ts->stack[ts->cnt -1 ].cp, + to_al->sym, sample->addr, + ts->kernel_start); + err =thread_stack__push_cp (ts,0 , sample->time, ref, cp, false, + false); +if (!err) + ts->stack[ts->cnt -1 ].non_call = true; }return err;
tools/perf/util/thread-stack.h +3 -0
@@ -35,10 +35,13 @@ struct call_path;* * CALL_RETURN_NO_CALL: 'return' but no matching 'call' * CALL_RETURN_NO_RETURN: 'call' but no matching 'return' +* CALL_RETURN_NON_CALL: a branch but not a 'call' to the start of a different +* symbol */ enum {CALL_RETURN_NO_CALL =1 <<0 ,CALL_RETURN_NO_RETURN =1 <<1 , +CALL_RETURN_NON_CALL =1 <<2 , };/**
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 49/53 perf auxtrace: Define auxtrace record alignment
In reply to Arnaldo Carvalho de MeloFrom: Adrian Hunter <[email protected]>
Define auxtrace record alignment so that it can be referenced elsewhere.
Note this is preparation for patch "perf intel-pt: Fix overlap calculation for padding"
--- tools/perf/util/auxtrace.c | 4 ++-- tools/perf/util/auxtrace.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-)
tools/perf/util/auxtrace.c +2 -2
@@ -1279,9 +1279,9 @@ static int __auxtrace_mmap__read(struct perf_mmap *map, }/* padding must be written by fn() e.g. record__process_auxtrace() */ - padding = size &7 ; + padding = size & (PERF_AUXTRACE_RECORD_ALIGNMENT -1 );if (padding) - padding =8 - padding; + padding =PERF_AUXTRACE_RECORD_ALIGNMENT - padding;memset (&ev,0 ,sizeof (ev)); ev.auxtrace.header.type =PERF_RECORD_AUXTRACE ;
tools/perf/util/auxtrace.h +3 -0
@@ -40,6 +40,9 @@ struct record_opts;struct auxtrace_info_event ;struct events_stats ; +/* Auxtrace records must have the same alignment as perf event records */ +#define PERF_AUXTRACE_RECORD_ALIGNMENT 8 +enum auxtrace_type {PERF_AUXTRACE_UNKNOWN ,PERF_AUXTRACE_INTEL_PT ,
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 50/53 perf intel-pt: Fix overlap calculation for padding
In reply to Arnaldo Carvalho de MeloFrom: Adrian Hunter <[email protected]>
Auxtrace records might have up to 7 bytes of padding appended. Adjust the overlap accordingly.
--- .../util/intel-pt-decoder/intel-pt-decoder.c | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-)
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +34 -2
@@ -26,6 +26,7 @@#include "../cache.h" #include "../util.h" +#include "../auxtrace.h" #include "intel-pt-insn-decoder.h" #include "intel-pt-pkt-decoder.h"
@@ -2575,6 +2576,34 @@ static int intel_pt_tsc_cmp(uint64_t tsc1, uint64_t tsc2) } } +#define MAX_PADDING (PERF_AUXTRACE_RECORD_ALIGNMENT - 1) + +/** +* adj_for_padding - adjust overlap to account for padding. +* @buf_b: second buffer +* @buf_a: first buffer +* @len_a: size of first buffer +* +* @buf_a might have up to 7 bytes of padding appended. Adjust the overlap +* accordingly. +* +* Return: A pointer into @buf_b from where non-overlapped data starts +*/ +static unsigned char *adj_for_padding (unsigned char *buf_b, +unsigned char *buf_a,size_t len_a) +{ +unsigned char *p = buf_b -MAX_PADDING ; +unsigned char *q = buf_a + len_a -MAX_PADDING ; +int i; + +for (i =MAX_PADDING ; i; i--, p++, q++) { +if (*p != *q) +break ; + } + +return p; +} +/** * intel_pt_find_overlap_tsc - determine start of non-overlapped trace data * using TSC.
@@ -2625,8 +2654,11 @@ static unsigned char *intel_pt_find_overlap_tsc(unsigned char *buf_a,/* Same TSC, so buffers are consecutive */ if (!cmp && rem_b >= rem_a) { +unsigned char *start; + *consecutive = true; -return buf_b + len_b - (rem_b - rem_a); + start = buf_b + len_b - (rem_b - rem_a); +return adj_for_padding (start, buf_a, len_a); }if (cmp <0 )return buf_b;/* tsc_a < tsc_b => no overlap */
@@ -2689,7 +2721,7 @@ unsigned char *intel_pt_find_overlap(unsigned char *buf_a, size_t len_a, found =memmem (buf_a, len_a, buf_b, len_a);if (found) { *consecutive = true; -return buf_b + len_a; +return adj_for_padding (buf_b + len_a, buf_a, len_a); }/* Try again at next PSB in buffer 'a' */
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 51/53 perf intel-pt: Fix CYC timestamp calculation after OVF
In reply to Arnaldo Carvalho de MeloFrom: Adrian Hunter <[email protected]>
CYC packet timestamp calculation depends upon CBR which was being cleared upon overflow (OVF). That can cause errors due to failing to synchronize with sideband events. Even if a CBR change has been lost, the old CBR is still a better estimate than zero. So remove the clearing of CBR.
--- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 1 - 1 file changed, 1 deletion(-)
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +0 -1
@@ -1395,7 +1395,6 @@ static int intel_pt_overflow(struct intel_pt_decoder *decoder) {intel_pt_log ("ERROR: Buffer overflow\n" );intel_pt_clear_tx_flags (decoder); - decoder->cbr =0 ; decoder->timestamp_insn_cnt =0 ; decoder->pkt_state =INTEL_PT_STATE_ERR_RESYNC ; decoder->overflow = true;
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 52/53 perf intel-pt: Packet splitting can happen only on 32-bit
In reply to Arnaldo Carvalho de MeloFrom: Adrian Hunter <[email protected]>
Data is copied when the trace is stopped, so packets are never split between buffers except when processing if the buffer cannot fit in the address space which can only happen on 32-bit systems. Change the logic to reflect that.
--- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +1 -1
@@ -868,7 +868,7 @@ static int intel_pt_get_next_packet(struct intel_pt_decoder *decoder) ret =intel_pt_get_packet (decoder->buf, decoder->len, &decoder->packet); -if (ret ==INTEL_PT_NEED_MORE_BYTES && +if (ret ==INTEL_PT_NEED_MORE_BYTES &&BITS_PER_LONG ==32 && decoder->len <INTEL_PT_PKT_MAX_SZ && !decoder->next_buf) { ret =intel_pt_get_split_packet (decoder);if (ret <0 )
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 53/53 perf auxtrace: Add timestamp to auxtrace errors
In reply to Arnaldo Carvalho de MeloFrom: Adrian Hunter <[email protected]>
The timestamp can use useful to find part of a trace that has an error without outputting all of the trace e.g. using the itrace 's' option to skip initial number of events.
--- tools/perf/util/auxtrace.c | 22 ++++++++++++++++++++-- tools/perf/util/auxtrace.h | 2 +- tools/perf/util/event.h | 3 ++- tools/perf/util/intel-bts.c | 4 ++-- tools/perf/util/intel-pt.c | 23 ++++++++++++++++------- tools/perf/util/s390-cpumsf.c | 7 ++++--- tools/perf/util/session.c | 3 +++ 7 files changed, 48 insertions(+), 16 deletions(-)
tools/perf/util/auxtrace.c +20 -2
@@ -27,6 +27,7 @@#include <linux/bitops.h> #include <linux/log2.h> #include <linux/string.h> +#include <linux/time64.h> #include <sys/param.h> #include <stdlib.h>
@@ -858,7 +859,7 @@ void auxtrace_buffer__free(struct auxtrace_buffer *buffer)void auxtrace_synth_error (struct auxtrace_error_event *auxtrace_error,int type,int code,int cpu,pid_t pid,pid_t tid,u64 ip, -const char *msg) +const char *msg,u64 timestamp) {size_t size;
@@ -870,7 +871,9 @@ void auxtrace_synth_error(struct auxtrace_error_event *auxtrace_error, int type, auxtrace_error->cpu = cpu; auxtrace_error->pid = pid; auxtrace_error->tid = tid; + auxtrace_error->fmt =1 ; auxtrace_error->ip = ip; + auxtrace_error->time = timestamp;strlcpy (auxtrace_error->msg, msg,MAX_AUXTRACE_ERROR_MSG ); size = (void *)auxtrace_error->msg - (void *)auxtrace_error +
@@ -1160,12 +1163,27 @@ static const char *auxtrace_error_name(int type)size_t perf_event__fprintf_auxtrace_error (union perf_event *event,FILE *fp) {struct auxtrace_error_event *e = &event->auxtrace_error; +unsigned long long nsecs = e->time; +const char *msg = e->msg;int ret; ret =fprintf (fp," %s error type %u" ,auxtrace_error_name (e->type), e->type); + +if (e->fmt && nsecs) { +unsigned long secs = nsecs /NSEC_PER_SEC ; + + nsecs -= secs *NSEC_PER_SEC ; + ret +=fprintf (fp," time %lu.%09llu" , secs, nsecs); + }else { + ret +=fprintf (fp," time 0" ); + } + +if (!e->fmt) + msg = (const char *)&e->time; + ret +=fprintf (fp," cpu %d pid %d tid %d ip %#" PRIx64" code %u: %s\n" , - e->cpu, e->pid, e->tid, e->ip, e->code, e->msg); + e->cpu, e->pid, e->tid, e->ip, e->code, msg);return ret; }
tools/perf/util/auxtrace.h +1 -1
@@ -519,7 +519,7 @@ void auxtrace_index__free(struct list_head *head);void auxtrace_synth_error (struct auxtrace_error_event *auxtrace_error,int type,int code,int cpu,pid_t pid,pid_t tid,u64 ip, -const char *msg); +const char *msg,u64 timestamp); int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr, struct perf_tool *tool,
tools/perf/util/event.h +2 -1
@@ -532,8 +532,9 @@ struct auxtrace_error_event {u32 cpu;u32 pid;u32 tid; -u32 reserved__;/* For alignment */ +u32 fmt;u64 ip; +u64 time;char msg[MAX_AUXTRACE_ERROR_MSG ]; };
tools/perf/util/intel-bts.c +2 -2
@@ -144,7 +144,7 @@ static int intel_bts_lost(struct intel_bts *bts, struct perf_sample *sample)auxtrace_synth_error (&event.auxtrace_error,PERF_AUXTRACE_ERROR_ITRACE ,INTEL_BTS_ERR_LOST , sample->cpu, sample->pid, - sample->tid,0 ,"Lost trace data" ); + sample->tid,0 ,"Lost trace data" , sample->time); err =perf_session__deliver_synth_event (bts->session, &event,NULL );if (err)
@@ -374,7 +374,7 @@ static int intel_bts_synth_error(struct intel_bts *bts, int cpu, pid_t pid,auxtrace_synth_error (&event.auxtrace_error,PERF_AUXTRACE_ERROR_ITRACE ,INTEL_BTS_ERR_NOINSN , cpu, pid, tid, ip, -"Failed to get instruction" ); +"Failed to get instruction" ,0 ); err =perf_session__deliver_synth_event (bts->session, &event,NULL );if (err)
tools/perf/util/intel-pt.c +16 -7
@@ -1411,7 +1411,7 @@ static int intel_pt_synth_pwrx_sample(struct intel_pt_queue *ptq) }static int intel_pt_synth_error (struct intel_pt *pt,int code,int cpu, -pid_t pid,pid_t tid,u64 ip) +pid_t pid,pid_t tid,u64 ip,u64 timestamp) {union perf_event event;char msg[MAX_AUXTRACE_ERROR_MSG ];
@@ -1420,7 +1420,7 @@ static int intel_pt_synth_error(struct intel_pt *pt, int code, int cpu,intel_pt__strerror (code, msg,MAX_AUXTRACE_ERROR_MSG );auxtrace_synth_error (&event.auxtrace_error,PERF_AUXTRACE_ERROR_ITRACE , - code, cpu, pid, tid, ip, msg); + code, cpu, pid, tid, ip, msg, timestamp); err =perf_session__deliver_synth_event (pt->session, &event,NULL );if (err)
@@ -1430,6 +1430,18 @@ static int intel_pt_synth_error(struct intel_pt *pt, int code, int cpu,return err; } +static int intel_ptq_synth_error (struct intel_pt_queue *ptq, +const struct intel_pt_state *state) +{ +struct intel_pt *pt = ptq->pt; +u64 tm = ptq->timestamp; + + tm = pt->timeless_decoding ?0 :tsc_to_perf_time (tm, &pt->tc); + +return intel_pt_synth_error (pt, state->err, ptq->cpu, ptq->pid, + ptq->tid, state->from_ip, tm); +} +static int intel_pt_next_tid (struct intel_pt *pt,struct intel_pt_queue *ptq) {struct auxtrace_queue *queue;
@@ -1676,10 +1688,7 @@ static int intel_pt_run_decoder(struct intel_pt_queue *ptq, u64 *timestamp)intel_pt_next_tid (pt, ptq); }if (pt->synth_opts.errors) { - err =intel_pt_synth_error (pt, state->err, - ptq->cpu, ptq->pid, - ptq->tid, - state->from_ip); + err =intel_ptq_synth_error (ptq, state);if (err)return err; }
@@ -1804,7 +1813,7 @@ static int intel_pt_process_timeless_queues(struct intel_pt *pt, pid_t tid,static int intel_pt_lost (struct intel_pt *pt,struct perf_sample *sample) {return intel_pt_synth_error (pt,INTEL_PT_ERR_LOST , sample->cpu, - sample->pid, sample->tid,0 ); + sample->pid, sample->tid,0 , sample->time); }static struct intel_pt_queue *intel_pt_cpu_to_ptq (struct intel_pt *pt,int cpu)
tools/perf/util/s390-cpumsf.c +4 -3
@@ -819,7 +819,7 @@ static int s390_cpumsf_process_queues(struct s390_cpumsf *sf, u64 timestamp) }static int s390_cpumsf_synth_error (struct s390_cpumsf *sf,int code,int cpu, -pid_t pid,pid_t tid,u64 ip) +pid_t pid,pid_t tid,u64 ip,u64 timestamp) {char msg[MAX_AUXTRACE_ERROR_MSG ];union perf_event event;
@@ -827,7 +827,7 @@ static int s390_cpumsf_synth_error(struct s390_cpumsf *sf, int code, int cpu,strncpy (msg,"Lost Auxiliary Trace Buffer" ,sizeof (msg) -1 );auxtrace_synth_error (&event.auxtrace_error,PERF_AUXTRACE_ERROR_ITRACE , - code, cpu, pid, tid, ip, msg); + code, cpu, pid, tid, ip, msg, timestamp); err =perf_session__deliver_synth_event (sf->session, &event,NULL );if (err)
@@ -839,7 +839,8 @@ static int s390_cpumsf_synth_error(struct s390_cpumsf *sf, int code, int cpu,static int s390_cpumsf_lost (struct s390_cpumsf *sf,struct perf_sample *sample) {return s390_cpumsf_synth_error (sf,1 , sample->cpu, - sample->pid, sample->tid,0 ); + sample->pid, sample->tid,0 , + sample->time); } static int
tools/perf/util/session.c +3 -0
@@ -703,7 +703,10 @@ static void perf_event__auxtrace_error_swap(union perf_event *event, event->auxtrace_error.cpu =bswap_32 (event->auxtrace_error.cpu); event->auxtrace_error.pid =bswap_32 (event->auxtrace_error.pid); event->auxtrace_error.tid =bswap_32 (event->auxtrace_error.tid); + event->auxtrace_error.fmt =bswap_32 (event->auxtrace_error.fmt); event->auxtrace_error.ip =bswap_64 (event->auxtrace_error.ip); +if (event->auxtrace_error.fmt) + event->auxtrace_error.time =bswap_64 (event->auxtrace_error.time); } static void perf_event__thread_map_swap(union perf_event *event,
Signature · 1 line
2.20.1
Quoted 300 lines · Arnaldo Carvalho de Melo
Hi Ingo,
Please consider pulling,
- Arnaldo
Test results at the end of this message, as usual.
The following changes since commit
ca3bb3d027f69ac3ab1dafb32bde2f5a3a44439c:perf/ring_buffer: Convert ring_buffer.aux_refcount to
refcount_t(2019-02-04 08:46:17 +0100)are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.gittags/perf-core-for-mingo-5.1-20190206for you to fetch changes up to
16bd4321c2425d37031a902cdbf183e2cd099946:perf auxtrace: Add timestamp to auxtrace errors (2019-02-06 11:20:32 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:Hardware tracing:
Adrian Hunter:
- Handle calls optimized into jumps to a different symbol
in the thread stack routines used to process hardware traces (Adrian Hunter)Intel PT:
Adrian Hunter:
- Fix overlap calculation for padding.
- Fix CYC timestamp calculation after OVF.
- Packet splitting can only happen in 32-bit.
- Add timestamp to auxtrace errors.
ARM CoreSight:
Leo Yan:
- Add last instruction information in packet
- Set sample flags for instruction range, exception and return packets and for a trace discontinuity.
- Add exception number in exception packet
- Change tuple from traceID-CPU# to traceID-metadata
- Add traceID in packet
Mathieu Poirier:
- Add "sinks" group to PMU directory
- Use event attributes to send sink information to kernel
- Remove
set_drv_config()API, no longer used.perf annotate:
Jiri Olsa:
- Delay symbol annotation to the resort phase, speeding up 'perf report' startup.
perf record:
Alexey Budankov:
- Allow binding userspace buffers to NUMA nodes.
Symbols:
Adrian Hunter:
- Fix calculating of symbol sizes when splitting kallsyms into maps for kcore processing.
Vendor events:
William Cohen:
- Intel: Fix
Load_Miss_Real_Latencyon CLXMisc:
Arnaldo Carvalho de Melo:
- Streamline headers, removing includes when all that is needed are just forward declarations, fixup the fallout for cases where headers should have been explicitely included but were instead obtained indirectly, by sheer luck.
- Add fallback versions for CPU_{OR,EQUAL}(), so that code using it continue to build on older systems where those were not yet introduced or in systems using some other libc than the GNU one where those helpers aren't present.
Documentation:
Changbin Du:
- Add documentation for BPF event selection.
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>----------------------------------------------------------------
Adrian Hunter (9):
perf tools: Fixsplit_kallsyms_for_kcore()for trampoline symbols
perf thread-stack: Tidythread_stack__push_cp()usage
perf thread-stack: Tidythread_stack__no_call_return()by adding more local variables perf thread-stack: Represent jmps to the start of a different symbol perf auxtrace: Define auxtrace record alignment
perf intel-pt: Fix overlap calculation for padding
perf intel-pt: Fix CYC timestamp calculation after OVF
perf intel-pt: Packet splitting can happen only on 32-bit
perf auxtrace: Add timestamp to auxtrace errorsAlexey Budankov (3):
perf record: Allocate affinity masks
perf record: Bind the AIO user space buffers to nodes perf record: Apply affinity masks when reading mmap buffersArnaldo Carvalho de Melo (21):
perf powerpc: Add missing headers toskip-callchain-idx.c
perf arm pmu: Add missinglinux/string.hheader
perf srccode: Move struct definition frommap.htosrccode.hperf callchain: Uninlinecallchain_cursor_reset()to removemap.hdependency perf symbols: Introducemap_symbol.h
pref tools: Add missingmap.hincludes
perf map: Move structs and prototypes for map groups to a separate header perf tests: Add missing headers so far obtained indirectly
perf hist: Removesymbol.hfromhist.h, just fwd decls are needed perf tools: Add missing include forsymbols.h
perf evsel: No need to includesymbol.hinevsel.h,symbol_conf.his enough perf thread: Don't includesymbol.h,symbol_conf.his enough perf tools: Add missing include <callchain.h> in various places perf hist: Remove the needlesscallchain.hinclude fromhist.hperf tests pmu: Add missing headers
perf pmu: Remove needlessevsel.hinclude, only needs one fwd decl perf kvm stat: Replacekvm-stat.hincludes with forward declarations perf powerpc kvm-stat: Add missingevlist.hheader
perf bpf-loader: Remove unecessary includes frombpf-loader.hperf tools: Add fallback versions for CPU_{OR,EQUAL}()
perf clang: Do not use 'returnstd::move(something)'Changbin Du (1):
perf tools: Add documentation for BPF event selectionJiri Olsa (3):
perf hists: Add argument tohists__resort_cb_tcallback perf evsel: Addoutput_resort_cbmethod
perf report: Move symbol annotation to the resort phaseLeo Yan (8):
perf cs-etm: Add last instruction information in packet perf cs-etm: Set sample flags for instruction range packet perf cs-etm: Set sample flags for trace discontinuity perf cs-etm: Add exception number in exception packet perf cs-etm: Change tuple from traceID-CPU# to traceID-metadata perf cs-etm: Add traceID in packet
perf cs-etm: Set sample flags for exception packet perf cs-etm: Set sample flags for exception return packetMathieu Poirier (7):
perf/aux: Makeperf_eventaccessible tosetup_aux()
coresight: perf: Add "sinks" group to PMU directory
coresight: Use event attributes for sink selection
perf pmu: MoveEVENT_SOURCE_DEVICE_PATHto PMU header file perf arm cs-etm: Use event attributes to send sink information to kernel perf coresight: Removeset_drv_config()API
perf pmu: Removeset_drv_configAPIWilliam Cohen (1):
perf vendor events intel: FixLoad_Miss_Real_Latencyon CLXarch/s390/kernel/perf_cpum_sf.c | 6 +- arch/x86/events/intel/bts.c | 4 +- arch/x86/events/intel/pt.c | 5 +- drivers/hwtracing/coresight/coresight-etm-perf.c | 112 +++++- drivers/hwtracing/coresight/coresight-etm-perf.h | 6 +- drivers/hwtracing/coresight/coresight-priv.h | 1 + drivers/hwtracing/coresight/coresight.c | 60 ++++ drivers/perf/arm_spe_pmu.c | 6 +- include/linux/coresight.h | 7 +- include/linux/perf_event.h | 2 +- kernel/events/ring_buffer.c | 2 +- tools/perf/Documentation/perf-config.txt | 31 ++ tools/perf/Documentation/perf-record.txt | 14 + tools/perf/arch/arm/tests/dwarf-unwind.c | 1 + tools/perf/arch/arm/util/cs-etm.c | 98 +++-- tools/perf/arch/arm/util/cs-etm.h | 3 - tools/perf/arch/arm/util/pmu.c | 3 +- tools/perf/arch/arm64/tests/dwarf-unwind.c | 1 + tools/perf/arch/powerpc/tests/dwarf-unwind.c | 1 + tools/perf/arch/powerpc/util/kvm-stat.c | 2 + tools/perf/arch/powerpc/util/skip-callchain-idx.c | 3 + tools/perf/arch/s390/util/kvm-stat.c | 1 + tools/perf/arch/x86/tests/dwarf-unwind.c | 1 + tools/perf/arch/x86/util/kvm-stat.c | 1 + tools/perf/builtin-annotate.c | 1 + tools/perf/builtin-c2c.c | 9 +- tools/perf/builtin-inject.c | 2 + tools/perf/builtin-kallsyms.c | 1 + tools/perf/builtin-kmem.c | 1 + tools/perf/builtin-mem.c | 1 + tools/perf/builtin-record.c | 38 +- tools/perf/builtin-report.c | 22 +- tools/perf/builtin-script.c | 1 + tools/perf/builtin-stat.c | 9 - tools/perf/builtin-top.c | 14 +- tools/perf/builtin-trace.c | 2 + tools/perf/perf.h | 8 + .../arch/x86/cascadelakex/clx-metrics.json | 2 +- tools/perf/scripts/python/export-to-postgresql.py | 2 +- tools/perf/scripts/python/export-to-sqlite.py | 2 +- tools/perf/tests/code-reading.c | 2 + tools/perf/tests/dwarf-unwind.c | 1 + tools/perf/tests/hists_common.c | 1 + tools/perf/tests/hists_cumulate.c | 1 + tools/perf/tests/hists_filter.c | 1 + tools/perf/tests/hists_output.c | 1 + tools/perf/tests/mmap-thread-lookup.c | 1 + tools/perf/tests/pmu.c | 2 + tools/perf/tests/sample-parsing.c | 2 + tools/perf/tests/sdt.c | 1 + tools/perf/ui/browsers/annotate.c | 1 + tools/perf/ui/browsers/hists.c | 3 + tools/perf/ui/gtk/annotate.c | 2 + tools/perf/ui/gtk/hists.c | 1 + tools/perf/ui/hist.c | 1 + tools/perf/ui/stdio/hist.c | 4 + tools/perf/util/Build | 1 - tools/perf/util/annotate.c | 1 + tools/perf/util/auxtrace.c | 27 +- tools/perf/util/auxtrace.h | 5 +- tools/perf/util/bpf-loader.c | 1 + tools/perf/util/bpf-loader.h | 7 +- tools/perf/util/build-id.c | 1 + tools/perf/util/c++/clang.cpp | 2 +- tools/perf/util/callchain.c | 17 + tools/perf/util/callchain.h | 20 +- tools/perf/util/config.c | 1 + tools/perf/util/cpu-set-sched.h | 50 +++ tools/perf/util/cpumap.c | 10 + tools/perf/util/cpumap.h | 1 + tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 41 ++- tools/perf/util/cs-etm-decoder/cs-etm-decoder.h | 6 + tools/perf/util/cs-etm.c | 394 ++++++++++++++++++++- tools/perf/util/cs-etm.h | 53 ++- tools/perf/util/db-export.c | 1 + tools/perf/util/drv_configs.c | 78 ---- tools/perf/util/drv_configs.h | 26 -- tools/perf/util/dso.c | 1 + tools/perf/util/event.c | 2 + tools/perf/util/event.h | 3 +- tools/perf/util/evlist.c | 6 +- tools/perf/util/evlist.h | 2 +- tools/perf/util/evsel.h | 2 +- tools/perf/util/hist.c | 21 +- tools/perf/util/hist.h | 9 +- tools/perf/util/intel-bts.c | 6 +- .../perf/util/intel-pt-decoder/intel-pt-decoder.c | 39 +- tools/perf/util/intel-pt.c | 23 +- tools/perf/util/kvm-stat.h | 7 +- tools/perf/util/machine.c | 1 + tools/perf/util/machine.h | 2 +- tools/perf/util/map.c | 6 + tools/perf/util/map.h | 100 +----- tools/perf/util/map_groups.h | 91 +++++ tools/perf/util/map_symbol.h | 22 ++ tools/perf/util/mmap.c | 105 +++++- tools/perf/util/mmap.h | 3 +- tools/perf/util/pmu.c | 2 - tools/perf/util/pmu.h | 5 +- tools/perf/util/probe-event.c | 2 + tools/perf/util/s390-cpumsf.c | 7 +- .../perf/util/scripting-engines/trace-event-perl.c | 2 + .../util/scripting-engines/trace-event-python.c | 2 + tools/perf/util/session.c | 5 + tools/perf/util/setup.py | 5 + tools/perf/util/sort.c | 8 +- tools/perf/util/sort.h | 3 +- tools/perf/util/srccode.h | 13 + tools/perf/util/symbol-elf.c | 2 + tools/perf/util/symbol.c | 3 + tools/perf/util/symbol.h | 14 +- tools/perf/util/thread-stack.c | 78 ++-- tools/perf/util/thread-stack.h | 3 + tools/perf/util/thread.c | 1 + tools/perf/util/thread.h | 7 +- tools/perf/util/unwind-libdw.c | 2 + tools/perf/util/unwind-libunwind-local.c | 1 +
Quoted 8 lines
tools/perf/util/unwind-libunwind.c | 1 + tools/perf/util/vdso.c | 1 + 119 files changed, 1399 insertions(+), 473 deletions(-) create mode 100644 tools/perf/util/cpu-set-sched.h delete mode 100644 tools/perf/util/drv_configs.c delete mode 100644 tools/perf/util/drv_configs.h create mode 100644 tools/perf/util/map_groups.h create mode 100644 tools/perf/util/map_symbol.h
Pulled, thanks a lot Arnaldo!
Ingo