Skip to contentSkip to conversation

perf/core improvements and fixes

GIT PULL In review Arnaldo Carvalho de Melo 4 participants 36 messages Sep 20, 2019 – Sep 24, 2019 1 message not in the archive

Subsystems (7)
lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

Hi Ingo/Thomas,

Please consider pulling,

Best regards,

- Arnaldo

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

The following changes since commit e336b4027775cb458dc713745e526fa1a1996b2a:

kprobes: Prohibit probing on BUG() and WARN() address (2019-09-05 10:15:16 +0200)

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.4-20190920-2

for you to fetch changes up to 2bff2b828502b5e5d5ea5a52643d3542053df03f:

perf kvm stat: Set 'trace_cycles' as default event for 'perf kvm record' in powerpc (2019-09-20 10:28:26 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

perf stat:

Srikar Dronamraju:

- Fix a segmentation fault when using repeat forever.

- Reset previous counts on repeat with interval.

aarch64:

James Clark:

- Add PMU event JSON files for Cortex-A76 and Neoverse N1.

PowerPC:

Anju T Sudhakar:

- Make 'trace_cycles' the default event for 'perf kvm record' in PowerPC.

S/390:

- Link libjvmti to tools/lib/string.o to have a weak strlcpy() implementation, providing previously unresolved symbol on s/390.

perf test:

Jiri Olsa:

- Add libperf automated tests to 'make -C tools/perf build-test'.

Colin Ian King:

- Fix spelling mistake.

Tree wide:

Arnaldo Carvalho de Melo:

- Some more header file sanitization.

libperf:

Jiri Olsa:

- Add dependency on libperf for python.so binding.

libtraceevent:

Sakari Ailus:

- Convert remaining %p[fF] users to %p[sS].

----------------------------------------------------------------
Anju T Sudhakar (3):
perf kvm: Move kvm-stat header file from conditional inclusion to common include section perf kvm: Add arch neutral function to choose event for perf kvm record perf kvm stat: Set 'trace_cycles' as default event for 'perf kvm record' in powerpc

Arnaldo Carvalho de Melo (19):
perf jvmti: Link against tools/lib/string.o to have weak strlcpy() perf tools: Remove needless builtin.h include directives perf debug: No need to include ui/util.h
perf tools: Remove debug.h from places where it is not needed perf tools: Remove util.h from where it is not needed perf probe: Add missing build-id.h header.
perf symbols: Add missing dso.h header
perf env: Remove needless cpumap.h header
perf event: Move perf_event__synthesize* to event.h perf stat: Move perf_stat_synthesize_config() to event.h perf callchain: Remove needless event.h include
perf python: Remove debug.h
perf hist: Add missing 'struct branch_stack' forward declaration perf annotate: Add missing machine.h include directive perf sched: Add missing event.h include directive
perf auxtrace: Add missing 'struct perf_sample' forward declaration perf tools: Move event synthesizing routines to separate header perf memswap: Adopt 'struct u64_swap' from evsel.h
perf tools: Move event synthesizing routines to separate .c file

Colin Ian King (1):

      perf test: Fix spelling mistake "allos" -> "allocate"

James Clark (1):
perf tools: Add PMU event JSON files for ARM Cortex-A76 and, Neoverse N1.

Jiri Olsa (4):
perf python: Add missing python/perf.so dependency for libperf perf tests: Add libperf automated test for 'make -C tools/perf build-test'
libperf: Add missing event.h file to install rule
libperf: Adopt perf_cpu_map__max() function

Sakari Ailus (1):
tools lib traceevent: Convert remaining %p[fF] users to %p[sS]

Srikar Dronamraju (2):
perf stat: Reset previous counts on repeat with interval perf stat: Fix a segmentation fault when using repeat forever

 .../Documentation/libtraceevent-func_apis.txt      |   10 +-
 tools/lib/traceevent/event-parse.c                 |   18 +-
 tools/perf/Makefile.perf                           |    2 +-
 tools/perf/arch/arm/util/cs-etm.c                  |    2 +-
 tools/perf/arch/arm64/util/arm-spe.c               |    2 +-
 tools/perf/arch/arm64/util/dwarf-regs.c            |    1 -
 tools/perf/arch/arm64/util/header.c                |    4 +-
 tools/perf/arch/arm64/util/unwind-libunwind.c      |    2 +-
 tools/perf/arch/powerpc/util/dwarf-regs.c          |    1 -
 tools/perf/arch/powerpc/util/header.c              |    1 -
 tools/perf/arch/powerpc/util/kvm-stat.c            |   45 +
 tools/perf/arch/powerpc/util/skip-callchain-idx.c  |    1 +
 tools/perf/arch/powerpc/util/sym-handling.c        |    1 -
 tools/perf/arch/s390/util/machine.c                |    2 +-
 tools/perf/arch/x86/tests/intel-cqm.c              |    1 -
 tools/perf/arch/x86/tests/perf-time-to-tsc.c       |    1 -
 tools/perf/arch/x86/tests/rdpmc.c                  |    2 +-
 tools/perf/arch/x86/util/archinsn.c                |    1 +
 tools/perf/arch/x86/util/event.c                   |    2 +
 tools/perf/arch/x86/util/intel-bts.c               |    2 +-
 tools/perf/arch/x86/util/intel-pt.c                |    2 +-
 tools/perf/arch/x86/util/machine.c                 |    3 +-
 tools/perf/arch/x86/util/tsc.c                     |    2 +
 tools/perf/bench/epoll-ctl.c                       |    2 +-
 tools/perf/bench/epoll-wait.c                      |    2 +-
 tools/perf/bench/futex-hash.c                      |    2 +-
 tools/perf/bench/futex-lock-pi.c                   |    2 +-
 tools/perf/bench/futex-requeue.c                   |    2 +-
 tools/perf/bench/futex-wake-parallel.c             |    3 +-
 tools/perf/bench/futex-wake.c                      |    2 +-
 tools/perf/bench/numa.c                            |    1 -
 tools/perf/bench/sched-messaging.c                 |    2 -
 tools/perf/bench/sched-pipe.c                      |    2 -
 tools/perf/builtin-annotate.c                      |    1 +
 tools/perf/builtin-c2c.c                           |    1 +
 tools/perf/builtin-config.c                        |    1 -
 tools/perf/builtin-evlist.c                        |    2 -
 tools/perf/builtin-inject.c                        |    1 +
 tools/perf/builtin-kvm.c                           |   15 +-
 tools/perf/builtin-record.c                        |   10 +-
 tools/perf/builtin-report.c                        |    2 +-
 tools/perf/builtin-sched.c                         |    3 +
 tools/perf/builtin-stat.c                          |   24 +-
 tools/perf/builtin-top.c                           |    1 +
 tools/perf/builtin-trace.c                         |    1 +
 tools/perf/jvmti/Build                             |    9 +
 tools/perf/lib/Makefile                            |    1 +
 tools/perf/lib/cpumap.c                            |   12 +
 tools/perf/lib/include/perf/cpumap.h               |    1 +
 tools/perf/lib/libperf.map                         |    1 +
 tools/perf/perf.c                                  |    2 +-
 .../arch/arm64/arm/cortex-a76-n1/branch.json       |   14 +
 .../arch/arm64/arm/cortex-a76-n1/bus.json          |   24 +
 .../arch/arm64/arm/cortex-a76-n1/cache.json        |  207 +++
 .../arch/arm64/arm/cortex-a76-n1/exception.json    |   52 +
 .../arch/arm64/arm/cortex-a76-n1/instruction.json  |  108 ++
 .../arch/arm64/arm/cortex-a76-n1/memory.json       |   23 +
 .../arch/arm64/arm/cortex-a76-n1/other.json        |    7 +
 .../arch/arm64/arm/cortex-a76-n1/pipeline.json     |   14 +
 tools/perf/pmu-events/arch/arm64/mapfile.csv       |    2 +
 tools/perf/tests/bitmap.c                          |    2 +-
 tools/perf/tests/clang.c                           |    2 -
 tools/perf/tests/code-reading.c                    |    2 +-
 tools/perf/tests/cpumap.c                          |    1 +
 tools/perf/tests/dso-data.c                        |    1 -
 tools/perf/tests/dwarf-unwind.c                    |    1 +
 tools/perf/tests/event-times.c                     |    1 -
 tools/perf/tests/event_update.c                    |    4 +-
 tools/perf/tests/hists_common.c                    |    2 +
 tools/perf/tests/keep-tracking.c                   |    3 +-
 tools/perf/tests/llvm.c                            |    1 -
 tools/perf/tests/make                              |    6 +-
 tools/perf/tests/mem2node.c                        |    2 +-
 tools/perf/tests/mmap-basic.c                      |    3 +-
 tools/perf/tests/mmap-thread-lookup.c              |    4 +-
 tools/perf/tests/openat-syscall-all-cpus.c         |    5 +-
 tools/perf/tests/parse-events.c                    |    1 -
 tools/perf/tests/parse-no-sample-id-all.c          |    2 -
 tools/perf/tests/perf-hooks.c                      |    1 -
 tools/perf/tests/pmu.c                             |    1 -
 tools/perf/tests/sample-parsing.c                  |    2 +-
 tools/perf/tests/stat.c                            |    1 +
 tools/perf/tests/switch-tracking.c                 |    1 -
 tools/perf/tests/task-exit.c                       |    2 +-
 tools/perf/tests/thread-map.c                      |    1 +
 tools/perf/tests/topology.c                        |    2 +-
 tools/perf/tests/vmlinux-kallsyms.c                |    2 +-
 tools/perf/ui/browser.c                            |    1 -
 tools/perf/ui/browsers/annotate.c                  |    1 -
 tools/perf/ui/browsers/header.c                    |    1 -
 tools/perf/ui/browsers/map.c                       |    1 -
 tools/perf/ui/browsers/res_sample.c                |    2 +-
 tools/perf/ui/browsers/scripts.c                   |    3 +-
 tools/perf/ui/gtk/helpline.c                       |    1 -
 tools/perf/ui/gtk/progress.c                       |    1 -
 tools/perf/ui/gtk/setup.c                          |    3 +-
 tools/perf/ui/gtk/util.c                           |    1 -
 tools/perf/ui/helpline.c                           |    2 -
 tools/perf/ui/hist.c                               |    1 -
 tools/perf/ui/setup.c                              |    2 +-
 tools/perf/ui/stdio/hist.c                         |    1 +
 tools/perf/ui/tui/helpline.c                       |    1 -
 tools/perf/ui/tui/setup.c                          |    2 +-
 tools/perf/ui/tui/util.c                           |    1 -
 tools/perf/util/Build                              |    1 +
 tools/perf/util/annotate.c                         |    2 +-
 tools/perf/util/arm-spe.c                          |    1 -
 tools/perf/util/auxtrace.c                         |    6 +-
 tools/perf/util/auxtrace.h                         |   18 +-
 tools/perf/util/bpf-event.c                        |    1 +
 tools/perf/util/bpf-event.h                        |   15 +-
 tools/perf/util/branch.c                           |    2 -
 tools/perf/util/branch.h                           |    9 +-
 tools/perf/util/build-id.c                         |    2 +-
 tools/perf/util/callchain.c                        |    1 +
 tools/perf/util/callchain.h                        |    5 +-
 tools/perf/util/cloexec.c                          |    2 +-
 tools/perf/util/cs-etm-decoder/cs-etm-decoder.c    |    1 -
 tools/perf/util/cs-etm.c                           |    2 +-
 tools/perf/util/data.c                             |    3 +-
 tools/perf/util/debug.c                            |    1 -
 tools/perf/util/debug.h                            |    2 +-
 tools/perf/util/demangle-java.c                    |    1 -
 tools/perf/util/demangle-rust.c                    |    1 -
 tools/perf/util/dwarf-regs.c                       |    1 -
 tools/perf/util/env.h                              |    3 +-
 tools/perf/util/event.c                            | 1109 +-----------
 tools/perf/util/event.h                            |   77 +-
 tools/perf/util/evlist.c                           |    2 +-
 tools/perf/util/evsel.c                            |  280 +--
 tools/perf/util/evsel.h                            |    5 -
 tools/perf/util/evsel_fprintf.c                    |    1 +
 tools/perf/util/header.c                           |  395 +---
 tools/perf/util/header.h                           |   60 +-
 tools/perf/util/hist.h                             |    1 +
 tools/perf/util/intel-bts.c                        |    2 +-
 tools/perf/util/intel-pt.c                         |    1 +
 tools/perf/util/jitdump.c                          |    2 -
 tools/perf/util/kvm-stat.h                         |    4 +
 tools/perf/util/libunwind/arm64.c                  |    1 -
 tools/perf/util/libunwind/x86_32.c                 |    1 -
 tools/perf/util/llvm-utils.c                       |    1 +
 tools/perf/util/lzma.c                             |    2 +-
 tools/perf/util/machine.c                          |   15 -
 tools/perf/util/machine.h                          |   15 -
 tools/perf/util/memswap.h                          |    7 +
 tools/perf/util/namespaces.c                       |   18 +
 tools/perf/util/namespaces.h                       |    2 +
 tools/perf/util/parse-events.c                     |    1 -
 tools/perf/util/perf-hooks.c                       |    1 -
 tools/perf/util/pmu.c                              |    1 -
 tools/perf/util/probe-file.c                       |    1 +
 tools/perf/util/python.c                           |    4 +-
 tools/perf/util/record.c                           |    2 -
 tools/perf/util/rwsem.c                            |    1 +
 tools/perf/util/s390-cpumsf.c                      |    1 -
 tools/perf/util/s390-sample-raw.c                  |    1 -
 .../util/scripting-engines/trace-event-python.c    |    2 -
 tools/perf/util/session.c                          |   72 +-
 tools/perf/util/session.h                          |    5 -
 tools/perf/util/srccode.c                          |    2 +-
 tools/perf/util/stat.c                             |   60 +-
 tools/perf/util/stat.h                             |    9 +-
 tools/perf/util/svghelper.c                        |    2 +-
 tools/perf/util/symbol-elf.c                       |    3 +
 tools/perf/util/symbol-minimal.c                   |    3 +-
 tools/perf/util/symbol.c                           |    2 +-
 tools/perf/util/synthetic-events.c                 | 1884 ++++++++++++++++++++
 tools/perf/util/synthetic-events.h                 |  103 ++
 tools/perf/util/target.c                           |    2 -
 tools/perf/util/top.c                              |    1 -
 tools/perf/util/trace-event-info.c                 |    2 +-
 tools/perf/util/trace-event-read.c                 |    1 -
 tools/perf/util/trace-event.c                      |    1 -
 tools/perf/util/tsc.h                              |   14 +-
 tools/perf/util/unwind-libdw.c                     |    1 -
 tools/perf/util/unwind-libunwind-local.c           |    1 -
 tools/perf/util/usage.c                            |    1 -
 tools/perf/util/vdso.c                             |    2 +-
 tools/perf/util/zlib.c                             |    4 +-
 180 files changed, 2763 insertions(+), 2256 deletions(-)
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/branch.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/bus.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/cache.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/exception.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/instruction.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/memory.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/other.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/pipeline.json
 create mode 100644 tools/perf/util/synthetic-events.c
 create mode 100644 tools/perf/util/synthetic-events.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.

Clearlinux is failing when building with libpython, but that is not a perf regression, will try to remove one compiler warning that is causing the problem when building some of the glue code files in the python files, outside perf.

  # export PERF_TARBALL=http://192.168.124.1/perf/perf-5.3.0-rc6.tar.xz
  # dm
   1 alpine:3.4                    : Ok   gcc (Alpine 5.3.0) 5.3.0, clang version 3.8.0 (tags/RELEASE_380/final)
   2 alpine:3.5                    : Ok   gcc (Alpine 6.2.1) 6.2.1 20160822, clang version 3.8.1 (tags/RELEASE_381/final)
   3 alpine:3.6                    : Ok   gcc (Alpine 6.3.0) 6.3.0, clang version 4.0.0 (tags/RELEASE_400/final)
   4 alpine:3.7                    : Ok   gcc (Alpine 6.4.0) 6.4.0, Alpine clang version 5.0.0 (tags/RELEASE_500/final) (based on LLVM 5.0.0)
   5 alpine:3.8                    : Ok   gcc (Alpine 6.4.0) 6.4.0, Alpine clang version 5.0.1 (tags/RELEASE_501/final) (based on LLVM 5.0.1)
   6 alpine:3.9                    : Ok   gcc (Alpine 8.3.0) 8.3.0, Alpine clang version 5.0.1 (tags/RELEASE_502/final) (based on LLVM 5.0.1)
   7 alpine:3.10                   : Ok   gcc (Alpine 8.3.0) 8.3.0, Alpine clang version 8.0.0 (tags/RELEASE_800/final) (based on LLVM 8.0.0)
   8 alpine:edge                   : Ok   gcc (Alpine 8.3.0) 8.3.0, Alpine clang version 8.0.1 (tags/RELEASE_801/final) (based on LLVM 8.0.1)
   9 amazonlinux:1                 : Ok   gcc (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2), clang version 3.6.2 (tags/RELEASE_362/final)
  10 amazonlinux:2                 : Ok   gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5), clang version 7.0.1 (Amazon Linux 2 7.0.1-1.amzn2.0.2)
  11 android-ndk:r12b-arm          : Ok   arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
  12 android-ndk:r15c-arm          : Ok   arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
  13 centos:5                      : Ok   gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55)
  14 centos:6                      : Ok   gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
  15 centos:7                      : Ok   gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39), clang version 3.4.2 (tags/RELEASE_34/dot2-final)
  16 clearlinux:latest             : Ok   gcc (Clear Linux OS for Intel Architecture) 9.2.1 20190908 gcc-9-branch@275492, clang version 8.0.0 (tags/RELEASE_800/final)
  17 debian:8                      : Ok   gcc (Debian 4.9.2-10+deb8u2) 4.9.2, Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
  18 debian:9                      : Ok   gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, clang version 3.8.1-24 (tags/RELEASE_381/final)
  19 debian:10                     : Ok   gcc (Debian 8.3.0-6) 8.3.0, clang version 7.0.1-8 (tags/RELEASE_701/final)
  20 debian:experimental           : Ok   gcc (Debian 9.2.1-8) 9.2.1 20190909, clang version 8.0.1-3+b1 (tags/RELEASE_801/final)
  21 debian:experimental-x-arm64   : Ok   aarch64-linux-gnu-gcc (Debian 8.3.0-19) 8.3.0
  22 debian:experimental-x-mips    : Ok   mips-linux-gnu-gcc (Debian 8.3.0-19) 8.3.0
  23 debian:experimental-x-mips64  : Ok   mips64-linux-gnuabi64-gcc (Debian 8.3.0-7) 8.3.0
  24 debian:experimental-x-mipsel  : Ok   mipsel-linux-gnu-gcc (Debian 8.3.0-19) 8.3.0
  25 fedora:20                     : Ok   gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7), clang version 3.4.2 (tags/RELEASE_34/dot2-final)
  26 fedora:22                     : Ok   gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6), clang version 3.5.0 (tags/RELEASE_350/final)
  27 fedora:23                     : Ok   gcc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6), clang version 3.7.0 (tags/RELEASE_370/final)
  28 fedora:24                     : Ok   gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1), clang version 3.8.1 (tags/RELEASE_381/final)
  29 fedora:24-x-ARC-uClibc        : Ok   arc-linux-gcc (ARCompact ISA Linux uClibc toolchain 2017.09-rc2) 7.1.1 20170710
  30 fedora:25                     : Ok   gcc (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1), clang version 3.9.1 (tags/RELEASE_391/final)
  31 fedora:26                     : Ok   gcc (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2), clang version 4.0.1 (tags/RELEASE_401/final)
  32 fedora:27                     : Ok   gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-6), clang version 5.0.2 (tags/RELEASE_502/final)
  33 fedora:28                     : Ok   gcc (GCC) 8.3.1 20190223 (Red Hat 8.3.1-2), clang version 6.0.1 (tags/RELEASE_601/final)
  34 fedora:29                     : Ok   gcc (GCC) 8.3.1 20190223 (Red Hat 8.3.1-2), clang version 7.0.1 (Fedora 7.0.1-6.fc29)
  35 fedora:30                     : Ok   gcc (GCC) 9.1.1 20190503 (Red Hat 9.1.1-1), clang version 8.0.0 (Fedora 8.0.0-1.fc30)
  36 fedora:30-x-ARC-glibc         : Ok   arc-linux-gcc (ARC HS GNU/Linux glibc toolchain 2019.03-rc1) 8.3.1 20190225
  37 fedora:30-x-ARC-uClibc        : Ok   arc-linux-gcc (ARCv2 ISA Linux uClibc toolchain 2019.03-rc1) 8.3.1 20190225
  38 fedora:31                     : Ok   gcc (GCC) 9.1.1 20190605 (Red Hat 9.1.1-2), clang version 8.0.0 (Fedora 8.0.0-3.fc31.1)
  39 fedora:rawhide                : Ok   gcc (GCC) 9.1.1 20190605 (Red Hat 9.1.1-2), clang version 8.0.0 (Fedora 8.0.0-3.fc31.1)
  40 gentoo-stage3-amd64:latest    : Ok   gcc (Gentoo 8.3.0-r1 p1.1) 8.3.0
  41 mageia:5                      : Ok   gcc (GCC) 4.9.2, clang version 3.5.2 (tags/RELEASE_352/final)
  42 mageia:6                      : Ok   gcc (Mageia 5.5.0-1.mga6) 5.5.0, clang version 3.9.1 (tags/RELEASE_391/final)
  43 mageia:7                      : Ok   gcc (Mageia 8.3.1-0.20190524.1.mga7) 8.3.1 20190524, clang version 8.0.0 (Mageia 8.0.0-1.mga7)
  44 manjaro:latest                : Ok   gcc (GCC) 9.1.0, clang version 8.0.1 (tags/RELEASE_801/final)
  45 opensuse:15.0                 : Ok   gcc (SUSE Linux) 7.4.1 20190424 [gcc-7-branch revision 270538], clang version 5.0.1 (tags/RELEASE_501/final 312548)
  46 opensuse:15.1                 : Ok   gcc (SUSE Linux) 7.4.1 20190424 [gcc-7-branch revision 270538], clang version 7.0.1 (tags/RELEASE_701/final 349238)
  47 opensuse:42.3                 : Ok   gcc (SUSE Linux) 4.8.5, clang version 3.8.0 (tags/RELEASE_380/final 262553)
  48 opensuse:tumbleweed           : Ok   gcc (SUSE Linux) 9.2.1 20190820 [gcc-9-branch revision 274748], clang version 8.0.1 (tags/RELEASE_801/final 366581)
  49 oraclelinux:6                 : Ok   gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23.0.1)
  50 oraclelinux:7                 : Ok   gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39.0.1), clang version 3.4.2 (tags/RELEASE_34/dot2-final)
  51 oraclelinux:8                 : Ok   gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3.0.1), clang version 7.0.1 (tags/RELEASE_701/final)
  52 ubuntu:12.04                  : Ok   gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3, Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0)
  53 ubuntu:14.04                  : Ok   gcc (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4, Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)
  54 ubuntu:16.04                  : Ok   gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609, clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
  55 ubuntu:16.04-x-arm            : Ok   arm-linux-gnueabihf-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  56 ubuntu:16.04-x-arm64          : Ok   aarch64-linux-gnu-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  57 ubuntu:16.04-x-powerpc        : Ok   powerpc-linux-gnu-gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  58 ubuntu:16.04-x-powerpc64      : Ok   powerpc64-linux-gnu-gcc (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  59 ubuntu:16.04-x-powerpc64el    : Ok   powerpc64le-linux-gnu-gcc (Ubuntu/IBM 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  60 ubuntu:16.04-x-s390           : Ok   s390x-linux-gnu-gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  61 ubuntu:18.04                  : Ok   gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0, clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
  62 ubuntu:18.04-x-arm            : Ok   arm-linux-gnueabihf-gcc (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1) 7.4.0
  63 ubuntu:18.04-x-arm64          : Ok   aarch64-linux-gnu-gcc (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1) 7.4.0
  64 ubuntu:18.04-x-m68k           : Ok   m68k-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
  65 ubuntu:18.04-x-powerpc        : Ok   powerpc-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
  66 ubuntu:18.04-x-powerpc64      : Ok   powerpc64-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
  67 ubuntu:18.04-x-powerpc64el    : Ok   powerpc64le-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
  68 ubuntu:18.04-x-riscv64        : Ok   riscv64-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
  69 ubuntu:18.04-x-s390           : Ok   s390x-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
  70 ubuntu:18.04-x-sh4            : Ok   sh4-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
  71 ubuntu:18.04-x-sparc64        : Ok   sparc64-linux-gnu-gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
  72 ubuntu:18.10                  : Ok   gcc (Ubuntu 8.3.0-6ubuntu1~18.10.1) 8.3.0, clang version 7.0.0-3 (tags/RELEASE_700/final)
  73 ubuntu:19.04                  : Ok   gcc (Ubuntu 8.3.0-6ubuntu1) 8.3.0, clang version 8.0.0-3 (tags/RELEASE_800/final)
  74 ubuntu:19.04-x-alpha          : Ok   alpha-linux-gnu-gcc (Ubuntu 8.3.0-6ubuntu1) 8.3.0
  75 ubuntu:19.04-x-arm64          : Ok   aarch64-linux-gnu-gcc (Ubuntu/Linaro 8.3.0-6ubuntu1) 8.3.0
  76 ubuntu:19.04-x-hppa           : Ok   hppa-linux-gnu-gcc (Ubuntu 8.3.0-6ubuntu1) 8.3.0
  77 ubuntu:19.10                  : Ok   gcc (Ubuntu 9.2.1-8ubuntu1) 9.2.1 20190909, clang version 9.0.0-+rc5-1~exp1 (tags/RELEASE_900/rc5)
  #
  # uname -a
  Linux quaco 5.3.0+ #2 SMP Thu Sep 19 16:13:22 -03 2019 x86_64 x86_64 x86_64 GNU/Linux
  # git log --oneline -1
  2bff2b828502 perf kvm stat: Set 'trace_cycles' as default event for 'perf kvm record' in powerpc
  # perf version --build-options
  perf version 5.3.rc6.g2bff2b828502
                   dwarf: [ on  ]  # HAVE_DWARF_SUPPORT
      dwarf_getlocations: [ on  ]  # HAVE_DWARF_GETLOCATIONS_SUPPORT
                   glibc: [ on  ]  # HAVE_GLIBC_SUPPORT
                    gtk2: [ on  ]  # HAVE_GTK2_SUPPORT
           syscall_table: [ on  ]  # HAVE_SYSCALL_TABLE_SUPPORT
                  libbfd: [ on  ]  # HAVE_LIBBFD_SUPPORT
                  libelf: [ on  ]  # HAVE_LIBELF_SUPPORT
                 libnuma: [ on  ]  # HAVE_LIBNUMA_SUPPORT
  numa_num_possible_cpus: [ on  ]  # HAVE_LIBNUMA_SUPPORT
                 libperl: [ on  ]  # HAVE_LIBPERL_SUPPORT
               libpython: [ on  ]  # HAVE_LIBPYTHON_SUPPORT
                libslang: [ on  ]  # HAVE_SLANG_SUPPORT
               libcrypto: [ on  ]  # HAVE_LIBCRYPTO_SUPPORT
               libunwind: [ on  ]  # HAVE_LIBUNWIND_SUPPORT
      libdw-dwarf-unwind: [ on  ]  # HAVE_DWARF_SUPPORT
                    zlib: [ on  ]  # HAVE_ZLIB_SUPPORT
                    lzma: [ on  ]  # HAVE_LZMA_SUPPORT
               get_cpuid: [ on  ]  # HAVE_AUXTRACE_SUPPORT
                     bpf: [ on  ]  # HAVE_LIBBPF_SUPPORT
                     aio: [ on  ]  # HAVE_AIO_SUPPORT
                    zstd: [ on  ]  # HAVE_ZSTD_SUPPORT
  # perf test
   1: vmlinux symtab matches kallsyms                       : Ok
   2: Detect openat syscall event                           : Ok
   3: Detect openat syscall event on all cpus               : Ok
   4: Read samples using the mmap interface                 : Ok
   5: Test data source output                               : Ok
   6: Parse event definition strings                        : Ok
   7: Simple expression parser                              : Ok
   8: PERF_RECORD_* events & perf_sample fields             : Ok
   9: Parse perf pmu format                                 : Ok
  10: DSO data read                                         : Ok
  11: DSO data cache                                        : Ok
  12: DSO data reopen                                       : Ok
  13: Roundtrip evsel->name                                 : Ok
  14: Parse sched tracepoints fields                        : Ok
  15: syscalls:sys_enter_openat event fields                : Ok
  16: Setup struct perf_event_attr                          : Ok
  17: Match and link multiple hists                         : Ok
  18: 'import perf' in python                               : Ok
  19: Breakpoint overflow signal handler                    : Ok
  20: Breakpoint overflow sampling                          : Ok
  21: Breakpoint accounting                                 : Ok
  22: Watchpoint                                            :
  22.1: Read Only Watchpoint                                : Skip
  22.2: Write Only Watchpoint                               : Ok
  22.3: Read / Write Watchpoint                             : Ok
  22.4: Modify Watchpoint                                   : Ok
  23: Number of exit events of a simple workload            : Ok
  24: Software clock events period values                   : Ok
  25: Object code reading                                   : Ok
  26: Sample parsing                                        : Ok
  27: Use a dummy software event to keep tracking           : Ok
  28: Parse with no sample_id_all bit set                   : Ok
  29: Filter hist entries                                   : Ok
  30: Lookup mmap thread                                    : Ok
  31: Share thread 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: time utils                                            : Ok
  60: map_groups__merge_in                                  : Ok
  61: x86 rdpmc                                             : Ok
  62: Convert perf time to TSC                              : Ok
  63: DWARF unwind                                          : Ok
  64: x86 instruction decoder - new instructions            : Ok
  65: Intel PT packet decoder                               : Ok
  66: x86 bp modify                                         : Ok
  67: probe libc's inet_pton & backtrace it with ping       : Ok
  68: Use vfs_getname probe to get syscall args filenames   : Ok
  69: Add vfs_getname probe to get syscall args filenames   : Ok
  70: Check open filename arg using perf trace + vfs_getname: Ok
  71: Zstd perf.data compression/decompression              : Ok
  #
  $ make -C tools/perf build-test
  make: Entering directory '/home/acme/git/perf/tools/perf'
  - tarpkg: ./tests/perf-targz-src-pkg .
                make_install_O: make install
             make_util_map_o_O: make util/map.o
                  make_no_ui_O: make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
            make_no_libaudit_O: make NO_LIBAUDIT=1
              make_no_libelf_O: make NO_LIBELF=1
           make_no_libbionic_O: make NO_LIBBIONIC=1
           make_no_libunwind_O: make NO_LIBUNWIND=1
                 make_perf_o_O: make perf.o
             make_no_scripts_O: make NO_LIBPYTHON=1 NO_LIBPERL=1
              make_clean_all_O: make clean all
                    make_doc_O: make doc
                make_no_gtk2_O: make NO_GTK2=1
         make_with_clangllvm_O: make LIBCLANGLLVM=1
                 make_static_O: make LDFLAGS=-static
                   make_help_O: make help
  make_no_libdw_dwarf_unwind_O: make NO_LIBDW_DWARF_UNWIND=1
       make_util_pmu_bison_o_O: make util/pmu-bison.o
                   make_pure_O: make
                   make_tags_O: make tags
                make_no_newt_O: make NO_NEWT=1
                 make_cscope_O: make cscope
            make_install_bin_O: make install-bin
              make_no_libbpf_O: make NO_LIBBPF=1
           make_no_backtrace_O: make NO_BACKTRACE=1
   make_install_prefix_slash_O: make install prefix=/tmp/krava/
        make_with_babeltrace_O: make LIBBABELTRACE=1
         make_install_prefix_O: make install prefix=/tmp/krava
                make_minimal_O: make NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1 NO_LIBZSTD=1 NO_LIBCAP=1
            make_no_demangle_O: make NO_DEMANGLE=1
             make_no_libnuma_O: make NO_LIBNUMA=1
            make_no_auxtrace_O: make NO_AUXTRACE=1
                  make_debug_O: make DEBUG=1
               make_no_slang_O: make NO_SLANG=1
           make_no_libpython_O: make NO_LIBPYTHON=1
             make_no_libperl_O: make NO_LIBPERL=1
  OK
  make: Leaving directory '/home/acme/git/perf/tools/perf'
  $
author maintainer
#1 lore raw

PATCH 1/31 perf python: Add missing python/perf.so dependency for libperf

From: Jiri Olsa <[email protected]>

The python/perf.so compilation needs libperf ready, otherwise it fails:

  $ make python/perf.so JOBS=1
    BUILD:   Doing 'make -j1' parallel build
    GEN      python/perf.so
  gcc: error: /home/jolsa/kernel/linux-perf/tools/perf/lib/libperf.a: No such file or directory

Fixing this with by adding libperf dependency.

---
 tools/perf/Makefile.perf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.perf +1 -1
index f9807d8c005b..2ccc12f3730b 100644
@@ -567,7 +567,7 @@ all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS)
 # Create python binding output directory if not already present
 _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python')
 
-$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST)
+$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBTRACEEVENT_DYNAMIC_LIST) $(LIBPERF)
 	$(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \
         CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS)' \
 	  $(PYTHON_WORD) util/setup.py \
Signature · 1 line
2.21.0
author maintainer
#2 lore raw

PATCH 2/31 perf tests: Add libperf automated test for 'make -C tools/perf build-test'

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

Add a libperf build test, that is triggered when one does:

  $ make -C tools/perf build-test
---
 tools/perf/tests/make | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/perf/tests/make +5 -1
index 70c48475896d..6b3afed5d910 100644
@@ -327,6 +327,10 @@ make_kernelsrc_tools:
 	(make -C ../../tools $(PARALLEL_OPT) $(K_O_OPT) perf) > $@ 2>&1 && \
 	test -x $(KERNEL_O)/tools/perf/perf && rm -f $@ || (cat $@ ; false)
 
+make_libperf:
+	@echo "- make -C lib";
+	make -C lib clean >$@ 2>&1; make -C lib >>$@ 2>&1 && rm $@
+
 FEATURES_DUMP_FILE := $(FULL_O)/BUILD_TEST_FEATURE_DUMP
 FEATURES_DUMP_FILE_STATIC := $(FULL_O)/BUILD_TEST_FEATURE_DUMP_STATIC
 
@@ -365,5 +369,5 @@ $(foreach t,$(run),$(if $(findstring make_static,$(t)),\
 			$(eval $(t) := $($(t)) FEATURES_DUMP=$(FEATURES_DUMP_FILE))))
 endif
 
-.PHONY: all $(run) $(run_O) tarpkg clean make_kernelsrc make_kernelsrc_tools
+.PHONY: all $(run) $(run_O) tarpkg clean make_kernelsrc make_kernelsrc_tools make_libperf
 endif # ifndef MK
Signature · 1 line
2.21.0
author maintainer
#3 lore raw

PATCH 3/31 libperf: Add missing event.h file to install rule

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

So that this development header is properly installed and can be found by tools linking with libperf.

---
 tools/perf/lib/Makefile | 1 +
 1 file changed, 1 insertion(+)
tools/perf/lib/Makefile +1 -0
index a67efb8d9d39..e325c0503dc6 100644
@@ -146,6 +146,7 @@ install_headers:
 		$(call do_install,include/perf/threadmap.h,$(prefix)/include/perf,644); \
 		$(call do_install,include/perf/evlist.h,$(prefix)/include/perf,644); \
 		$(call do_install,include/perf/evsel.h,$(prefix)/include/perf,644);
+		$(call do_install,include/perf/event.h,$(prefix)/include/perf,644);
 
 install_pkgconfig: $(LIBPERF_PC)
 	$(call QUIET_INSTALL, $(LIBPERF_PC)) \
Signature · 1 line
2.21.0
author maintainer
#4 lore raw

PATCH 4/31 libperf: Adopt perf_cpu_map__max() function

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

From 'perf stat', so that it can be used from multiple places.

---
 tools/perf/builtin-stat.c            | 14 +-------------
 tools/perf/lib/cpumap.c              | 12 ++++++++++++
 tools/perf/lib/include/perf/cpumap.h |  1 +
 tools/perf/lib/libperf.map           |  1 +
 4 files changed, 15 insertions(+), 13 deletions(-)
tools/perf/builtin-stat.c +1 -13
index 7e17bf9f700a..5bc0c570b7b6 100644
@@ -822,18 +822,6 @@ static int perf_stat__get_core(struct perf_stat_config *config __maybe_unused,
 	return cpu_map__get_core(map, cpu, NULL);
 }
 
-static int cpu_map__get_max(struct perf_cpu_map *map)
-{
-	int i, max = -1;
-
-	for (i = 0; i < map->nr; i++) {
-		if (map->map[i] > max)
-			max = map->map[i];
-	}
-
-	return max;
-}
-
 static int perf_stat__get_aggr(struct perf_stat_config *config,
 			       aggr_get_id_t get_id, struct perf_cpu_map *map, int idx)
 {
@@ -928,7 +916,7 @@ static int perf_stat_init_aggr_mode(void)
 	 * taking the highest cpu number to be the size of
 	 * the aggregation translate cpumap.
 	 */
-	nr = cpu_map__get_max(evsel_list->core.cpus);
+	nr = perf_cpu_map__max(evsel_list->core.cpus);
 	stat_config.cpus_aggr_map = perf_cpu_map__empty_new(nr + 1);
 	return stat_config.cpus_aggr_map ? 0 : -ENOMEM;
 }
tools/perf/lib/cpumap.c +12 -0
index 1f0e6f334237..2ca1fafa620d 100644
@@ -260,3 +260,15 @@ int perf_cpu_map__idx(struct perf_cpu_map *cpus, int cpu)
 
 	return -1;
 }
+
+int perf_cpu_map__max(struct perf_cpu_map *map)
+{
+	int i, max = -1;
+
+	for (i = 0; i < map->nr; i++) {
+		if (map->map[i] > max)
+			max = map->map[i];
+	}
+
+	return max;
+}
tools/perf/lib/include/perf/cpumap.h +1 -0
index 8aa995c59498..ac9aa497f84a 100644
@@ -16,6 +16,7 @@ LIBPERF_API void perf_cpu_map__put(struct perf_cpu_map *map);
 LIBPERF_API int perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx);
 LIBPERF_API int perf_cpu_map__nr(const struct perf_cpu_map *cpus);
 LIBPERF_API bool perf_cpu_map__empty(const struct perf_cpu_map *map);
+LIBPERF_API int perf_cpu_map__max(struct perf_cpu_map *map);
 
 #define perf_cpu_map__for_each_cpu(cpu, idx, cpus)		\
 	for ((idx) = 0, (cpu) = perf_cpu_map__cpu(cpus, idx);	\
tools/perf/lib/libperf.map +1 -0
index dc4d66363bc4..cd0d17b996c8 100644
@@ -9,6 +9,7 @@ LIBPERF_0.0.1 {
 		perf_cpu_map__nr;
 		perf_cpu_map__cpu;
 		perf_cpu_map__empty;
+		perf_cpu_map__max;
 		perf_thread_map__new_dummy;
 		perf_thread_map__set_pid;
 		perf_thread_map__comm;
Signature · 1 line
2.21.0
author maintainer
#5 lore raw

PATCH 5/31 perf jvmti: Link against tools/lib/string.o to have weak strlcpy()

In reply to Arnaldo Carvalho de Melo

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

That is needed in systems such some S/390 distros.

  $ readelf -s /tmp/build/perf/jvmti/jvmti-in.o | grep strlcpy
	452: 0000000000002990   125 FUNC    WEAK   DEFAULT  119 strlcpy
  $

Thanks to Jiri Olsa for fixing up my initial stab at this, I forgot how Makefiles are picky about spaces versus tabs.

---
 tools/perf/jvmti/Build | 9 +++++++++
 1 file changed, 9 insertions(+)
tools/perf/jvmti/Build +9 -0
index eaeb8cb5379b..1e148bbdf820 100644
@@ -1,8 +1,17 @@
 jvmti-y += libjvmti.o
 jvmti-y += jvmti_agent.o
 
+# For strlcpy
+jvmti-y += libstring.o
+
 CFLAGS_jvmti         = -fPIC -DPIC -I$(JDIR)/include -I$(JDIR)/include/linux
 CFLAGS_REMOVE_jvmti  = -Wmissing-declarations
 CFLAGS_REMOVE_jvmti += -Wstrict-prototypes
 CFLAGS_REMOVE_jvmti += -Wextra
 CFLAGS_REMOVE_jvmti += -Wwrite-strings
+
+CFLAGS_libstring.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
+
+$(OUTPUT)jvmti/libstring.o: ../lib/string.c FORCE
+	$(call rule_mkdir)
+	$(call if_changed_dep,cc_o_c)
Signature · 1 line
2.21.0
author maintainer
#6 lore raw

PATCH 6/31 perf tools: Add PMU event JSON files for ARM Cortex-A76 and, Neoverse N1.

In reply to Arnaldo Carvalho de Melo

From: James Clark <[email protected]>

The source of the event codes and description text was the Neoverse N1 technical reference manual at:

http://infocenter.arm.com/help/topic/com.arm.doc.100616_0301_01_en/neoverse_n1_trm_100616_0301_01_en.pdf

The Cortex-A76 shares the same event IDs as the Neoverse N1 and they can be viewed at:

https://static.docs.arm.com/100798/0400/cortex_a76_trm_100798_0400_00_en.pdf

---
 .../arch/arm64/arm/cortex-a76-n1/branch.json  |  14 ++
 .../arch/arm64/arm/cortex-a76-n1/bus.json     |  24 ++
 .../arch/arm64/arm/cortex-a76-n1/cache.json   | 207 ++++++++++++++++++
 .../arm64/arm/cortex-a76-n1/exception.json    |  52 +++++
 .../arm64/arm/cortex-a76-n1/instruction.json  | 108 +++++++++
 .../arch/arm64/arm/cortex-a76-n1/memory.json  |  23 ++
 .../arch/arm64/arm/cortex-a76-n1/other.json   |   7 +
 .../arm64/arm/cortex-a76-n1/pipeline.json     |  14 ++
 tools/perf/pmu-events/arch/arm64/mapfile.csv  |   2 +
 9 files changed, 451 insertions(+)
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/branch.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/bus.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/cache.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/exception.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/instruction.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/memory.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/other.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/pipeline.json
tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/branch.json new file +14 -0
new file mode 100644
index 000000000000..b5e5d055c70d
@@ -0,0 +1,14 @@
+[
+    {
+        "PublicDescription": "Mispredicted or not predicted branch speculatively executed. This event counts any predictable branch instruction which is mispredicted either due to dynamic misprediction or because the MMU is off and the branches are statically predicted not taken.",
+        "EventCode": "0x10",
+        "EventName": "BR_MIS_PRED",
+        "BriefDescription": "Mispredicted or not predicted branch speculatively executed."
+    },
+    {
+        "PublicDescription": "Predictable branch speculatively executed. This event counts all predictable branches.",
+        "EventCode": "0x12",
+        "EventName": "BR_PRED",
+        "BriefDescription": "Predictable branch speculatively executed."
+    }
+]
tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/bus.json new file +24 -0
new file mode 100644
index 000000000000..fce7309ae624
@@ -0,0 +1,24 @@
+[
+    {
+        "EventCode": "0x11",
+        "EventName": "CPU_CYCLES",
+        "BriefDescription": "The number of core clock cycles."
+    },
+    {
+        "PublicDescription": "Bus access. This event counts for every beat of data transferred over the data channels between the core and the SCU. If both read and write data beats are transferred on a given cycle, this event is counted twice on that cycle. This event counts the sum of BUS_ACCESS_RD and BUS_ACCESS_WR.",
+        "EventCode": "0x19",
+        "EventName": "BUS_ACCESS",
+        "BriefDescription": "Bus access."
+    },
+    {
+        "EventCode": "0x1D",
+        "EventName": "BUS_CYCLES",
+        "BriefDescription": "Bus cycles. This event duplicates CPU_CYCLES."
+    },
+    {
+        "ArchStdEvent":  "BUS_ACCESS_RD"
+    },
+    {
+        "ArchStdEvent":  "BUS_ACCESS_WR"
+    }
+]
tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/cache.json new file +207 -0

207 lines not on this page · raw message

tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/exception.json new file +52 -0

52 lines not on this page · raw message

tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/instruction.json new file +108 -0

108 lines not on this page · raw message

tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/memory.json new file +23 -0
new file mode 100644
index 000000000000..b86643253f19
@@ -0,0 +1,23 @@
+[
+    {
+        "PublicDescription": "Data memory access. This event counts memory accesses due to load or store instructions. This event counts the sum of MEM_ACCESS_RD and MEM_ACCESS_WR.",
+        "EventCode": "0x13",
+        "EventName": "MEM_ACCESS",
+        "BriefDescription": "Data memory access"
+    },
+    {
+         "ArchStdEvent": "MEM_ACCESS_RD"
+    },
+    {
+         "ArchStdEvent": "MEM_ACCESS_WR"
+    },
+    {
+         "ArchStdEvent": "UNALIGNED_LD_SPEC"
+    },
+    {
+         "ArchStdEvent": "UNALIGNED_ST_SPEC"
+    },
+    {
+         "ArchStdEvent": "UNALIGNED_LDST_SPEC"
+    }
+]
tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/other.json new file +7 -0
new file mode 100644
index 000000000000..8bde029a62d5
@@ -0,0 +1,7 @@
+[
+    {
+        "EventCode": "0x31",
+        "EventName": "REMOTE_ACCESS",
+        "BriefDescription": "Access to another socket in a multi-socket system"
+    }
+]
tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/pipeline.json new file +14 -0
new file mode 100644
index 000000000000..010a647f9d02
@@ -0,0 +1,14 @@
+[
+    {
+        "PublicDescription": "No operation issued because of the frontend. The counter counts on any cycle when there are no fetched instructions available to dispatch.",
+        "EventCode": "0x23",
+        "EventName": "STALL_FRONTEND",
+        "BriefDescription": "No operation issued because of the frontend."
+    },
+    {
+        "PublicDescription": "No operation issued because of the backend. The counter counts on any cycle fetched instructions are not dispatched due to resource constraints.",
+        "EventCode": "0x24",
+        "EventName": "STALL_BACKEND",
+        "BriefDescription": "No operation issued because of the backend."
+    }
+]
tools/perf/pmu-events/arch/arm64/mapfile.csv +2 -0
index 927fcddcb4aa..0d609149b82a 100644
@@ -16,6 +16,8 @@
 0x00000000420f1000,v1,arm/cortex-a53,core
 0x00000000410fd070,v1,arm/cortex-a57-a72,core
 0x00000000410fd080,v1,arm/cortex-a57-a72,core
+0x00000000410fd0b0,v1,arm/cortex-a76-n1,core
+0x00000000410fd0c0,v1,arm/cortex-a76-n1,core
 0x00000000420f5160,v1,cavium/thunderx2,core
 0x00000000430f0af0,v1,cavium/thunderx2,core
 0x00000000480fd010,v1,hisilicon/hip08,core
Signature · 1 line
2.21.0
author maintainer
#7 lore raw

PATCH 7/31 perf tools: Remove needless builtin.h include directives

In reply to Arnaldo Carvalho de Melo

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

Now that builtin.h isn't included by any other header, we can check where it is really needed, i.e. we can remove it and be sure that it isn't being obtained indirectly.

---
 tools/perf/bench/numa.c            | 1 -
 tools/perf/bench/sched-messaging.c | 1 -
 tools/perf/bench/sched-pipe.c      | 1 -
 tools/perf/util/jitdump.c          | 1 -
 4 files changed, 4 deletions(-)
tools/perf/bench/numa.c +0 -1
index 62b8ef4bcb1f..5797253b9700 100644
@@ -9,7 +9,6 @@
 /* For the CLR_() macros */
 #include <pthread.h>
 
-#include "../builtin.h"
 #include <subcmd/parse-options.h>
 #include "../util/cloexec.h"
 
tools/perf/bench/sched-messaging.c +0 -1
index c63eb9a46346..6e499b32bf00 100644
@@ -12,7 +12,6 @@
 
 #include "../util/util.h"
 #include <subcmd/parse-options.h>
-#include "../builtin.h"
 #include "bench.h"
 
 /* Test groups of 20 processes spraying to 20 receivers */
tools/perf/bench/sched-pipe.c +0 -1
index 35b07f197d48..edd40aafa318 100644
@@ -11,7 +11,6 @@
  */
 #include "../util/util.h"
 #include <subcmd/parse-options.h>
-#include "../builtin.h"
 #include "bench.h"
 
 #include <unistd.h>
tools/perf/util/jitdump.c +0 -1
index b80f29bfc7bb..00db9957fdb0 100644
@@ -27,7 +27,6 @@
 #include "jit.h"
 #include "jitdump.h"
 #include "genelf.h"
-#include "../builtin.h"
 
 #include <linux/ctype.h>
 #include <linux/zalloc.h>
Signature · 1 line
2.21.0
author maintainer
#8 lore raw

PATCH 8/31 perf debug: No need to include ui/util.h

In reply to Arnaldo Carvalho de Melo

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

Nothing from that file is used in util/debug.h, it is only needed in some places that get it indirectly via including util/debug.h, remove that entanglement.

---
 tools/perf/ui/browsers/scripts.c | 1 +
 tools/perf/ui/gtk/setup.c        | 3 ++-
 tools/perf/util/debug.h          | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)
tools/perf/ui/browsers/scripts.c +1 -0
index 586a21acc13d..3b81075b8da8 100644
@@ -2,6 +2,7 @@
 #include "../../builtin.h"
 #include "../../perf.h"
 #include "../../util/util.h"
+#include "../util.h"
 #include "../../util/hist.h"
 #include "../../util/debug.h"
 #include "../../util/symbol.h"
tools/perf/ui/gtk/setup.c +2 -1
index 1a2616b97b5c..f5eee4d66873 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "gtk.h"
-#include "../../util/debug.h"
+#include <linux/compiler.h>
+#include "../util.h"
 
 extern struct perf_error_ops perf_gtk_eops;
 
tools/perf/util/debug.h +1 -1
index b2deee987ffa..d25ae1c4cee9 100644
@@ -3,9 +3,9 @@
 #ifndef __PERF_DEBUG_H
 #define __PERF_DEBUG_H
 
+#include <stdarg.h>
 #include <stdbool.h>
 #include <linux/compiler.h>
-#include "../ui/util.h"
 
 extern int verbose;
 extern bool quiet, dump_trace;
Signature · 1 line
2.21.0
author maintainer
#9 lore raw

PATCH 9/31 perf tools: Remove debug.h from places where it is not needed

In reply to Arnaldo Carvalho de Melo

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

Pruning a bit more the includes dependency tree. Building this thing on lots of containers takes time, we better reduce the time per build, each container is doing 6 builds when clang and clang-devel are available, and the plan is to do a 'make -C tools/perf build-test' that have many more.

Also helps when doing normal development, as touching some random file will have a much reduced chance of triggering lots of rebuilds.

---
 tools/perf/arch/arm64/util/unwind-libunwind.c | 2 +-
 tools/perf/arch/powerpc/util/sym-handling.c   | 1 -
 tools/perf/tests/clang.c                      | 1 -
 tools/perf/ui/browsers/header.c               | 1 -
 tools/perf/ui/gtk/helpline.c                  | 1 -
 tools/perf/ui/gtk/util.c                      | 1 -
 tools/perf/ui/helpline.c                      | 1 -
 tools/perf/ui/tui/helpline.c                  | 1 -
 tools/perf/ui/tui/util.c                      | 1 -
 tools/perf/util/branch.c                      | 1 -
 tools/perf/util/demangle-java.c               | 1 -
 tools/perf/util/libunwind/arm64.c             | 1 -
 tools/perf/util/libunwind/x86_32.c            | 1 -
 tools/perf/util/target.c                      | 1 -
 tools/perf/util/usage.c                       | 1 -
 tools/perf/util/zlib.c                        | 2 --
 16 files changed, 1 insertion(+), 17 deletions(-)
tools/perf/arch/arm64/util/unwind-libunwind.c +1 -1
index 002520d4036b..1495a9523a23 100644
@@ -5,8 +5,8 @@
 #include <libunwind.h>
 #include "perf_regs.h"
 #include "../../util/unwind.h"
-#include "../../util/debug.h"
 #endif
+#include "../../util/debug.h"
 
 int LIBUNWIND__ARCH_REG_ID(int regnum)
 {
tools/perf/arch/powerpc/util/sym-handling.c +0 -1
index 8a4b717e0a53..abb7a12d8f93 100644
@@ -4,7 +4,6 @@
  * Copyright (C) 2015 Naveen N. Rao, IBM Corporation
  */
 
-#include "debug.h"
 #include "dso.h"
 #include "symbol.h"
 #include "map.h"
tools/perf/tests/clang.c +0 -1
index f45fe11dcf50..ff2711a40940 100644
@@ -1,6 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "tests.h"
-#include "debug.h"
 #include "util.h"
 #include "c++/clang-c.h"
 #include <linux/kernel.h>
tools/perf/ui/browsers/header.c +0 -1
index 0f59a7001479..57e6e4332f74 100644
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#include "util/debug.h"
 #include "ui/browser.h"
 #include "ui/keysyms.h"
 #include "ui/ui.h"
tools/perf/ui/gtk/helpline.c +0 -1
index e166da9ec767..e40a006aead8 100644
@@ -6,7 +6,6 @@
 #include "gtk.h"
 #include "../ui.h"
 #include "../helpline.h"
-#include "../../util/debug.h"
 
 static void gtk_helpline_pop(void)
 {
tools/perf/ui/gtk/util.c +0 -1
index c2c558958b9c..c47f5c387838 100644
@@ -1,6 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "../util.h"
-#include "../../util/debug.h"
 #include "gtk.h"
 
 #include <stdlib.h>
tools/perf/ui/helpline.c +0 -1
index 54bcd08df87e..e00901450f91 100644
@@ -3,7 +3,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "../util/debug.h"
 #include "helpline.h"
 #include "ui.h"
 #include "../util/util.h"
tools/perf/ui/tui/helpline.c +0 -1
index 5f188f678c55..298d6af82fdd 100644
@@ -6,7 +6,6 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 
-#include "../../util/debug.h"
 #include "../helpline.h"
 #include "../ui.h"
 #include "../libslang.h"
tools/perf/ui/tui/util.c +0 -1
index 087d9ab054c8..b98dd0e31dc1 100644
@@ -5,7 +5,6 @@
 #include <stdlib.h>
 #include <sys/ttydefaults.h>
 
-#include "../../util/debug.h"
 #include "../browser.h"
 #include "../keysyms.h"
 #include "../helpline.h"
tools/perf/util/branch.c +0 -1
index 9d1e090084a2..52261e5f718a 100644
@@ -1,5 +1,4 @@
 #include "util/util.h"
-#include "util/debug.h"
 #include "util/map_symbol.h"
 #include "util/branch.h"
 #include <linux/kernel.h>
tools/perf/util/demangle-java.c +0 -1
index 763328c151e9..6fb7f34c0814 100644
@@ -3,7 +3,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "debug.h"
 #include "symbol.h"
 
 #include "demangle-java.h"
tools/perf/util/libunwind/arm64.c +0 -1
index 66756e6be111..6b4e5a0892f8 100644
@@ -22,7 +22,6 @@
 #define LIBUNWIND__ARCH_REG_SP PERF_REG_ARM64_SP
 
 #include "unwind.h"
-#include "debug.h"
 #include "libunwind-aarch64.h"
 #include <../../../../arch/arm64/include/uapi/asm/perf_regs.h>
 #include "../../arch/arm64/util/unwind-libunwind.c"
tools/perf/util/libunwind/x86_32.c +0 -1
index c5e568188e19..21c216c40a3b 100644
@@ -22,7 +22,6 @@
 #define LIBUNWIND__ARCH_REG_SP PERF_REG_X86_SP
 
 #include "unwind.h"
-#include "debug.h"
 #include "libunwind-x86.h"
 #include <../../../../arch/x86/include/uapi/asm/perf_regs.h>
 
tools/perf/util/target.c +0 -1
index 565f7aef7e6c..e152d2bbe3a3 100644
@@ -7,7 +7,6 @@
 
 #include "target.h"
 #include "util.h"
-#include "debug.h"
 
 #include <pwd.h>
 #include <stdio.h>
tools/perf/util/usage.c +0 -1
index 3949a60b00ae..196438ee4c9d 100644
@@ -8,7 +8,6 @@
  * Copyright (C) Linus Torvalds, 2005
  */
 #include "util.h"
-#include "debug.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <linux/compiler.h>
tools/perf/util/zlib.c +0 -2
index 59d456f716e9..deb6e69adb5a 100644
@@ -10,8 +10,6 @@
 
 #include "util/compress.h"
 #include "util/util.h"
-#include "util/debug.h"
-
 
 #define CHUNK_SIZE  16384
 
Signature · 1 line
2.21.0
author maintainer
#10 lore raw

PATCH 10/31 perf tools: Remove util.h from where it is not needed

In reply to Arnaldo Carvalho de Melo

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

Check that it is not needed and remove, fixing up some fallout for places where it was only serving to get something else.

---
 tools/perf/arch/arm/util/cs-etm.c                      | 2 +-
 tools/perf/arch/arm64/util/arm-spe.c                   | 2 +-
 tools/perf/arch/arm64/util/dwarf-regs.c                | 1 -
 tools/perf/arch/powerpc/util/dwarf-regs.c              | 1 -
 tools/perf/arch/powerpc/util/header.c                  | 1 -
 tools/perf/arch/s390/util/machine.c                    | 2 +-
 tools/perf/arch/x86/tests/intel-cqm.c                  | 1 -
 tools/perf/arch/x86/tests/rdpmc.c                      | 2 +-
 tools/perf/arch/x86/util/intel-bts.c                   | 2 +-
 tools/perf/arch/x86/util/intel-pt.c                    | 2 +-
 tools/perf/arch/x86/util/machine.c                     | 2 +-
 tools/perf/bench/sched-messaging.c                     | 1 -
 tools/perf/bench/sched-pipe.c                          | 1 -
 tools/perf/builtin-config.c                            | 1 -
 tools/perf/builtin-evlist.c                            | 2 --
 tools/perf/builtin-report.c                            | 2 +-
 tools/perf/perf.c                                      | 2 +-
 tools/perf/tests/clang.c                               | 1 -
 tools/perf/tests/dso-data.c                            | 1 -
 tools/perf/tests/event-times.c                         | 1 -
 tools/perf/tests/llvm.c                                | 1 -
 tools/perf/tests/mmap-thread-lookup.c                  | 2 +-
 tools/perf/tests/parse-events.c                        | 1 -
 tools/perf/tests/parse-no-sample-id-all.c              | 2 --
 tools/perf/tests/perf-hooks.c                          | 1 -
 tools/perf/tests/pmu.c                                 | 1 -
 tools/perf/tests/sample-parsing.c                      | 1 -
 tools/perf/tests/topology.c                            | 1 -
 tools/perf/tests/vmlinux-kallsyms.c                    | 2 +-
 tools/perf/ui/browser.c                                | 1 -
 tools/perf/ui/browsers/annotate.c                      | 1 -
 tools/perf/ui/browsers/map.c                           | 1 -
 tools/perf/ui/browsers/res_sample.c                    | 2 +-
 tools/perf/ui/browsers/scripts.c                       | 2 +-
 tools/perf/ui/gtk/progress.c                           | 1 -
 tools/perf/ui/helpline.c                               | 1 -
 tools/perf/ui/hist.c                                   | 1 -
 tools/perf/ui/setup.c                                  | 2 +-
 tools/perf/ui/tui/setup.c                              | 2 +-
 tools/perf/util/annotate.c                             | 2 +-
 tools/perf/util/auxtrace.c                             | 4 +++-
 tools/perf/util/branch.c                               | 1 -
 tools/perf/util/branch.h                               | 9 ++++++++-
 tools/perf/util/build-id.c                             | 2 +-
 tools/perf/util/cloexec.c                              | 2 +-
 tools/perf/util/cs-etm-decoder/cs-etm-decoder.c        | 1 -
 tools/perf/util/cs-etm.c                               | 1 -
 tools/perf/util/data.c                                 | 3 ++-
 tools/perf/util/debug.c                                | 1 -
 tools/perf/util/demangle-rust.c                        | 1 -
 tools/perf/util/dwarf-regs.c                           | 1 -
 tools/perf/util/evlist.c                               | 2 +-
 tools/perf/util/evsel.c                                | 1 +
 tools/perf/util/header.c                               | 3 ++-
 tools/perf/util/jitdump.c                              | 1 -
 tools/perf/util/llvm-utils.c                           | 1 +
 tools/perf/util/lzma.c                                 | 2 +-
 tools/perf/util/perf-hooks.c                           | 1 -
 tools/perf/util/record.c                               | 1 -
 tools/perf/util/rwsem.c                                | 1 +
 tools/perf/util/s390-sample-raw.c                      | 1 -
 tools/perf/util/scripting-engines/trace-event-python.c | 1 -
 tools/perf/util/session.c                              | 1 +
 tools/perf/util/srccode.c                              | 2 +-
 tools/perf/util/symbol-elf.c                           | 2 ++
 tools/perf/util/symbol-minimal.c                       | 3 +--
 tools/perf/util/symbol.c                               | 2 +-
 tools/perf/util/target.c                               | 1 -
 tools/perf/util/trace-event-info.c                     | 2 +-
 tools/perf/util/trace-event-read.c                     | 1 -
 tools/perf/util/trace-event.c                          | 1 -
 tools/perf/util/unwind-libdw.c                         | 1 -
 tools/perf/util/unwind-libunwind-local.c               | 1 -
 tools/perf/util/vdso.c                                 | 2 +-
 tools/perf/util/zlib.c                                 | 2 +-
 75 files changed, 47 insertions(+), 73 deletions(-)
tools/perf/arch/arm/util/cs-etm.c +1 -1
index c32db09baf0d..5d120b1e35ed 100644
@@ -25,7 +25,7 @@
 #include "../../util/evsel.h"
 #include "../../util/pmu.h"
 #include "../../util/cs-etm.h"
-#include "../../util/util.h"
+#include "../../util/util.h" // page_size
 #include "../../util/session.h"
 
 #include <errno.h>
tools/perf/arch/arm64/util/arm-spe.c +1 -1
index 4b364692da67..eebbf31f995c 100644
@@ -16,7 +16,7 @@
 #include "../../util/evsel.h"
 #include "../../util/evlist.h"
 #include "../../util/session.h"
-#include "../../util/util.h"
+#include "../../util/util.h" // page_size
 #include "../../util/pmu.h"
 #include "../../util/debug.h"
 #include "../../util/auxtrace.h"
tools/perf/arch/arm64/util/dwarf-regs.c +0 -1
index b047b882c5b1..917b97d7c5d3 100644
@@ -11,7 +11,6 @@
 #include <dwarf-regs.h>
 #include <linux/ptrace.h> /* for struct user_pt_regs */
 #include <linux/stringify.h>
-#include "util.h"
 
 struct pt_regs_dwarfnum {
 	const char *name;
tools/perf/arch/powerpc/util/dwarf-regs.c +0 -1
index 4952890b9428..0c4f4caf53ac 100644
@@ -12,7 +12,6 @@
 #include <linux/ptrace.h>
 #include <linux/kernel.h>
 #include <linux/stringify.h>
-#include "util.h"
 
 struct pt_regs_dwarfnum {
 	const char *name;
tools/perf/arch/powerpc/util/header.c +0 -1
index 0b242664f5ea..b6b7bc7e31a1 100644
@@ -6,7 +6,6 @@
 #include <string.h>
 #include <linux/stringify.h>
 #include "header.h"
-#include "util.h"
 
 #define mfspr(rn)       ({unsigned long rval; \
 			 asm volatile("mfspr %0," __stringify(rn) \
tools/perf/arch/s390/util/machine.c +1 -1
index c8c86a0c9b79..df099d6cc3f5 100644
@@ -2,7 +2,7 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <string.h>
-#include "util.h"
+#include "util.h" // page_size
 #include "machine.h"
 #include "api/fs/fs.h"
 #include "debug.h"
tools/perf/arch/x86/tests/intel-cqm.c +0 -1
index 3b5cc3373821..111c0ab2e7b5 100644
@@ -5,7 +5,6 @@
 #include "evlist.h"
 #include "evsel.h"
 #include "arch-tests.h"
-#include "util.h"
 
 #include <signal.h>
 #include <sys/mman.h>
tools/perf/arch/x86/tests/rdpmc.c +1 -1
index 6e67cee792b1..e7640fb047de 100644
@@ -13,7 +13,7 @@
 #include "tests/tests.h"
 #include "cloexec.h"
 #include "event.h"
-#include "util.h"
+#include "util.h" // page_size
 #include "arch-tests.h"
 
 static u64 rdpmc(unsigned int counter)
tools/perf/arch/x86/util/intel-bts.c +1 -1
index d263430c045f..090d90e093df 100644
@@ -22,7 +22,7 @@
 #include "../../util/tsc.h"
 #include "../../util/auxtrace.h"
 #include "../../util/intel-bts.h"
-#include "../../util/util.h"
+#include "../../util/util.h" // page_size
 
 #define KiB(x) ((x) * 1024)
 #define MiB(x) ((x) * 1024 * 1024)
tools/perf/arch/x86/util/intel-pt.c +1 -1
index cb7cf16af79c..3d041b89f018 100644
@@ -26,7 +26,7 @@
 #include "../../util/record.h"
 #include "../../util/target.h"
 #include "../../util/tsc.h"
-#include "../../util/util.h"
+#include "../../util/util.h" // page_size
 #include "../../util/intel-pt.h"
 
 #define KiB(x) ((x) * 1024)
tools/perf/arch/x86/util/machine.c +1 -1
index 1e9ec783b9a1..42418040bc07 100644
@@ -3,7 +3,7 @@
 #include <linux/string.h>
 #include <stdlib.h>
 
-#include "../../util/util.h"
+#include "../../util/util.h" // page_size
 #include "../../util/machine.h"
 #include "../../util/map.h"
 #include "../../util/symbol.h"
tools/perf/bench/sched-messaging.c +0 -1
index 6e499b32bf00..97e4a4fb3362 100644
@@ -10,7 +10,6 @@
  *
  */
 
-#include "../util/util.h"
 #include <subcmd/parse-options.h>
 #include "bench.h"
 
tools/perf/bench/sched-pipe.c +0 -1
index edd40aafa318..3c88d1f201f1 100644
@@ -9,7 +9,6 @@
  *  http://people.redhat.com/mingo/cfs-scheduler/tools/pipe-test-1m.c
  * Ported to perf by Hitoshi Mitake <[email protected]>
  */
-#include "../util/util.h"
 #include <subcmd/parse-options.h>
 #include "bench.h"
 
tools/perf/builtin-config.c +0 -1
index 42d8157e047a..2603015f98be 100644
@@ -9,7 +9,6 @@
 
 #include "util/cache.h"
 #include <subcmd/parse-options.h>
-#include "util/util.h"
 #include "util/debug.h"
 #include "util/config.h"
 #include <linux/string.h>
tools/perf/builtin-evlist.c +0 -2
index 238fa3876805..294494e60e48 100644
@@ -5,8 +5,6 @@
  */
 #include "builtin.h"
 
-#include "util/util.h"
-
 #include <linux/list.h>
 
 #include "perf.h"
tools/perf/builtin-report.c +1 -1
index b18fab94d38d..3047e5169d9d 100644
@@ -48,7 +48,7 @@
 #include "util/auxtrace.h"
 #include "util/units.h"
 #include "util/branch.h"
-#include "util/util.h"
+#include "util/util.h" // perf_tip()
 #include "ui/ui.h"
 #include "ui/progress.h"
 
tools/perf/perf.c +1 -1
index 1193b923e801..bb40a108b8f7 100644
@@ -20,7 +20,7 @@
 #include "util/bpf-loader.h"
 #include "util/debug.h"
 #include "util/event.h"
-#include "util/util.h"
+#include "util/util.h" // page_size, usage()
 #include "ui/ui.h"
 #include "perf-sys.h"
 #include <api/fs/fs.h>
tools/perf/tests/clang.c +0 -1
index ff2711a40940..2577d3ed1531 100644
@@ -1,6 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "tests.h"
-#include "util.h"
 #include "c++/clang-c.h"
 #include <linux/kernel.h>
 
tools/perf/tests/dso-data.c +0 -1
index a4874d4ce7ef..627c1aaf1c9e 100644
@@ -10,7 +10,6 @@
 #include <sys/resource.h>
 #include <api/fs/fs.h>
 #include "dso.h"
-#include "util.h"
 #include "machine.h"
 #include "symbol.h"
 #include "tests.h"
tools/perf/tests/event-times.c +0 -1
index d824a726906c..0228ba435a2a 100644
@@ -9,7 +9,6 @@
 #include "tests.h"
 #include "evlist.h"
 #include "evsel.h"
-#include "util.h"
 #include "debug.h"
 #include "parse-events.h"
 #include "thread_map.h"
tools/perf/tests/llvm.c +0 -1
index 022e4c9cf092..ae6cda81c209 100644
@@ -7,7 +7,6 @@
 #include "llvm.h"
 #include "tests.h"
 #include "debug.h"
-#include "util.h"
 
 #ifdef HAVE_LIBBPF_SUPPORT
 static int test__bpf_parsing(void *obj_buf, size_t obj_buf_sz)
tools/perf/tests/mmap-thread-lookup.c +1 -1
index 360d70deb855..f72889c13538 100644
@@ -14,7 +14,7 @@
 #include "map.h"
 #include "symbol.h"
 #include "thread.h"
-#include "util.h"
+#include "util.h" // page_size
 
 #define THREADS 4
 
tools/perf/tests/parse-events.c +0 -1
index 02ba696fb87f..c25c8e7b41e5 100644
@@ -6,7 +6,6 @@
 #include "tests.h"
 #include "debug.h"
 #include "pmu.h"
-#include "util.h"
 #include <dirent.h>
 #include <errno.h>
 #include <sys/types.h>
tools/perf/tests/parse-no-sample-id-all.c +0 -2
index 8284752a60c8..adf3c9c4a416 100644
@@ -1,4 +1,3 @@
-// SPDX-License-Identifier: GPL-2.0
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <stddef.h>
@@ -8,7 +7,6 @@
 #include "event.h"
 #include "evlist.h"
 #include "header.h"
-#include "util.h"
 #include "debug.h"
 
 static int process_event(struct evlist **pevlist, union perf_event *event)
tools/perf/tests/perf-hooks.c +0 -1
index a693bcf017ea..dbc27199c65e 100644
@@ -4,7 +4,6 @@
 
 #include "tests.h"
 #include "debug.h"
-#include "util.h"
 #include "perf-hooks.h"
 
 static void sigsegv_handler(int sig __maybe_unused)
tools/perf/tests/pmu.c +0 -1
index 14a78898d79e..74379ff1f7fa 100644
@@ -1,7 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "parse-events.h"
 #include "pmu.h"
-#include "util.h"
 #include "tests.h"
 #include <errno.h>
 #include <stdio.h>
tools/perf/tests/sample-parsing.c +0 -1
index 5fcc06817076..e3b965e7a233 100644
@@ -9,7 +9,6 @@
 
 #include "map_symbol.h"
 #include "branch.h"
-#include "util.h"
 #include "event.h"
 #include "evsel.h"
 #include "debug.h"
tools/perf/tests/topology.c +0 -1
index a4f9f5182b47..c963f301d15e 100644
@@ -4,7 +4,6 @@
 #include <stdio.h>
 #include <perf/cpumap.h>
 #include "tests.h"
-#include "util.h"
 #include "session.h"
 #include "evlist.h"
 #include "debug.h"
tools/perf/tests/vmlinux-kallsyms.c +1 -1
index 01f434c067c6..7f28775875c2 100644
@@ -7,7 +7,7 @@
 #include "dso.h"
 #include "map.h"
 #include "symbol.h"
-#include "util.h"
+#include "util.h" // page_size
 #include "tests.h"
 #include "debug.h"
 #include "machine.h"
tools/perf/ui/browser.c +0 -1
index f93d40b1c203..781afe42e90e 100644
@@ -1,5 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#include "../util/util.h"
 #include "../util/string2.h"
 #include "../util/config.h"
 #include "libslang.h"
tools/perf/ui/browsers/annotate.c +0 -1
index ac74ed2c23a0..82207db8f97c 100644
@@ -2,7 +2,6 @@
 #include "../browser.h"
 #include "../helpline.h"
 #include "../ui.h"
-#include "../util.h"
 #include "../../util/annotate.h"
 #include "../../util/debug.h"
 #include "../../util/dso.h"
tools/perf/ui/browsers/map.c +0 -1
index 893b065971f6..3d49b916c9e4 100644
@@ -5,7 +5,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <linux/bitops.h>
-#include "../../util/util.h"
 #include "../../util/debug.h"
 #include "../../util/map.h"
 #include "../../util/dso.h"
tools/perf/ui/browsers/res_sample.c +1 -1
index f16a38fea45e..76d356a18790 100644
@@ -7,7 +7,7 @@
 #include "config.h"
 #include "time-utils.h"
 #include "../util.h"
-#include "../../util/util.h"
+#include "../../util/util.h" // perf_exe()
 #include "../../perf.h"
 #include <stdlib.h>
 #include <string.h>
tools/perf/ui/browsers/scripts.c +1 -1
index 3b81075b8da8..fc733a6354d4 100644
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "../../builtin.h"
 #include "../../perf.h"
-#include "../../util/util.h"
+#include "../../util/util.h" // perf_exe()
 #include "../util.h"
 #include "../../util/hist.h"
 #include "../../util/debug.h"
tools/perf/ui/gtk/progress.c +0 -1
index b6ad8857da78..eea6fcde518a 100644
@@ -3,7 +3,6 @@
 
 #include "gtk.h"
 #include "../progress.h"
-#include "util.h"
 
 static GtkWidget *dialog;
 static GtkWidget *progress;
tools/perf/ui/helpline.c +0 -1
index e00901450f91..911182b3f5e6 100644
@@ -5,7 +5,6 @@
 
 #include "helpline.h"
 #include "ui.h"
-#include "../util/util.h"
 
 char ui_helpline__current[512];
 
tools/perf/ui/hist.c +0 -1
index 3e533de7d852..f73675500061 100644
@@ -8,7 +8,6 @@
 #include "../util/callchain.h"
 #include "../util/debug.h"
 #include "../util/hist.h"
-#include "../util/util.h"
 #include "../util/sort.h"
 #include "../util/evsel.h"
 #include "../util/evlist.h"
tools/perf/ui/setup.c +1 -1
index c7a86b4be9f5..700335cde618 100644
@@ -1,11 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <pthread.h>
 #include <dlfcn.h>
+#include <unistd.h>
 
 #include <subcmd/pager.h>
 #include "../util/debug.h"
 #include "../util/hist.h"
-#include "../util/util.h"
 #include "ui.h"
 
 pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
tools/perf/ui/tui/setup.c +1 -1
index 56651a4f5aa0..e9bfe856a5de 100644
@@ -2,13 +2,13 @@
 #include <signal.h>
 #include <stdbool.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <linux/kernel.h>
 #ifdef HAVE_BACKTRACE_SUPPORT
 #include <execinfo.h>
 #endif
 
 #include "../../util/debug.h"
-#include "../../util/util.h"
 #include "../../perf.h"
 #include "../browser.h"
 #include "../helpline.h"
tools/perf/util/annotate.c +1 -1
index 1748f528b6e9..d441cca6a517 100644
@@ -14,7 +14,7 @@
 #include <bpf/btf.h>
 #include <bpf/libbpf.h>
 #include <linux/btf.h>
-#include "util.h"
+#include "util.h" // hex_width()
 #include "ui/ui.h"
 #include "sort.h"
 #include "build-id.h"
tools/perf/util/auxtrace.c +3 -1
index 6f25224a3def..7ec0a6caa6cd 100644
@@ -50,10 +50,12 @@
 #include "intel-bts.h"
 #include "arm-spe.h"
 #include "s390-cpumsf.h"
-#include "util.h"
+#include "util.h" // page_size
 
 #include <linux/ctype.h>
+#include <linux/kernel.h>
 #include "symbol/kallsyms.h"
+#include <internal/lib.h>
 
 static bool auxtrace__dont_decode(struct perf_session *session)
 {
tools/perf/util/branch.c +0 -1
index 52261e5f718a..2285b1eb3128 100644
@@ -1,4 +1,3 @@
-#include "util/util.h"
 #include "util/map_symbol.h"
 #include "util/branch.h"
 #include <linux/kernel.h>
tools/perf/util/branch.h +8 -1
index 06f66dad0b79..88e00d268f6f 100644
@@ -1,8 +1,15 @@
 #ifndef _PERF_BRANCH_H
 #define _PERF_BRANCH_H 1
-
+/*
+ * The linux/stddef.h isn't need here, but is needed for __always_inline used
+ * in files included from uapi/linux/perf_event.h such as
+ * /usr/include/linux/swab.h and /usr/include/linux/byteorder/little_endian.h,
+ * detected in at least musl libc, used in Alpine Linux. -acme
+ */
 #include <stdio.h>
 #include <stdint.h>
+#include <linux/compiler.h>
+#include <linux/stddef.h>
 #include <linux/perf_event.h>
 #include <linux/types.h>
 
tools/perf/util/build-id.c +1 -1
index e5fb77755d9e..7928c398a063 100644
@@ -7,7 +7,7 @@
  * Copyright (C) 2009, 2010 Red Hat Inc.
  * Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo <[email protected]>
  */
-#include "util.h"
+#include "util.h" // copyfile_ns(), lsdir(), mkdir_p(), rm_rf()
 #include <dirent.h>
 #include <errno.h>
 #include <stdio.h>
tools/perf/util/cloexec.c +1 -1
index 4e904fcb2783..a12872f2856a 100644
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <errno.h>
 #include <sched.h>
-#include "util.h"
+#include "util.h" // for sched_getcpu()
 #include "../perf-sys.h"
 #include "cloexec.h"
 #include "event.h"
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +0 -1
index 37d7c492b155..cd92a99eb89d 100644
@@ -17,7 +17,6 @@
 #include "cs-etm.h"
 #include "cs-etm-decoder.h"
 #include "intlist.h"
-#include "util.h"
 
 /* use raw logging */
 #ifdef CS_DEBUG_RAW
tools/perf/util/cs-etm.c +0 -1
index 707afdbd9529..f87b9c1c9f9a 100644
@@ -35,7 +35,6 @@
 #include "thread.h"
 #include "thread-stack.h"
 #include <tools/libc_compat.h>
-#include "util.h"
 
 #define MAX_TIMESTAMP (~0ULL)
 
tools/perf/util/data.c +2 -1
index e75c3a279fe8..88fba2ba549f 100644
@@ -13,9 +13,10 @@
 #include <dirent.h>
 
 #include "data.h"
-#include "util.h"
+#include "util.h" // rm_rf_perf_data()
 #include "debug.h"
 #include "header.h"
+#include <internal/lib.h>
 
 static void close_dir(struct perf_data_file *files, int nr)
 {
tools/perf/util/debug.c +0 -1
index a1b59bd35519..e55114f0336f 100644
@@ -17,7 +17,6 @@
 #include "event.h"
 #include "debug.h"
 #include "print_binary.h"
-#include "util.h"
 #include "target.h"
 #include "ui/helpline.h"
 #include "ui/ui.h"
tools/perf/util/demangle-rust.c +0 -1
index 423afbbd386b..a659fc69f73a 100644
@@ -1,6 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <string.h>
-#include "util.h"
 #include "debug.h"
 
 #include "demangle-rust.h"
tools/perf/util/dwarf-regs.c +0 -1
index db55eddce8cd..1b49ecee5aff 100644
@@ -5,7 +5,6 @@
  * Written by: Masami Hiramatsu <[email protected]>
  */
 
-#include <util.h>
 #include <debug.h>
 #include <dwarf-regs.h>
 #include <elf.h>
tools/perf/util/evlist.c +1 -1
index 095924aa186b..ea9517d506d8 100644
@@ -16,7 +16,7 @@
 #include "evsel.h"
 #include "debug.h"
 #include "units.h"
-#include "util.h"
+#include "util.h" // page_size
 #include "../perf.h"
 #include "asm/bug.h"
 #include "bpf-event.h"
tools/perf/util/evsel.c +1 -0
index 85825384f9e8..c194ec787f96 100644
@@ -45,6 +45,7 @@
 #include "../perf-sys.h"
 #include "util/parse-branch-options.h"
 #include <internal/xyarray.h>
+#include <internal/lib.h>
 
 #include <linux/ctype.h>
 
tools/perf/util/header.c +2 -1
index b0c34dda30a0..d85827de1b60 100644
@@ -42,11 +42,12 @@
 #include "tool.h"
 #include "time-utils.h"
 #include "units.h"
-#include "util.h"
+#include "util.h" // page_size, perf_exe()
 #include "cputopo.h"
 #include "bpf-event.h"
 
 #include <linux/ctype.h>
+#include <internal/lib.h>
 
 /*
  * magic2 = "PERFILE2"
tools/perf/util/jitdump.c +0 -1
index 00db9957fdb0..9f9c6c6a2fd3 100644
@@ -15,7 +15,6 @@
 #include <linux/stringify.h>
 
 #include "build-id.h"
-#include "util.h"
 #include "event.h"
 #include "debug.h"
 #include "evlist.h"
tools/perf/util/llvm-utils.c +1 -0
index 55fb4b3b1157..8d04e3d070b1 100644
@@ -8,6 +8,7 @@
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <linux/err.h>
 #include <linux/string.h>
 #include <linux/zalloc.h>
tools/perf/util/lzma.c +1 -1
index 397447066033..39062df02629 100644
@@ -7,10 +7,10 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include "compress.h"
-#include "util.h"
 #include "debug.h"
 #include <string.h>
 #include <unistd.h>
+#include <internal/lib.h>
 
 #define BUFSIZE 8192
 
tools/perf/util/perf-hooks.c +0 -1
index e635c594f773..7a0ab3507bd5 100644
@@ -12,7 +12,6 @@
 #include <setjmp.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
-#include "util/util.h"
 #include "util/debug.h"
 #include "util/perf-hooks.h"
 
tools/perf/util/record.c +0 -1
index 286fe816c0f3..860c48895ab6 100644
@@ -10,7 +10,6 @@
 #include <api/fs/fs.h>
 #include <subcmd/parse-options.h>
 #include <perf/cpumap.h>
-#include "util.h"
 #include "cloexec.h"
 #include "record.h"
 #include "../perf-sys.h"
tools/perf/util/rwsem.c +1 -0
index 5e52e7baa7b6..f3d29d8ddc99 100644
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 #include "util.h"
 #include "rwsem.h"
 
tools/perf/util/s390-sample-raw.c +0 -1
index 4d9593e331ea..05b43ab4eeef 100644
@@ -22,7 +22,6 @@
 #include <asm/byteorder.h>
 
 #include "debug.h"
-#include "util.h"
 #include "session.h"
 #include "evlist.h"
 #include "color.h"
tools/perf/util/scripting-engines/trace-event-python.c +0 -1
index 666a56e88d8e..bb6828532741 100644
@@ -37,7 +37,6 @@
 #include "../dso.h"
 #include "../callchain.h"
 #include "../evsel.h"
-#include "../util.h"
 #include "../event.h"
 #include "../thread.h"
 #include "../comm.h"
tools/perf/util/session.c +1 -0
index e9e4a04f15db..2b133bc22caa 100644
@@ -34,6 +34,7 @@
 #include "ui/progress.h"
 #include "../perf.h"
 #include "arch/common.h"
+#include <internal/lib.h>
 
 #ifdef HAVE_ZSTD_SUPPORT
 static int perf_session__process_compressed_event(struct perf_session *session,
tools/perf/util/srccode.c +1 -1
index adfcf1ff464c..b402f9ca89ab 100644
@@ -15,7 +15,7 @@
 #include <string.h>
 #include "srccode.h"
 #include "debug.h"
-#include "util.h"
+#include "util.h" // page_size
 
 #define MAXSRCCACHE (32*1024*1024)
 #define MAXSRCFILES     64
tools/perf/util/symbol-elf.c +2 -0
index 9428639872a6..8b9199c343dd 100644
@@ -18,8 +18,10 @@
 #include "debug.h"
 #include "util.h"
 #include <linux/ctype.h>
+#include <linux/kernel.h>
 #include <linux/zalloc.h>
 #include <symbol/kallsyms.h>
+#include <internal/lib.h>
 
 #ifndef EM_AARCH64
 #define EM_AARCH64	183  /* ARM 64 bit */
tools/perf/util/symbol-minimal.c +1 -2
index 7e2813ec9498..d6e99af263ec 100644
@@ -1,8 +1,6 @@
-// SPDX-License-Identifier: GPL-2.0
 #include "dso.h"
 #include "symbol.h"
 #include "symsrc.h"
-#include "util.h"
 
 #include <errno.h>
 #include <unistd.h>
@@ -13,6 +11,7 @@
 #include <byteswap.h>
 #include <sys/stat.h>
 #include <linux/zalloc.h>
+#include <internal/lib.h>
 
 static bool check_need_swap(int file_endian)
 {
tools/perf/util/symbol.c +1 -1
index 765c75df2904..a8f80e427674 100644
@@ -19,7 +19,7 @@
 #include "build-id.h"
 #include "cap.h"
 #include "dso.h"
-#include "util.h"
+#include "util.h" // lsdir()
 #include "debug.h"
 #include "event.h"
 #include "machine.h"
tools/perf/util/target.c +0 -1
index e152d2bbe3a3..a3db13dea937 100644
@@ -6,7 +6,6 @@
  */
 
 #include "target.h"
-#include "util.h"
 
 #include <pwd.h>
 #include <stdio.h>
tools/perf/util/trace-event-info.c +1 -1
index d63d542b2cde..fe07e7550930 100644
@@ -2,7 +2,7 @@
 /*
  * Copyright (C) 2008,2009, Steven Rostedt <[email protected]>
  */
-#include "util.h"
+#include "util.h" // page_size
 #include <dirent.h>
 #include <mntent.h>
 #include <stdio.h>
tools/perf/util/trace-event-read.c +0 -1
index b6c0db068be0..8593d3c200c6 100644
@@ -15,7 +15,6 @@
 #include <unistd.h>
 #include <errno.h>
 
-#include "util.h"
 #include "trace-event.h"
 #include "debug.h"
 
tools/perf/util/trace-event.c +0 -1
index 01b9d89bf5bf..b3ee651e3d91 100644
@@ -14,7 +14,6 @@
 #include <api/fs/fs.h>
 #include "trace-event.h"
 #include "machine.h"
-#include "util.h"
 
 /*
  * global trace_event object used by trace_event__tp_format
tools/perf/util/unwind-libdw.c +0 -1
index 9ece188ae48a..15f6e46d7124 100644
@@ -17,7 +17,6 @@
 #include "event.h"
 #include "perf_regs.h"
 #include "callchain.h"
-#include "util.h"
 
 static char *debuginfo_path;
 
tools/perf/util/unwind-libunwind-local.c +0 -1
index ebdbb056510c..1800887b2255 100644
@@ -37,7 +37,6 @@
 #include "unwind.h"
 #include "map.h"
 #include "symbol.h"
-#include "util.h"
 #include "debug.h"
 #include "asm/bug.h"
 #include "dso.h"
tools/perf/util/vdso.c +1 -1
index e5e6599603f4..ba4b4395f35d 100644
@@ -11,7 +11,7 @@
 
 #include "vdso.h"
 #include "dso.h"
-#include "util.h"
+#include <internal/lib.h>
 #include "map.h"
 #include "symbol.h"
 #include "machine.h"
tools/perf/util/zlib.c +1 -1
index deb6e69adb5a..78d2297c1b67 100644
@@ -7,9 +7,9 @@
 #include <sys/mman.h>
 #include <zlib.h>
 #include <linux/compiler.h>
+#include <internal/lib.h>
 
 #include "util/compress.h"
-#include "util/util.h"
 
 #define CHUNK_SIZE  16384
 
Signature · 1 line
2.21.0
author maintainer
#11 lore raw

PATCH 11/31 perf probe: Add missing build-id.h header.

In reply to Arnaldo Carvalho de Melo

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

It uses things defined in that header and was getting it only indirectly, thru dso.h, fix it.

---
 tools/perf/util/probe-file.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/util/probe-file.c +1 -0
index d13db55a2feb..b659466ea498 100644
@@ -16,6 +16,7 @@
 #include "strlist.h"
 #include "strfilter.h"
 #include "debug.h"
+#include "build-id.h"
 #include "dso.h"
 #include "color.h"
 #include "symbol.h"
Signature · 1 line
2.21.0
author maintainer
#12 lore raw

PATCH 12/31 perf symbols: Add missing dso.h header

In reply to Arnaldo Carvalho de Melo

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

This was being obtained only indirectly, by luck.

---
 tools/perf/util/symbol-elf.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/util/symbol-elf.c +1 -0
index 8b9199c343dd..6fbfdf8bf61f 100644
@@ -7,6 +7,7 @@
 #include <unistd.h>
 #include <inttypes.h>
 
+#include "dso.h"
 #include "map.h"
 #include "map_groups.h"
 #include "symbol.h"
Signature · 1 line
2.21.0
author maintainer
#13 lore raw

PATCH 13/31 perf env: Remove needless cpumap.h header

In reply to Arnaldo Carvalho de Melo

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

Only a 'struct perf_cmp_map' forward allocation is necessary, fix the places that need the header but were getting it indirectly, by luck, from env.h.

---
 tools/perf/arch/arm64/util/header.c                    | 4 +++-
 tools/perf/arch/x86/tests/perf-time-to-tsc.c           | 1 -
 tools/perf/bench/epoll-ctl.c                           | 2 +-
 tools/perf/bench/epoll-wait.c                          | 2 +-
 tools/perf/bench/futex-hash.c                          | 2 +-
 tools/perf/bench/futex-lock-pi.c                       | 2 +-
 tools/perf/bench/futex-requeue.c                       | 2 +-
 tools/perf/bench/futex-wake-parallel.c                 | 3 ++-
 tools/perf/bench/futex-wake.c                          | 2 +-
 tools/perf/builtin-c2c.c                               | 1 +
 tools/perf/builtin-sched.c                             | 2 ++
 tools/perf/tests/bitmap.c                              | 2 +-
 tools/perf/tests/code-reading.c                        | 1 -
 tools/perf/tests/event_update.c                        | 1 +
 tools/perf/tests/keep-tracking.c                       | 3 +--
 tools/perf/tests/mem2node.c                            | 2 +-
 tools/perf/tests/mmap-basic.c                          | 3 +--
 tools/perf/tests/openat-syscall-all-cpus.c             | 5 +++--
 tools/perf/tests/switch-tracking.c                     | 1 -
 tools/perf/tests/task-exit.c                           | 2 +-
 tools/perf/tests/topology.c                            | 1 +
 tools/perf/util/arm-spe.c                              | 1 -
 tools/perf/util/auxtrace.c                             | 1 -
 tools/perf/util/env.h                                  | 3 ++-
 tools/perf/util/event.c                                | 2 ++
 tools/perf/util/evsel.c                                | 2 +-
 tools/perf/util/intel-bts.c                            | 1 -
 tools/perf/util/parse-events.c                         | 1 -
 tools/perf/util/pmu.c                                  | 1 -
 tools/perf/util/python.c                               | 1 -
 tools/perf/util/record.c                               | 1 -
 tools/perf/util/s390-cpumsf.c                          | 1 -
 tools/perf/util/scripting-engines/trace-event-python.c | 1 -
 tools/perf/util/session.c                              | 1 -
 tools/perf/util/stat.c                                 | 1 +
 tools/perf/util/svghelper.c                            | 2 +-
 tools/perf/util/top.c                                  | 1 -
 37 files changed, 31 insertions(+), 34 deletions(-)
tools/perf/arch/arm64/util/header.c +3 -1
index e41defaaa2e6..a32e4b72a98f 100644
@@ -1,5 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <perf/cpumap.h>
+#include <internal/cpumap.h>
 #include <api/fs/fs.h>
 #include "debug.h"
 #include "header.h"
@@ -29,7 +31,7 @@ char *get_cpuid_str(struct perf_pmu *pmu)
 
 	/* read midr from list of cpus mapped to this pmu */
 	cpus = perf_cpu_map__get(pmu->cpus);
-	for (cpu = 0; cpu < cpus->nr; cpu++) {
+	for (cpu = 0; cpu < perf_cpu_map__nr(cpus); cpu++) {
 		scnprintf(path, PATH_MAX, "%s/devices/system/cpu/cpu%d"MIDR,
 				sysfs, cpus->map[cpu]);
 
tools/perf/arch/x86/tests/perf-time-to-tsc.c +0 -1
index eb3635941c2b..0a4570b340fa 100644
@@ -15,7 +15,6 @@
 #include "evlist.h"
 #include "evsel.h"
 #include "thread_map.h"
-#include "cpumap.h"
 #include "record.h"
 #include "tsc.h"
 #include "tests/tests.h"
tools/perf/bench/epoll-ctl.c +1 -1
index d1caa4a0a12a..bb617e568841 100644
@@ -21,12 +21,12 @@
 #include <sys/resource.h>
 #include <sys/epoll.h>
 #include <sys/eventfd.h>
+#include <internal/cpumap.h>
 #include <perf/cpumap.h>
 
 #include "../util/stat.h"
 #include <subcmd/parse-options.h>
 #include "bench.h"
-#include "cpumap.h"
 
 #include <err.h>
 
tools/perf/bench/epoll-wait.c +1 -1
index f6b4472847d2..7af694437f4e 100644
@@ -76,12 +76,12 @@
 #include <sys/epoll.h>
 #include <sys/eventfd.h>
 #include <sys/types.h>
+#include <internal/cpumap.h>
 #include <perf/cpumap.h>
 
 #include "../util/stat.h"
 #include <subcmd/parse-options.h>
 #include "bench.h"
-#include "cpumap.h"
 
 #include <err.h>
 
tools/perf/bench/futex-hash.c +1 -1
index 80e138904c66..8ba0c3330a9a 100644
@@ -20,13 +20,13 @@
 #include <linux/kernel.h>
 #include <linux/zalloc.h>
 #include <sys/time.h>
+#include <internal/cpumap.h>
 #include <perf/cpumap.h>
 
 #include "../util/stat.h"
 #include <subcmd/parse-options.h>
 #include "bench.h"
 #include "futex.h"
-#include "cpumap.h"
 
 #include <err.h>
 
tools/perf/bench/futex-lock-pi.c +1 -1
index c5d6d0abbaa9..d0cae8125423 100644
@@ -14,10 +14,10 @@
 #include <linux/kernel.h>
 #include <linux/zalloc.h>
 #include <errno.h>
+#include <internal/cpumap.h>
 #include <perf/cpumap.h>
 #include "bench.h"
 #include "futex.h"
-#include "cpumap.h"
 
 #include <err.h>
 #include <stdlib.h>
tools/perf/bench/futex-requeue.c +1 -1
index 75d3418c1a88..a00a6891447a 100644
@@ -20,10 +20,10 @@
 #include <linux/kernel.h>
 #include <linux/time64.h>
 #include <errno.h>
+#include <internal/cpumap.h>
 #include <perf/cpumap.h>
 #include "bench.h"
 #include "futex.h"
-#include "cpumap.h"
 
 #include <err.h>
 #include <stdlib.h>
tools/perf/bench/futex-wake-parallel.c +2 -1
index 163fe16c275a..a053cf2b7039 100644
@@ -29,7 +29,8 @@ int bench_futex_wake_parallel(int argc __maybe_unused, const char **argv __maybe
 #include <linux/time64.h>
 #include <errno.h>
 #include "futex.h"
-#include "cpumap.h"
+#include <internal/cpumap.h>
+#include <perf/cpumap.h>
 
 #include <err.h>
 #include <stdlib.h>
tools/perf/bench/futex-wake.c +1 -1
index 77dcdc13618a..df810096abfe 100644
@@ -20,10 +20,10 @@
 #include <linux/kernel.h>
 #include <linux/time64.h>
 #include <errno.h>
+#include <internal/cpumap.h>
 #include <perf/cpumap.h>
 #include "bench.h"
 #include "futex.h"
-#include "cpumap.h"
 
 #include <err.h>
 #include <stdlib.h>
tools/perf/builtin-c2c.c +1 -0
index b09b12e0976b..61aaacc2aedd 100644
@@ -20,6 +20,7 @@
 #include <sys/param.h>
 #include "debug.h"
 #include "builtin.h"
+#include <perf/cpumap.h>
 #include <subcmd/pager.h>
 #include <subcmd/parse-options.h>
 #include "map_symbol.h"
tools/perf/builtin-sched.c +2 -0
index ec96d64aec69..511e19a7aafa 100644
@@ -3,6 +3,7 @@
 #include "perf.h"
 #include "perf-sys.h"
 
+#include "util/cpumap.h"
 #include "util/evlist.h"
 #include "util/evsel.h"
 #include "util/symbol.h"
@@ -36,6 +37,7 @@
 #include <pthread.h>
 #include <math.h>
 #include <api/fs/fs.h>
+#include <perf/cpumap.h>
 #include <linux/time64.h>
 
 #include <linux/ctype.h>
tools/perf/tests/bitmap.c +1 -1
index db2aadff3708..96c137360918 100644
@@ -2,8 +2,8 @@
 #include <linux/compiler.h>
 #include <linux/bitmap.h>
 #include <perf/cpumap.h>
+#include <internal/cpumap.h>
 #include "tests.h"
-#include "cpumap.h"
 #include "debug.h"
 
 #define NBITS 100
tools/perf/tests/code-reading.c +0 -1
index c1c29e08e7fb..8d9020c46ca9 100644
@@ -19,7 +19,6 @@
 #include "evlist.h"
 #include "evsel.h"
 #include "thread_map.h"
-#include "cpumap.h"
 #include "machine.h"
 #include "map.h"
 #include "symbol.h"
tools/perf/tests/event_update.c +1 -0
index cac4290e233a..317eb8c5ccd4 100644
@@ -2,6 +2,7 @@
 #include <linux/compiler.h>
 #include <perf/cpumap.h>
 #include <string.h>
+#include "cpumap.h"
 #include "evlist.h"
 #include "evsel.h"
 #include "header.h"
tools/perf/tests/keep-tracking.c +1 -2
index 9f0762d987fa..df0fd5a44e04 100644
@@ -12,7 +12,6 @@
 #include "evsel.h"
 #include "record.h"
 #include "thread_map.h"
-#include "cpumap.h"
 #include "tests.h"
 
 #define CHECK__(x) {				\
@@ -143,7 +142,7 @@ int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_un
 
 	found = find_comm(evlist, comm);
 	if (found != 1) {
-		pr_debug("Seconf time, failed to find tracking event.\n");
+		pr_debug("Second time, failed to find tracking event.\n");
 		goto out_err;
 	}
 
tools/perf/tests/mem2node.c +1 -1
index 7672ade70f20..a258bd51f1a4 100644
@@ -4,7 +4,7 @@
 #include <linux/kernel.h>
 #include <linux/zalloc.h>
 #include <perf/cpumap.h>
-#include "cpumap.h"
+#include <internal/cpumap.h>
 #include "debug.h"
 #include "env.h"
 #include "mem2node.h"
tools/perf/tests/mmap-basic.c +1 -2
index 85e1d7337dc0..042757629e90 100644
@@ -10,7 +10,6 @@
 #include "evlist.h"
 #include "evsel.h"
 #include "thread_map.h"
-#include "cpumap.h"
 #include "tests.h"
 #include <linux/err.h>
 #include <linux/kernel.h>
@@ -53,7 +52,7 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unuse
 
 	cpus = perf_cpu_map__new(NULL);
 	if (cpus == NULL) {
-		pr_debug("cpu_map__new\n");
+		pr_debug("perf_cpu_map__new\n");
 		goto out_free_threads;
 	}
 
tools/perf/tests/openat-syscall-all-cpus.c +3 -2
index 9171f77cd9cd..93c176523e38 100644
@@ -14,7 +14,8 @@
 #include "evsel.h"
 #include "tests.h"
 #include "thread_map.h"
-#include "cpumap.h"
+#include <perf/cpumap.h>
+#include <internal/cpumap.h>
 #include "debug.h"
 #include "stat.h"
 #include "util/counts.h"
@@ -37,7 +38,7 @@ int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, int
 
 	cpus = perf_cpu_map__new(NULL);
 	if (cpus == NULL) {
-		pr_debug("cpu_map__new\n");
+		pr_debug("perf_cpu_map__new\n");
 		goto out_thread_map_delete;
 	}
 
tools/perf/tests/switch-tracking.c +0 -1
index 1a60fa1219f5..3fb1ff7b8a2f 100644
@@ -14,7 +14,6 @@
 #include "evlist.h"
 #include "evsel.h"
 #include "thread_map.h"
-#include "cpumap.h"
 #include "record.h"
 #include "tests.h"
 
tools/perf/tests/task-exit.c +1 -1
index f610e8c0a083..088c7708b03a 100644
@@ -4,12 +4,12 @@
 #include "evsel.h"
 #include "target.h"
 #include "thread_map.h"
-#include "cpumap.h"
 #include "tests.h"
 
 #include <errno.h>
 #include <signal.h>
 #include <linux/string.h>
+#include <perf/cpumap.h>
 #include <perf/evlist.h>
 
 static int exited;
tools/perf/tests/topology.c +1 -0
index c963f301d15e..7d845d913d7d 100644
@@ -3,6 +3,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <perf/cpumap.h>
+#include "cpumap.h"
 #include "tests.h"
 #include "session.h"
 #include "evlist.h"
tools/perf/util/arm-spe.c +0 -1
index 8a7340f6a2a2..53be12b23ff4 100644
@@ -16,7 +16,6 @@
 #include <linux/log2.h>
 #include <linux/zalloc.h>
 
-#include "cpumap.h"
 #include "color.h"
 #include "evsel.h"
 #include "machine.h"
tools/perf/util/auxtrace.c +0 -1
index 7ec0a6caa6cd..1c0ff5acff83 100644
@@ -31,7 +31,6 @@
 #include "map.h"
 #include "pmu.h"
 #include "evsel.h"
-#include "cpumap.h"
 #include "symbol.h"
 #include "thread_map.h"
 #include "asm/bug.h"
tools/perf/util/env.h +2 -1
index d8e083d42610..db40906e2937 100644
@@ -4,9 +4,10 @@
 
 #include <linux/types.h>
 #include <linux/rbtree.h>
-#include "cpumap.h"
 #include "rwsem.h"
 
+struct perf_cpu_map;
+
 struct cpu_topology_map {
 	int	socket_id;
 	int	die_id;
tools/perf/util/event.c +2 -0
index f4afbb858ebb..d65ae7cf9316 100644
@@ -4,6 +4,7 @@
 #include <inttypes.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
+#include <perf/cpumap.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
@@ -11,6 +12,7 @@
 #include <api/fs/fs.h>
 #include <linux/perf_event.h>
 #include <linux/zalloc.h>
+#include "cpumap.h"
 #include "dso.h"
 #include "event.h"
 #include "debug.h"
tools/perf/util/evsel.c +1 -1
index c194ec787f96..5b40b840624c 100644
@@ -31,7 +31,7 @@
 #include "event.h"
 #include "evsel.h"
 #include "evlist.h"
-#include "cpumap.h"
+#include <perf/cpumap.h>
 #include "thread_map.h"
 #include "target.h"
 #include "perf_regs.h"
tools/perf/util/intel-bts.c +0 -1
index aacffa2b0362..15f87a09f4fe 100644
@@ -14,7 +14,6 @@
 #include <linux/log2.h>
 #include <linux/zalloc.h>
 
-#include "cpumap.h"
 #include "color.h"
 #include "evsel.h"
 #include "evlist.h"
tools/perf/util/parse-events.c +0 -1
index 5ec21d21113c..a33a1d5059a2 100644
@@ -30,7 +30,6 @@
 #include "parse-events-flex.h"
 #include "pmu.h"
 #include "thread_map.h"
-#include "cpumap.h"
 #include "probe-file.h"
 #include "asm/bug.h"
 #include "util/parse-branch-options.h"
tools/perf/util/pmu.c +0 -1
index fb597fa94234..5608da82ad23 100644
@@ -20,7 +20,6 @@
 #include "debug.h"
 #include "pmu.h"
 #include "parse-events.h"
-#include "cpumap.h"
 #include "header.h"
 #include "pmu-events/pmu-events.h"
 #include "string2.h"
tools/perf/util/python.c +0 -1
index 07ca4535e6f7..96dd3333c911 100644
@@ -11,7 +11,6 @@
 #include "callchain.h"
 #include "evsel.h"
 #include "event.h"
-#include "cpumap.h"
 #include "print_binary.h"
 #include "thread_map.h"
 #include "trace-event.h"
tools/perf/util/record.c +0 -1
index 860c48895ab6..8a015fc0aba0 100644
@@ -2,7 +2,6 @@
 #include "debug.h"
 #include "evlist.h"
 #include "evsel.h"
-#include "cpumap.h"
 #include "parse-events.h"
 #include <errno.h>
 #include <limits.h>
tools/perf/util/s390-cpumsf.c +0 -1
index 24a99909d8b3..6785cd87aa4d 100644
@@ -151,7 +151,6 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include "cpumap.h"
 #include "color.h"
 #include "evsel.h"
 #include "evlist.h"
tools/perf/util/scripting-engines/trace-event-python.c +0 -1
index bb6828532741..5d341efc3237 100644
@@ -48,7 +48,6 @@
 #include "map.h"
 #include "symbol.h"
 #include "thread_map.h"
-#include "cpumap.h"
 #include "print_binary.h"
 #include "stat.h"
 #include "mem-events.h"
tools/perf/util/session.c +0 -1
index 2b133bc22caa..2b583e6adb49 100644
@@ -22,7 +22,6 @@
 #include "symbol.h"
 #include "session.h"
 #include "tool.h"
-#include "cpumap.h"
 #include "perf_regs.h"
 #include "asm/bug.h"
 #include "auxtrace.h"
tools/perf/util/stat.c +1 -0
index 8f1ea27f976f..d309c1cc13db 100644
@@ -4,6 +4,7 @@
 #include <math.h>
 #include <string.h>
 #include "counts.h"
+#include "cpumap.h"
 #include "debug.h"
 #include "header.h"
 #include "stat.h"
tools/perf/util/svghelper.c +1 -1
index 582f4a69cd48..96f941e01681 100644
@@ -17,11 +17,11 @@
 #include <linux/string.h>
 #include <linux/time64.h>
 #include <linux/zalloc.h>
+#include <internal/cpumap.h>
 #include <perf/cpumap.h>
 
 #include "env.h"
 #include "svghelper.h"
-#include "cpumap.h"
 
 static u64 first_time, last_time;
 static u64 turbo_frequency, max_freq;
tools/perf/util/top.c +0 -1
index 51fb574998bb..ef96e3dd6902 100644
@@ -5,7 +5,6 @@
  * Refactored from builtin-top.c, see that files for further copyright notes.
  */
 
-#include "cpumap.h"
 #include "event.h"
 #include "evlist.h"
 #include "evsel.h"
Signature · 1 line
2.21.0
author maintainer
#14 lore raw

PATCH 14/31 perf event: Move perf_event__synthesize* to event.h

In reply to Arnaldo Carvalho de Melo

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

Where is the perf_event__handler_t typedef they need, which was the only reason for header.h to be including event.h, untangle that.

---
 tools/perf/util/event.h  | 36 ++++++++++++++++++++++++++++++++++
 tools/perf/util/header.h | 42 +++-------------------------------------
 2 files changed, 39 insertions(+), 39 deletions(-)
tools/perf/util/event.h +36 -0
index 47ad81d47b1a..4e6d33c76d57 100644
@@ -279,6 +279,9 @@ enum {
 
 void perf_event__print_totals(void);
 
+struct evlist;
+struct evsel;
+struct perf_session;
 struct perf_tool;
 struct perf_thread_map;
 struct perf_cpu_map;
@@ -290,6 +293,39 @@ typedef int (*perf_event__handler_t)(struct perf_tool *tool,
 				     struct perf_sample *sample,
 				     struct machine *machine);
 
+int perf_event__synthesize_attr(struct perf_tool *tool,
+				struct perf_event_attr *attr, u32 ids, u64 *id,
+				perf_event__handler_t process);
+int perf_event__synthesize_attrs(struct perf_tool *tool,
+				 struct evlist *evlist,
+				 perf_event__handler_t process);
+int perf_event__synthesize_build_id(struct perf_tool *tool,
+				    struct dso *pos, u16 misc,
+				    perf_event__handler_t process,
+				    struct machine *machine);
+int perf_event__synthesize_extra_attr(struct perf_tool *tool,
+				      struct evlist *evsel_list,
+				      perf_event__handler_t process,
+				      bool is_pipe);
+int perf_event__synthesize_event_update_cpus(struct perf_tool *tool,
+					     struct evsel *evsel,
+					     perf_event__handler_t process);
+int perf_event__synthesize_event_update_name(struct perf_tool *tool,
+					     struct evsel *evsel,
+					     perf_event__handler_t process);
+int perf_event__synthesize_event_update_scale(struct perf_tool *tool,
+					      struct evsel *evsel,
+					      perf_event__handler_t process);
+int perf_event__synthesize_event_update_unit(struct perf_tool *tool,
+					     struct evsel *evsel,
+					     perf_event__handler_t process);
+int perf_event__synthesize_features(struct perf_tool *tool,
+				    struct perf_session *session,
+				    struct evlist *evlist,
+				    perf_event__handler_t process);
+int perf_event__synthesize_tracing_data(struct perf_tool *tool,
+					int fd, struct evlist *evlist,
+					perf_event__handler_t process);
 int perf_event__synthesize_thread_map(struct perf_tool *tool,
 				      struct perf_thread_map *threads,
 				      perf_event__handler_t process,
tools/perf/util/header.h +3 -39

73 lines not on this page · raw message

Signature · 1 line
2.21.0
author maintainer
#15 lore raw

PATCH 15/31 perf stat: Move perf_stat_synthesize_config() to event.h

In reply to Arnaldo Carvalho de Melo

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

Together with the other synthsizers, and rename it to perf_event__synthesize_stat_events().

This allows us to stop including event.h in util/stat.h.

---
 tools/perf/builtin-stat.c |  4 ++--
 tools/perf/util/event.h   |  5 +++++
 tools/perf/util/stat.c    | 10 +++++-----
 tools/perf/util/stat.h    |  8 ++------
 4 files changed, 14 insertions(+), 13 deletions(-)
tools/perf/builtin-stat.c +2 -2
index 5bc0c570b7b6..b55e8060810b 100644
@@ -540,8 +540,8 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
 		if (err < 0)
 			return err;
 
-		err = perf_stat_synthesize_config(&stat_config, NULL, evsel_list,
-						  process_synthesized_event, is_pipe);
+		err = perf_event__synthesize_stat_events(&stat_config, NULL, evsel_list,
+							 process_synthesized_event, is_pipe);
 		if (err < 0)
 			return err;
 	}
tools/perf/util/event.h +5 -0
index 4e6d33c76d57..89a2404170a0 100644
@@ -293,6 +293,11 @@ typedef int (*perf_event__handler_t)(struct perf_tool *tool,
 				     struct perf_sample *sample,
 				     struct machine *machine);
 
+int perf_event__synthesize_stat_events(struct perf_stat_config *config,
+				       struct perf_tool *tool,
+				       struct evlist *evlist,
+				       perf_event__handler_t process,
+				       bool attrs);
 int perf_event__synthesize_attr(struct perf_tool *tool,
 				struct perf_event_attr *attr, u32 ids, u64 *id,
 				perf_event__handler_t process);
tools/perf/util/stat.c +5 -5
index d309c1cc13db..2e318d95c528 100644
@@ -495,11 +495,11 @@ int create_perf_stat_counter(struct evsel *evsel,
 	return perf_evsel__open_per_thread(evsel, evsel->core.threads);
 }
 
-int perf_stat_synthesize_config(struct perf_stat_config *config,
-				struct perf_tool *tool,
-				struct evlist *evlist,
-				perf_event__handler_t process,
-				bool attrs)
+int perf_event__synthesize_stat_events(struct perf_stat_config *config,
+				       struct perf_tool *tool,
+				       struct evlist *evlist,
+				       perf_event__handler_t process,
+				       bool attrs)
 {
 	int err;
 
tools/perf/util/stat.h +2 -6
index 14fe3e548229..0f9c9f6e2041 100644
@@ -7,8 +7,9 @@
 #include <sys/types.h>
 #include <sys/resource.h>
 #include "rblist.h"
-#include "event.h"
 
+struct perf_cpu_map;
+struct perf_stat_config;
 struct timespec;
 
 struct stats {
@@ -210,11 +211,6 @@ size_t perf_event__fprintf_stat_config(union perf_event *event, FILE *fp);
 int create_perf_stat_counter(struct evsel *evsel,
 			     struct perf_stat_config *config,
 			     struct target *target);
-int perf_stat_synthesize_config(struct perf_stat_config *config,
-				struct perf_tool *tool,
-				struct evlist *evlist,
-				perf_event__handler_t process,
-				bool attrs);
 void
 perf_evlist__print_counters(struct evlist *evlist,
 			    struct perf_stat_config *config,
Signature · 1 line
2.21.0
author maintainer
#16 lore raw

PATCH 16/31 perf callchain: Remove needless event.h include

In reply to Arnaldo Carvalho de Melo

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

All we need is a bunch of struct forward declarations and then add event.h to the only place that was getting it indirectly via callchain.h.

---
 tools/perf/arch/powerpc/util/skip-callchain-idx.c | 1 +
 tools/perf/util/callchain.h                       | 5 ++++-
 tools/perf/util/evsel_fprintf.c                   | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)
tools/perf/arch/powerpc/util/skip-callchain-idx.c +1 -0
index fc9c2f5fcd52..3018a054526a 100644
@@ -13,6 +13,7 @@
 #include "util/callchain.h"
 #include "util/debug.h"
 #include "util/dso.h"
+#include "util/event.h" // struct ip_callchain
 #include "util/map.h"
 #include "util/symbol.h"
 
tools/perf/util/callchain.h +4 -1
index b042ceef4114..83398e5bbe4b 100644
@@ -4,12 +4,15 @@
 
 #include <linux/list.h>
 #include <linux/rbtree.h>
-#include "event.h"
 #include "map_symbol.h"
 #include "branch.h"
 
+struct addr_location;
 struct evsel;
+struct ip_callchain;
 struct map;
+struct perf_sample;
+struct thread;
 
 #define HELP_PAD "\t\t\t\t"
 
tools/perf/util/evsel_fprintf.c +1 -0
index 496fec01f5d1..a8cbdf4c2753 100644
@@ -4,6 +4,7 @@
 #include <stdbool.h>
 #include <traceevent/event-parse.h>
 #include "evsel.h"
+#include "util/event.h"
 #include "callchain.h"
 #include "map.h"
 #include "strlist.h"
Signature · 1 line
2.21.0
author maintainer
#17 lore raw

PATCH 17/31 perf python: Remove debug.h

In reply to Arnaldo Carvalho de Melo

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

We only need to have the prototype for the eprintf() replacement we use in the python binding, provide it and avoid dragging debug.h as a dependency.

---
 tools/perf/util/python.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/python.c +2 -1
index 96dd3333c911..0ba19dd75510 100644
@@ -6,7 +6,6 @@
 #include <linux/err.h>
 #include <perf/cpumap.h>
 #include <traceevent/event-parse.h>
-#include "debug.h"
 #include "evlist.h"
 #include "callchain.h"
 #include "evsel.h"
@@ -60,6 +59,8 @@ int parse_callchain_record(const char *arg __maybe_unused,
  */
 int verbose;
 
+int eprintf(int level, int var, const char *fmt, ...);
+
 int eprintf(int level, int var, const char *fmt, ...)
 {
 	va_list args;
Signature · 1 line
2.21.0
author maintainer
#18 lore raw

PATCH 18/31 perf hist: Add missing 'struct branch_stack' forward declaration

In reply to Arnaldo Carvalho de Melo

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

Its needed, was being obtained indirectly, fix it.

---
 tools/perf/util/hist.h | 1 +
 1 file changed, 1 insertion(+)
tools/perf/util/hist.h +1 -0
index 34803e33dc80..6a186b668303 100644
@@ -15,6 +15,7 @@ struct addr_location;
 struct map_symbol;
 struct mem_info;
 struct branch_info;
+struct branch_stack;
 struct block_info;
 struct symbol;
 struct ui_progress;
Signature · 1 line
2.21.0
author maintainer
#19 lore raw

PATCH 19/31 perf annotate: Add missing machine.h include directive

In reply to Arnaldo Carvalho de Melo

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

We use what is defined there, were getting it by luck, indirectly, fix it.

---
 tools/perf/builtin-annotate.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/builtin-annotate.c +1 -0
index 4e4d2e76232e..553c651fa0a2 100644
@@ -27,6 +27,7 @@
 #include "util/sort.h"
 #include "util/hist.h"
 #include "util/dso.h"
+#include "util/machine.h"
 #include "util/map.h"
 #include "util/session.h"
 #include "util/tool.h"
Signature · 1 line
2.21.0
author maintainer
#20 lore raw

PATCH 20/31 perf sched: Add missing event.h include directive

In reply to Arnaldo Carvalho de Melo

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

We use what is defined there, were getting it by luck, indirectly, fix it.

---
 tools/perf/builtin-sched.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/builtin-sched.c +1 -0
index 511e19a7aafa..f0b828c201cc 100644
@@ -24,6 +24,7 @@
 #include "util/trace-event.h"
 
 #include "util/debug.h"
+#include "util/event.h"
 
 #include <linux/kernel.h>
 #include <linux/log2.h>
Signature · 1 line
2.21.0
author maintainer
#21 lore raw

PATCH 21/31 perf auxtrace: Add missing 'struct perf_sample' forward declaration

In reply to Arnaldo Carvalho de Melo

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

Its needed, was being obtained indirectly, fix it.

---
 tools/perf/util/auxtrace.h | 1 +
 1 file changed, 1 insertion(+)
tools/perf/util/auxtrace.h +1 -0
index 37e70dc01436..1ed902a24a39 100644
@@ -24,6 +24,7 @@ struct perf_session;
 struct evlist;
 struct perf_tool;
 struct perf_mmap;
+struct perf_sample;
 struct option;
 struct record_opts;
 struct perf_record_auxtrace_info;
Signature · 1 line
2.21.0
author maintainer
#22 lore raw

PATCH 22/31 perf tools: Move event synthesizing routines to separate header

In reply to Arnaldo Carvalho de Melo

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

Those are the only routines using the perf_event__handler_t typedef and are all related, so move to a separate header to reduce the header dependency tree, lots of places were getting event.h and even stdio.h, limits.h indirectly, so fix those as well.

---
 tools/perf/arch/x86/util/archinsn.c   |   1 +
 tools/perf/arch/x86/util/event.c      |   2 +
 tools/perf/arch/x86/util/machine.c    |   1 +
 tools/perf/arch/x86/util/tsc.c        |   2 +
 tools/perf/builtin-inject.c           |   1 +
 tools/perf/builtin-kvm.c              |   1 +
 tools/perf/builtin-record.c           |   1 +
 tools/perf/builtin-stat.c             |   1 +
 tools/perf/builtin-top.c              |   1 +
 tools/perf/builtin-trace.c            |   1 +
 tools/perf/tests/code-reading.c       |   1 +
 tools/perf/tests/cpumap.c             |   1 +
 tools/perf/tests/dwarf-unwind.c       |   1 +
 tools/perf/tests/event_update.c       |   1 +
 tools/perf/tests/hists_common.c       |   2 +
 tools/perf/tests/mmap-thread-lookup.c |   2 +
 tools/perf/tests/sample-parsing.c     |   1 +
 tools/perf/tests/stat.c               |   1 +
 tools/perf/tests/thread-map.c         |   1 +
 tools/perf/ui/stdio/hist.c            |   1 +
 tools/perf/util/auxtrace.c            |   1 +
 tools/perf/util/auxtrace.h            |  17 +---
 tools/perf/util/bpf-event.c           |   1 +
 tools/perf/util/bpf-event.h           |  15 +---
 tools/perf/util/callchain.c           |   1 +
 tools/perf/util/event.c               |   1 +
 tools/perf/util/event.h               | 118 +-------------------------
 tools/perf/util/evsel.c               |   1 +
 tools/perf/util/header.c              |   1 +
 tools/perf/util/intel-bts.c           |   1 +
 tools/perf/util/intel-pt.c            |   1 +
 tools/perf/util/machine.c             |  10 +++
 tools/perf/util/machine.h             |  15 ----
 tools/perf/util/session.c             |   1 +
 tools/perf/util/session.h             |   5 --
 tools/perf/util/stat.c                |   1 +
 tools/perf/util/synthetic-events.h    | 103 ++++++++++++++++++++++
 tools/perf/util/tsc.h                 |  14 +--
 38 files changed, 154 insertions(+), 177 deletions(-)
 create mode 100644 tools/perf/util/synthetic-events.h
tools/perf/arch/x86/util/archinsn.c +1 -0
index 9876c7a7ed7c..3e6791531ca5 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "../../../../arch/x86/include/asm/insn.h"
 #include "archinsn.h"
+#include "event.h"
 #include "machine.h"
 #include "thread.h"
 #include "symbol.h"
tools/perf/arch/x86/util/event.c +2 -0
index a3a0b6884779..d357c625c09f 100644
@@ -3,6 +3,8 @@
 #include <linux/string.h>
 #include <linux/zalloc.h>
 
+#include "../../util/event.h"
+#include "../../util/synthetic-events.h"
 #include "../../util/machine.h"
 #include "../../util/tool.h"
 #include "../../util/map.h"
tools/perf/arch/x86/util/machine.c +1 -0
index 42418040bc07..f0c289862f9f 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/types.h>
 #include <linux/string.h>
+#include <limits.h>
 #include <stdlib.h>
 
 #include "../../util/util.h" // page_size
tools/perf/arch/x86/util/tsc.c +2 -0
index c5197a15119b..2f55afb14e1f 100644
@@ -8,6 +8,8 @@
 #include <linux/types.h>
 #include <asm/barrier.h>
 #include "../../../util/debug.h"
+#include "../../../util/event.h"
+#include "../../../util/synthetic-events.h"
 #include "../../../util/tsc.h"
 
 int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc,
tools/perf/builtin-inject.c +1 -0
index c14f40b858bc..23a76cf3846f 100644
@@ -21,6 +21,7 @@
 #include "util/auxtrace.h"
 #include "util/jit.h"
 #include "util/symbol.h"
+#include "util/synthetic-events.h"
 #include "util/thread.h"
 
 #include <subcmd/parse-options.h>
tools/perf/builtin-kvm.c +1 -0
index 0a4fcbe32bf6..ac6d6e061dc5 100644
@@ -17,6 +17,7 @@
 #include "util/debug.h"
 #include "util/tool.h"
 #include "util/stat.h"
+#include "util/synthetic-events.h"
 #include "util/top.h"
 #include "util/data.h"
 #include "util/ordered-events.h"
tools/perf/builtin-record.c +1 -0
index 1447004eee8a..907d4d4677a3 100644
@@ -38,6 +38,7 @@
 #include "util/trigger.h"
 #include "util/perf-hooks.h"
 #include "util/cpu-set-sched.h"
+#include "util/synthetic-events.h"
 #include "util/time-utils.h"
 #include "util/units.h"
 #include "util/bpf-event.h"
tools/perf/builtin-stat.c +1 -0
index b55e8060810b..eece3d1e429a 100644
@@ -61,6 +61,7 @@
 #include "util/tool.h"
 #include "util/string2.h"
 #include "util/metricgroup.h"
+#include "util/synthetic-events.h"
 #include "util/target.h"
 #include "util/time-utils.h"
 #include "util/top.h"
tools/perf/builtin-top.c +1 -0
index 726e3f2dd8c7..b052470f89b4 100644
@@ -32,6 +32,7 @@
 #include "util/map.h"
 #include "util/session.h"
 #include "util/symbol.h"
+#include "util/synthetic-events.h"
 #include "util/top.h"
 #include "util/util.h"
 #include <linux/rbtree.h>
tools/perf/builtin-trace.c +1 -0
index 0f633f0d6be8..f0f735093e21 100644
@@ -28,6 +28,7 @@
 #include "util/dso.h"
 #include "util/env.h"
 #include "util/event.h"
+#include "util/synthetic-events.h"
 #include "util/evlist.h"
 #include "util/evswitch.h"
 #include <subcmd/pager.h>
tools/perf/tests/code-reading.c +1 -0
index 8d9020c46ca9..fd02c1f1d976 100644
@@ -24,6 +24,7 @@
 #include "symbol.h"
 #include "event.h"
 #include "record.h"
+#include "util/synthetic-events.h"
 #include "thread.h"
 
 #include "tests.h"
tools/perf/tests/cpumap.c +1 -0
index 39493de50117..8a0d236202b0 100644
@@ -3,6 +3,7 @@
 #include <stdio.h>
 #include "cpumap.h"
 #include "event.h"
+#include "util/synthetic-events.h"
 #include <string.h>
 #include <linux/bitops.h>
 #include <perf/cpumap.h>
tools/perf/tests/dwarf-unwind.c +1 -0
index 4125255ff637..4f4ecbcbe87e 100644
@@ -15,6 +15,7 @@
 #include "symbol.h"
 #include "thread.h"
 #include "callchain.h"
+#include "util/synthetic-events.h"
 
 #if defined (__x86_64__) || defined (__i386__) || defined (__powerpc__)
 #include "arch-tests.h"
tools/perf/tests/event_update.c +1 -0
index 317eb8c5ccd4..4bb772e2b73d 100644
@@ -7,6 +7,7 @@
 #include "evsel.h"
 #include "header.h"
 #include "machine.h"
+#include "util/synthetic-events.h"
 #include "tool.h"
 #include "tests.h"
 #include "debug.h"
tools/perf/tests/hists_common.c +2 -0
index de110d8f169b..6f34d08b84e5 100644
@@ -2,6 +2,7 @@
 #include <inttypes.h>
 #include "util/debug.h"
 #include "util/dso.h"
+#include "util/event.h" // struct perf_sample
 #include "util/map.h"
 #include "util/symbol.h"
 #include "util/sort.h"
@@ -10,6 +11,7 @@
 #include "util/thread.h"
 #include "tests/hists_common.h"
 #include <linux/kernel.h>
+#include <linux/perf_event.h>
 
 static struct {
 	u32 pid;
tools/perf/tests/mmap-thread-lookup.c +2 -0
index f72889c13538..33b496d194f4 100644
@@ -8,11 +8,13 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include "debug.h"
+#include "event.h"
 #include "tests.h"
 #include "machine.h"
 #include "thread_map.h"
 #include "map.h"
 #include "symbol.h"
+#include "util/synthetic-events.h"
 #include "thread.h"
 #include "util.h" // page_size
 
tools/perf/tests/sample-parsing.c +1 -0
index e3b965e7a233..3a02426db9a6 100644
@@ -12,6 +12,7 @@
 #include "event.h"
 #include "evsel.h"
 #include "debug.h"
+#include "util/synthetic-events.h"
 
 #include "tests.h"
 
tools/perf/tests/stat.c +1 -0
index cc10b4116c9f..c1911501c39c 100644
@@ -5,6 +5,7 @@
 #include "stat.h"
 #include "counts.h"
 #include "debug.h"
+#include "util/synthetic-events.h"
 
 static bool has_term(struct perf_record_stat_config *config,
 		     u64 tag, u64 val)
tools/perf/tests/thread-map.c +1 -0
index 39168c57943b..28f51c4bd373 100644
@@ -8,6 +8,7 @@
 #include "thread_map.h"
 #include "debug.h"
 #include "event.h"
+#include "util/synthetic-events.h"
 #include <linux/zalloc.h>
 #include <perf/event.h>
 
tools/perf/ui/stdio/hist.c +1 -0
index 832ca6cfbe30..5365606e9dad 100644
@@ -5,6 +5,7 @@
 
 #include "../../util/callchain.h"
 #include "../../util/debug.h"
+#include "../../util/event.h"
 #include "../../util/hist.h"
 #include "../../util/map.h"
 #include "../../util/map_groups.h"
tools/perf/util/auxtrace.c +1 -0
index 1c0ff5acff83..0e8c89cf7cad 100644
@@ -32,6 +32,7 @@
 #include "pmu.h"
 #include "evsel.h"
 #include "symbol.h"
+#include "util/synthetic-events.h"
 #include "thread_map.h"
 #include "asm/bug.h"
 #include "auxtrace.h"
tools/perf/util/auxtrace.h +2 -15
index 1ed902a24a39..b110aec1da4d 100644
@@ -11,14 +11,13 @@
 #include <errno.h>
 #include <stdbool.h>
 #include <stddef.h>
+#include <stdio.h> // FILE
 #include <linux/list.h>
 #include <linux/perf_event.h>
 #include <linux/types.h>
 #include <asm/bitsperlong.h>
 #include <asm/barrier.h>
 
-#include "event.h"
-
 union perf_event;
 struct perf_session;
 struct evlist;
@@ -27,6 +26,7 @@ struct perf_mmap;
 struct perf_sample;
 struct option;
 struct record_opts;
+struct perf_record_auxtrace_error;
 struct perf_record_auxtrace_info;
 struct events_stats;
 
@@ -525,10 +525,6 @@ void auxtrace_synth_error(struct perf_record_auxtrace_error *auxtrace_error, int
 			  int code, int cpu, pid_t pid, pid_t tid, u64 ip,
 			  const char *msg, u64 timestamp);
 
-int perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr,
-					 struct perf_tool *tool,
-					 struct perf_session *session,
-					 perf_event__handler_t process);
 int perf_event__process_auxtrace_info(struct perf_session *session,
 				      union perf_event *event);
 s64 perf_event__process_auxtrace(struct perf_session *session,
@@ -605,15 +601,6 @@ void auxtrace_record__free(struct auxtrace_record *itr __maybe_unused)
 {
 }
 
-static inline int
-perf_event__synthesize_auxtrace_info(struct auxtrace_record *itr __maybe_unused,
-				     struct perf_tool *tool __maybe_unused,
-				     struct perf_session *session __maybe_unused,
-				     perf_event__handler_t process __maybe_unused)
-{
-	return -EINVAL;
-}
-
 static inline
 int auxtrace_record__options(struct auxtrace_record *itr __maybe_unused,
 			     struct evlist *evlist __maybe_unused,
tools/perf/util/bpf-event.c +1 -0
index 7a3d4b125323..f7ed5d122e22 100644
@@ -16,6 +16,7 @@
 #include "map.h"
 #include "evlist.h"
 #include "record.h"
+#include "util/synthetic-events.h"
 
 #define ptr_to_u64(ptr)    ((__u64)(unsigned long)(ptr))
 
tools/perf/util/bpf-event.h +1 -14
index a01c2fd68c03..81fdc88e6c1a 100644
@@ -6,9 +6,9 @@
 #include <linux/rbtree.h>
 #include <pthread.h>
 #include <api/fd/array.h>
-#include "event.h"
 #include <stdio.h>
 
+struct bpf_prog_info;
 struct machine;
 union perf_event;
 struct perf_env;
@@ -33,11 +33,6 @@ struct btf_node {
 #ifdef HAVE_LIBBPF_SUPPORT
 int machine__process_bpf(struct machine *machine, union perf_event *event,
 			 struct perf_sample *sample);
-
-int perf_event__synthesize_bpf_events(struct perf_session *session,
-				      perf_event__handler_t process,
-				      struct machine *machine,
-				      struct record_opts *opts);
 int bpf_event__add_sb_event(struct evlist **evlist,
 				 struct perf_env *env);
 void bpf_event__print_bpf_prog_info(struct bpf_prog_info *info,
@@ -51,14 +46,6 @@ static inline int machine__process_bpf(struct machine *machine __maybe_unused,
 	return 0;
 }
 
-static inline int perf_event__synthesize_bpf_events(struct perf_session *session __maybe_unused,
-						    perf_event__handler_t process __maybe_unused,
-						    struct machine *machine __maybe_unused,
-						    struct record_opts *opts __maybe_unused)
-{
-	return 0;
-}
-
 static inline int bpf_event__add_sb_event(struct evlist **evlist __maybe_unused,
 					  struct perf_env *env __maybe_unused)
 {
tools/perf/util/callchain.c +1 -0
index c14646c1f2eb..9a9b56ed3f0a 100644
@@ -23,6 +23,7 @@
 
 #include "debug.h"
 #include "dso.h"
+#include "event.h"
 #include "hist.h"
 #include "sort.h"
 #include "machine.h"
tools/perf/util/event.c +1 -0
index d65ae7cf9316..043a08fc7398 100644
@@ -32,6 +32,7 @@
 #include "stat.h"
 #include "session.h"
 #include "bpf-event.h"
+#include "synthetic-events.h"
 #include "tool.h"
 #include "../perf.h"
 
tools/perf/util/event.h +2 -116

141 lines not on this page · raw message

tools/perf/util/evsel.c +1 -0
index 5b40b840624c..5af025c80ec5 100644
@@ -40,6 +40,7 @@
 #include "trace-event.h"
 #include "stat.h"
 #include "string2.h"
+#include "util/synthetic-events.h"
 #include "memswap.h"
 #include "util.h"
 #include "../perf-sys.h"
tools/perf/util/header.c +1 -0
index d85827de1b60..a4a8342eba98 100644
@@ -45,6 +45,7 @@
 #include "util.h" // page_size, perf_exe()
 #include "cputopo.h"
 #include "bpf-event.h"
+#include "util/synthetic-events.h"
 
 #include <linux/ctype.h>
 #include <internal/lib.h>
tools/perf/util/intel-bts.c +1 -0
index 15f87a09f4fe..3888d4cd3ed1 100644
@@ -28,6 +28,7 @@
 #include "auxtrace.h"
 #include "intel-pt-decoder/intel-pt-insn-decoder.h"
 #include "intel-bts.h"
+#include "util/synthetic-events.h"
 
 #define MAX_TIMESTAMP (~0ULL)
 
tools/perf/util/intel-pt.c +1 -0
index 9b56fb74bedf..bcdc0359f7cf 100644
@@ -33,6 +33,7 @@
 #include "tsc.h"
 #include "intel-pt.h"
 #include "config.h"
+#include "util/synthetic-events.h"
 #include "time-utils.h"
 
 #include "../arch/x86/include/uapi/asm/perf_regs.h"
tools/perf/util/machine.c +10 -0
index b4749d3eed08..132de5cfb9b9 100644
@@ -20,6 +20,7 @@
 #include "symbol.h"
 #include "sort.h"
 #include "strlist.h"
+#include "util/synthetic-events.h"
 #include "target.h"
 #include "thread.h"
 #include "util.h"
@@ -2624,6 +2625,15 @@ int __machine__synthesize_threads(struct machine *machine, struct perf_tool *too
 	return 0;
 }
 
+int machine__synthesize_threads(struct machine *machine, struct target *target,
+				struct perf_thread_map *threads, bool data_mmap,
+				unsigned int nr_threads_synthesize)
+{
+	return __machine__synthesize_threads(machine, NULL, target, threads,
+					     perf_event__process, data_mmap,
+					     nr_threads_synthesize);
+}
+
 pid_t machine__get_current_tid(struct machine *machine, int cpu)
 {
 	int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
tools/perf/util/machine.h +0 -15
index ffd391a925a6..18e13c0ccd6a 100644
@@ -6,7 +6,6 @@
 #include <linux/rbtree.h>
 #include "map_groups.h"
 #include "dsos.h"
-#include "event.h"
 #include "rwsem.h"
 
 struct addr_location;
@@ -252,20 +251,6 @@ int machines__for_each_thread(struct machines *machines,
 			      int (*fn)(struct thread *thread, void *p),
 			      void *priv);
 
-int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
-				  struct target *target, struct perf_thread_map *threads,
-				  perf_event__handler_t process, bool data_mmap,
-				  unsigned int nr_threads_synthesize);
-static inline
-int machine__synthesize_threads(struct machine *machine, struct target *target,
-				struct perf_thread_map *threads, bool data_mmap,
-				unsigned int nr_threads_synthesize)
-{
-	return __machine__synthesize_threads(machine, NULL, target, threads,
-					     perf_event__process, data_mmap,
-					     nr_threads_synthesize);
-}
-
 pid_t machine__get_current_tid(struct machine *machine, int cpu);
 int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid,
 			     pid_t tid);
tools/perf/util/session.c +1 -0
index 2b583e6adb49..6267613b551d 100644
@@ -29,6 +29,7 @@
 #include "thread-stack.h"
 #include "sample-raw.h"
 #include "stat.h"
+#include "util/synthetic-events.h"
 #include "util.h"
 #include "ui/progress.h"
 #include "../perf.h"
tools/perf/util/session.h +0 -5
index b7aa076ab6fd..b4c9428c18f0 100644
@@ -138,9 +138,4 @@ int perf_session__deliver_synth_event(struct perf_session *session,
 int perf_event__process_id_index(struct perf_session *session,
 				 union perf_event *event);
 
-int perf_event__synthesize_id_index(struct perf_tool *tool,
-				    perf_event__handler_t process,
-				    struct evlist *evlist,
-				    struct machine *machine);
-
 #endif /* __PERF_SESSION_H */
tools/perf/util/stat.c +1 -0
index 2e318d95c528..46c8a5027e12 100644
@@ -12,6 +12,7 @@
 #include "target.h"
 #include "evlist.h"
 #include "evsel.h"
+#include "util/synthetic-events.h"
 #include "thread_map.h"
 #include <linux/zalloc.h>
 
tools/perf/util/synthetic-events.h new file +103 -0

103 lines not on this page · raw message

tools/perf/util/tsc.h +2 -12
index e0c3af34ac8d..3c5a632ee57c 100644
@@ -4,13 +4,12 @@
 
 #include <linux/types.h>
 
-#include "event.h"
-
 struct perf_tsc_conversion {
 	u16 time_shift;
 	u32 time_mult;
 	u64 time_zero;
 };
+
 struct perf_event_mmap_page;
 
 int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc,
@@ -20,13 +19,4 @@ u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc);
 u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc);
 u64 rdtsc(void);
 
-struct perf_event_mmap_page;
-struct perf_tool;
-struct machine;
-
-int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc,
-				struct perf_tool *tool,
-				perf_event__handler_t process,
-				struct machine *machine);
-
-#endif
+#endif // __PERF_TSC_H
Signature · 1 line
2.21.0
author maintainer
#23 lore raw

PATCH 23/31 perf memswap: Adopt 'struct u64_swap' from evsel.h

In reply to Arnaldo Carvalho de Melo

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

As it is not used in evsel.h and is a memory swap struct, so fits better in memswap.h.

---
 tools/perf/util/evsel.h   | 5 -----
 tools/perf/util/memswap.h | 7 +++++++
 2 files changed, 7 insertions(+), 5 deletions(-)
tools/perf/util/evsel.h +0 -5
index 68321d10eb2d..74df298acb31 100644
@@ -179,11 +179,6 @@ struct evsel {
 	} side_band;
 };
 
-union u64_swap {
-	u64 val64;
-	u32 val32[2];
-};
-
 struct perf_missing_features {
 	bool sample_id_all;
 	bool exclude_guest;
tools/perf/util/memswap.h +7 -0
index 1e29ff903ca9..2c38e8c2d548 100644
@@ -2,6 +2,13 @@
 #ifndef PERF_MEMSWAP_H_
 #define PERF_MEMSWAP_H_
 
+#include <linux/types.h>
+
+union u64_swap {
+	u64 val64;
+	u32 val32[2];
+};
+
 void mem_bswap_64(void *src, int byte_size);
 void mem_bswap_32(void *src, int byte_size);
 
Signature · 1 line
2.21.0
author maintainer
#24 lore raw

PATCH 24/31 perf tools: Move event synthesizing routines to separate .c file

In reply to Arnaldo Carvalho de Melo

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

For better grouping, in time we may end up making most of these static, i.e. generalizing the 'perf record' synthesizing code so that based on the target it can do the right thing and call the needed synthesizers.

---
 tools/perf/builtin-record.c        |    9 -
 tools/perf/util/Build              |    1 +
 tools/perf/util/cs-etm.c           |    1 +
 tools/perf/util/event.c            | 1108 +---------------
 tools/perf/util/evsel.c            |  278 ----
 tools/perf/util/header.c           |  393 +-----
 tools/perf/util/header.h           |   18 +
 tools/perf/util/machine.c          |   25 -
 tools/perf/util/namespaces.c       |   18 +
 tools/perf/util/namespaces.h       |    2 +
 tools/perf/util/session.c          |   71 --
 tools/perf/util/stat.c             |   43 -
 tools/perf/util/synthetic-events.c | 1884 ++++++++++++++++++++++++++++
 13 files changed, 1928 insertions(+), 1923 deletions(-)
 create mode 100644 tools/perf/util/synthetic-events.c
tools/perf/builtin-record.c +0 -9
index 907d4d4677a3..4bd11c918e73 100644
@@ -1181,15 +1181,6 @@ static void workload_exec_failed_signal(int signo __maybe_unused,
 static void snapshot_sig_handler(int sig);
 static void alarm_sig_handler(int sig);
 
-int __weak
-perf_event__synth_time_conv(const struct perf_event_mmap_page *pc __maybe_unused,
-			    struct perf_tool *tool __maybe_unused,
-			    perf_event__handler_t process __maybe_unused,
-			    struct machine *machine __maybe_unused)
-{
-	return 0;
-}
-
 static const struct perf_event_mmap_page *
 perf_evlist__pick_pc(struct evlist *evlist)
 {
tools/perf/util/Build +1 -0
index 0b4d8e0d474c..fd89d6a8cd65 100644
@@ -86,6 +86,7 @@ perf-y += stat-display.o
 perf-y += record.o
 perf-y += srcline.o
 perf-y += srccode.o
+perf-y += synthetic-events.o
 perf-y += data.o
 perf-y += tsc.o
 perf-y += cloexec.o
tools/perf/util/cs-etm.c +1 -0
index f87b9c1c9f9a..6021974577d5 100644
@@ -35,6 +35,7 @@
 #include "thread.h"
 #include "thread-stack.h"
 #include <tools/libc_compat.h>
+#include "util/synthetic-events.h"
 
 #define MAX_TIMESTAMP (~0ULL)
 
tools/perf/util/event.c +1 -1107

1,150 lines not on this page · raw message

tools/perf/util/evsel.c +0 -278

290 lines not on this page · raw message

tools/perf/util/header.c +3 -390

448 lines not on this page · raw message

tools/perf/util/header.h +18 -0
index 999dac41871e..ca53a929e9fd 100644
@@ -92,6 +92,24 @@ struct perf_header {
 	struct perf_env 	env;
 };
 
+struct feat_fd {
+	struct perf_header *ph;
+	int		   fd;
+	void		   *buf;	/* Either buf != NULL or fd >= 0 */
+	ssize_t		   offset;
+	size_t		   size;
+	struct evsel	   *events;
+};
+
+struct perf_header_feature_ops {
+	int	   (*write)(struct feat_fd *ff, struct evlist *evlist);
+	void	   (*print)(struct feat_fd *ff, FILE *fp);
+	int	   (*process)(struct feat_fd *ff, void *data);
+	const char *name;
+	bool	   full_only;
+	bool	   synthesize;
+};
+
 struct evlist;
 struct perf_session;
 struct perf_tool;
tools/perf/util/machine.c +0 -25
index 132de5cfb9b9..0535338f2d7a 100644
@@ -20,7 +20,6 @@
 #include "symbol.h"
 #include "sort.h"
 #include "strlist.h"
-#include "util/synthetic-events.h"
 #include "target.h"
 #include "thread.h"
 #include "util.h"
@@ -2610,30 +2609,6 @@ int machines__for_each_thread(struct machines *machines,
 	return rc;
 }
 
-int __machine__synthesize_threads(struct machine *machine, struct perf_tool *tool,
-				  struct target *target, struct perf_thread_map *threads,
-				  perf_event__handler_t process, bool data_mmap,
-				  unsigned int nr_threads_synthesize)
-{
-	if (target__has_task(target))
-		return perf_event__synthesize_thread_map(tool, threads, process, machine, data_mmap);
-	else if (target__has_cpu(target))
-		return perf_event__synthesize_threads(tool, process,
-						      machine, data_mmap,
-						      nr_threads_synthesize);
-	/* command specified */
-	return 0;
-}
-
-int machine__synthesize_threads(struct machine *machine, struct target *target,
-				struct perf_thread_map *threads, bool data_mmap,
-				unsigned int nr_threads_synthesize)
-{
-	return __machine__synthesize_threads(machine, NULL, target, threads,
-					     perf_event__process, data_mmap,
-					     nr_threads_synthesize);
-}
-
 pid_t machine__get_current_tid(struct machine *machine, int cpu)
 {
 	int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
tools/perf/util/namespaces.c +18 -0
index 99be15dd2b6b..285d6f30d912 100644
@@ -17,8 +17,26 @@
 #include <string.h>
 #include <unistd.h>
 #include <asm/bug.h>
+#include <linux/kernel.h>
 #include <linux/zalloc.h>
 
+static const char *perf_ns__names[] = {
+	[NET_NS_INDEX]		= "net",
+	[UTS_NS_INDEX]		= "uts",
+	[IPC_NS_INDEX]		= "ipc",
+	[PID_NS_INDEX]		= "pid",
+	[USER_NS_INDEX]		= "user",
+	[MNT_NS_INDEX]		= "mnt",
+	[CGROUP_NS_INDEX]	= "cgroup",
+};
+
+const char *perf_ns__name(unsigned int id)
+{
+	if (id >= ARRAY_SIZE(perf_ns__names))
+		return "UNKNOWN";
+	return perf_ns__names[id];
+}
+
 struct namespaces *namespaces__new(struct perf_record_namespaces *event)
 {
 	struct namespaces *namespaces;
tools/perf/util/namespaces.h +2 -0
index 40edef56cb52..4b33f684eddd 100644
@@ -66,4 +66,6 @@ static inline void __nsinfo__zput(struct nsinfo **nsip)
 
 #define nsinfo__zput(nsi) __nsinfo__zput(&nsi)
 
+const char *perf_ns__name(unsigned int id);
+
 #endif  /* __PERF_NAMESPACES_H */
tools/perf/util/session.c +0 -71

80 lines not on this page · raw message

tools/perf/util/stat.c +0 -43

52 lines not on this page · raw message

tools/perf/util/synthetic-events.c new file +1884 -0

858 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.21.0

Part of the diff is not shown here. View the raw message.

author maintainer
#25 lore raw

PATCH 25/31 tools lib traceevent: Convert remaining %p[fF] users to %p[sS]

In reply to Arnaldo Carvalho de Melo

From: Sakari Ailus <[email protected]>

There are no in-kernel %p[fF] users left. Convert the traceevent tool, too, to align with the kernel.

Cc Andy Shevchenko <[email protected]>
Cc Heikki Krogerus <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Joe Perches <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Petr Mladek <[email protected]>
Cc Rafael J. Wysocki <[email protected]>
Cc Rob Herring <[email protected]>
Cc Steven Rostedt (VMware) <[email protected]>
Cc Tzvetomir Stoyanov <[email protected]>
---
 .../Documentation/libtraceevent-func_apis.txt  | 10 +++++-----
 tools/lib/traceevent/event-parse.c             | 18 ++++++++++++++----
 2 files changed, 19 insertions(+), 9 deletions(-)
tools/lib/traceevent/Documentation/libtraceevent-func_apis.txt +5 -5
index 38bfea30a5f6..f6aca0df2151 100644
@@ -59,12 +59,12 @@ parser context.
 
 The _tep_register_function()_ function registers a function name mapped to an
 address and (optional) module. This mapping is used in case the function tracer
-or events have "%pF" or "%pS" parameter in its format string. It is common to
-pass in the kallsyms function names with their corresponding addresses with this
+or events have "%pS" parameter in its format string. It is common to pass in
+the kallsyms function names with their corresponding addresses with this
 function. The _tep_ argument is the trace event parser context. The _name_ is
-the name of the function, the string is copied internally. The _addr_ is
-the start address of the function. The _mod_ is the kernel module
-the function may be in (NULL for none).
+the name of the function, the string is copied internally. The _addr_ is the
+start address of the function. The _mod_ is the kernel module the function may
+be in (NULL for none).
 
 The _tep_register_print_string()_ function  registers a string by the address
 it was stored in the kernel. Some strings internal to the kernel with static
tools/lib/traceevent/event-parse.c +14 -4
index bb22238debfe..6f842af4550b 100644
@@ -4367,10 +4367,20 @@ static struct tep_print_arg *make_bprint_args(char *fmt, void *data, int size, s
 					switch (*ptr) {
 					case 's':
 					case 'S':
-					case 'f':
-					case 'F':
 					case 'x':
 						break;
+					case 'f':
+					case 'F':
+						/*
+						 * Pre-5.5 kernels use %pf and
+						 * %pF for printing symbols
+						 * while kernels since 5.5 use
+						 * %pfw for fwnodes. So check
+						 * %p[fF] isn't followed by 'w'.
+						 */
+						if (ptr[1] != 'w')
+							break;
+						/* fall through */
 					default:
 						/*
 						 * Older kernels do not process
@@ -4487,12 +4497,12 @@ get_bprint_format(void *data, int size __maybe_unused,
 
 	printk = find_printk(tep, addr);
 	if (!printk) {
-		if (asprintf(&format, "%%pf: (NO FORMAT FOUND at %llx)\n", addr) < 0)
+		if (asprintf(&format, "%%ps: (NO FORMAT FOUND at %llx)\n", addr) < 0)
 			return NULL;
 		return format;
 	}
 
-	if (asprintf(&format, "%s: %s", "%pf", printk->printk) < 0)
+	if (asprintf(&format, "%s: %s", "%ps", printk->printk) < 0)
 		return NULL;
 
 	return format;
Signature · 1 line
2.21.0
author maintainer
#26 lore raw

PATCH 26/31 perf stat: Reset previous counts on repeat with interval

In reply to Arnaldo Carvalho de Melo

From: Srikar Dronamraju <[email protected]>

When using 'perf stat' with repeat and interval option, it shows wrong values for events.

The wrong values will be shown for the first interval on the second and subsequent repetitions.

Without the fix:

  # perf stat -r 3 -I 2000 -e faults -e sched:sched_switch -a sleep 5
     2.000282489                 53      faults
     2.000282489                513      sched:sched_switch
     4.005478208              3,721      faults
     4.005478208              2,666      sched:sched_switch
     5.025470933                395      faults
     5.025470933              1,307      sched:sched_switch
     2.009602825 1,84,46,74,40,73,70,95,47,520      faults 		<------
     2.009602825 1,84,46,74,40,73,70,95,49,568      sched:sched_switch  <------
     4.019612206              4,730      faults
     4.019612206              2,746      sched:sched_switch
     5.039615484              3,953      faults
     5.039615484              1,496      sched:sched_switch
     2.000274620 1,84,46,74,40,73,70,95,47,520      faults		<------
     2.000274620 1,84,46,74,40,73,70,95,47,520      sched:sched_switch	<------
     4.000480342              4,282      faults
     4.000480342              2,303      sched:sched_switch
     5.000916811              1,322      faults
     5.000916811              1,064      sched:sched_switch

#

prev_raw_counts is allocated when using intervals. This is used when calculating the difference in the counts of events when using interval.

The current counts are stored in prev_raw_counts to calculate the differences in the next iteration.

On the first interval of the second and subsequent repetitions, prev_raw_counts would be the values stored in the last interval of the previous repetitions, while the current counts will only be for the first interval of the current repetition.

Hence there is a possibility of events showing up as big number.

Fix this by resetting prev_raw_counts whenever perf stat repeats the command.

With the fix:

  # perf stat -r 3 -I 2000 -e faults -e sched:sched_switch -a sleep 5
     2.019349347              2,597      faults
     2.019349347              2,753      sched:sched_switch
     4.019577372              3,098      faults
     4.019577372              2,532      sched:sched_switch
     5.019415481              1,879      faults
     5.019415481              1,356      sched:sched_switch
     2.000178813              8,468      faults
     2.000178813              2,254      sched:sched_switch
     4.000404621              7,440      faults
     4.000404621              1,266      sched:sched_switch
     5.040196079              2,458      faults
     5.040196079                556      sched:sched_switch
     2.000191939              6,870      faults
     2.000191939              1,170      sched:sched_switch
     4.000414103                541      faults
     4.000414103                902      sched:sched_switch
     5.000809863                450      faults
     5.000809863                364      sched:sched_switch

#

Committer notes:

This was broken since the cset introducing the --interval feature, i.e. --repeat + --interval wasn't tested at that point, add the Fixes tag so that automatic scripts can pick this up.

Fixes 13370a9b5bb8 ("perf stat: Add interval printing")
Cc Namhyung Kim <[email protected]>
Cc Naveen N. Rao <[email protected]>
Cc Stephane Eranian <[email protected]>
[ Fixed up conflicts with libperf, i.e. some perf_{evsel,evlist} lost the 'perf' prefix ]
---
 tools/perf/builtin-stat.c |  3 +++
 tools/perf/util/stat.c    | 17 +++++++++++++++++
 tools/perf/util/stat.h    |  1 +
 3 files changed, 21 insertions(+)
tools/perf/builtin-stat.c +3 -0
index eece3d1e429a..fa4b148ecfca 100644
@@ -1952,6 +1952,9 @@ int cmd_stat(int argc, const char **argv)
 			fprintf(output, "[ perf stat: executing run #%d ... ]\n",
 				run_idx + 1);
 
+		if (run_idx != 0)
+			perf_evlist__reset_prev_raw_counts(evsel_list);
+
 		status = run_perf_stat(argc, argv, run_idx);
 		if (forever && status != -1) {
 			print_counters(NULL, argc, argv);
tools/perf/util/stat.c +17 -0
index 06571209cb0b..fcd54342c04c 100644
@@ -162,6 +162,15 @@ static void perf_evsel__free_prev_raw_counts(struct evsel *evsel)
 	evsel->prev_raw_counts = NULL;
 }
 
+static void perf_evsel__reset_prev_raw_counts(struct evsel *evsel)
+{
+	if (evsel->prev_raw_counts) {
+		evsel->prev_raw_counts->aggr.val = 0;
+		evsel->prev_raw_counts->aggr.ena = 0;
+		evsel->prev_raw_counts->aggr.run = 0;
+       }
+}
+
 static int perf_evsel__alloc_stats(struct evsel *evsel, bool alloc_raw)
 {
 	int ncpus = perf_evsel__nr_cpus(evsel);
@@ -212,6 +221,14 @@ void perf_evlist__reset_stats(struct evlist *evlist)
 	}
 }
 
+void perf_evlist__reset_prev_raw_counts(struct evlist *evlist)
+{
+	struct evsel *evsel;
+
+	evlist__for_each_entry(evlist, evsel)
+		perf_evsel__reset_prev_raw_counts(evsel);
+}
+
 static void zero_per_pkg(struct evsel *counter)
 {
 	if (counter->per_pkg_mask)
tools/perf/util/stat.h +1 -0
index 0f9c9f6e2041..edbeb2f63e8d 100644
@@ -193,6 +193,7 @@ void perf_stat__collect_metric_expr(struct evlist *);
 int perf_evlist__alloc_stats(struct evlist *evlist, bool alloc_raw);
 void perf_evlist__free_stats(struct evlist *evlist);
 void perf_evlist__reset_stats(struct evlist *evlist);
+void perf_evlist__reset_prev_raw_counts(struct evlist *evlist);
 
 int perf_stat_process_counter(struct perf_stat_config *config,
 			      struct evsel *counter);
Signature · 1 line
2.21.0

A message that is not in the archive (sent off-list or not yet received): [email protected]

#28 lore raw

Re: [PATCH 26/31] perf stat: Reset previous counts on repeat with interval

Hi Sasha, Arnaldo.

Between v5.2.16 and acme HEAD, struct perf_evlist to struct evlist and struct perf_evsel to struct evsel.

However the patches that I had posted
http://lkml.kernel.org/r/[email protected]
would apply cleanly to v5.2.16.

I would like to check if the backports to v5.2.16 should be the same patch (i.e include dependencies including struct renames) or is it okay to apply without the dependencies. Please advise.

Because the renames affected a lot of files, it throws up a lot of commits as dependencies. So I would wait for your inputs before I start with the work.

--
Thanks and Regards
Srikar

Quoted 12 lines

The bot has tested the following trees: v5.2.16, v4.19.74, v4.14.145, v4.9.193, v4.4.193.

v5.2.16: Failed to apply! Possible dependencies:
1c839a5a4061 ("perf cs-etm: Configure timestamp generation in CPU-wide mode") 32dcd021d004 ("perf evsel: Rename struct perf_evsel to struct evsel") 3399ad9ac234 ("perf cs-etm: Configure contextID tracing in CPU-wide mode") acae8b36cded ("perf header: Add die information in CPU topology") b74d8686a18b ("perf cpumap: Retrieve die id information") db5742b6849e ("perf stat: Support per-die aggregation") f854839ba2a5 ("perf cpu_map: Rename struct cpu_map to struct perf_cpu_map")

Signature · 2 lines
Thanks and Regards
Srikar Dronamraju
#29 lore raw

Re: [PATCH 26/31] perf stat: Reset previous counts on repeat with interval

Em Mon, Sep 23, 2019 at 09:58:54PM +0530, Srikar Dronamraju escreveu:

Quoted 9 lines

Hi Sasha, Arnaldo.

Between v5.2.16 and acme HEAD, struct perf_evlist to struct evlist and struct perf_evsel to struct evsel.

However the patches that I had posted
http://lkml.kernel.org/r/[email protected]
would apply cleanly to v5.2.16.

Quoted 7 lines

I would like to check if the backports to v5.2.16 should be the same patch (i.e include dependencies including struct renames) or is it okay to apply without the dependencies. Please advise.

Because the renames affected a lot of files, it throws up a lot of commits as dependencies. So I would wait for your inputs before I start with the work.

Better to not drag the renames, just use the original patch, I think its the best path forward (well, backward :)).

- Arnaldo

Quoted 21 lines

--
Thanks and Regards
Srikar

Quoted 12 lines

The bot has tested the following trees: v5.2.16, v4.19.74, v4.14.145, v4.9.193, v4.4.193.

v5.2.16: Failed to apply! Possible dependencies:
1c839a5a4061 ("perf cs-etm: Configure timestamp generation in CPU-wide mode") 32dcd021d004 ("perf evsel: Rename struct perf_evsel to struct evsel") 3399ad9ac234 ("perf cs-etm: Configure contextID tracing in CPU-wide mode") acae8b36cded ("perf header: Add die information in CPU topology") b74d8686a18b ("perf cpumap: Retrieve die id information") db5742b6849e ("perf stat: Support per-die aggregation") f854839ba2a5 ("perf cpu_map: Rename struct cpu_map to struct perf_cpu_map")

Signature · 2 lines
Thanks and Regards
Srikar Dronamraju
Signature · 1 line
- Arnaldo
#30 lore raw

Re: [PATCH 26/31] perf stat: Reset previous counts on repeat with interval

In reply to a message not in the archive

Hi Sasha,

Quoted 24 lines

This commit has been processed because it contains a "Fixes:" tag, fixing commit: 13370a9b5bb8 perf stat: Add interval printing.

The bot has tested the following trees: v5.2.16, v4.19.74, v4.14.145, v4.9.193, v4.4.193.

v5.2.16: Failed to apply! Possible dependencies:
1c839a5a4061 ("perf cs-etm: Configure timestamp generation in CPU-wide mode") 32dcd021d004 ("perf evsel: Rename struct perf_evsel to struct evsel") 3399ad9ac234 ("perf cs-etm: Configure contextID tracing in CPU-wide mode") acae8b36cded ("perf header: Add die information in CPU topology") b74d8686a18b ("perf cpumap: Retrieve die id information") db5742b6849e ("perf stat: Support per-die aggregation") f854839ba2a5 ("perf cpu_map: Rename struct cpu_map to struct perf_cpu_map")

v4.19.74: Failed to apply! Possible dependencies:
121dd9ea0116 ("perf bench: Add epoll parallel epoll_wait benchmark") 1c839a5a4061 ("perf cs-etm: Configure timestamp generation in CPU-wide mode") 231457ec7074 ("perf bench: Add epoll_ctl(2) benchmark")
32dcd021d004 ("perf evsel: Rename struct perf_evsel to struct evsel") 3399ad9ac234 ("perf cs-etm: Configure contextID tracing in CPU-wide mode") 6ca9a082b190 ("perf stat: Pass a 'struct perf_stat_config' argument to global print functions") 6f6b6594b5f3 ("perf stat: Move *_aggr_* data to 'struct perf_stat_config'") 77e0faf8552c ("perf stat: Pass 'evlist' to aggr_update_shadow()")

Quoted 9 lines

8897a8916efb ("perf stat: Move ru_* data to 'struct perf_stat_config'") ae2d7da554f0 ("perf stat: Pass 'struct perf_stat_config' to first_shadow_cpu()") d97ae04b3d52 ("perf stat: Move 'run_count' to 'struct perf_stat_config'") df4f7b4d4b1e ("perf stat: Move 'unit_width' to 'struct perf_stat_config'") f3ca50e61ff4 ("perf stat: Pass 'struct perf_stat_config' argument to local print functions") f854839ba2a5 ("perf cpu_map: Rename struct cpu_map to struct perf_cpu_map") fa4e819bbca9 ("perf arm cs-etm: Use event attributes to send sink information to kernel") fa7070a38676 ("perf stat: Move csv_* to 'struct perf_stat_config'")

As suggested by Arnaldo, I am adding my patch which applies and builds well on v5.2.16 and v4.14.145. This one differs from the one committed by Arnaldo with respect to structure name change.

Meanwhile I will investigate on v4.14.145 v4.9.193 v4.4.193 and get back to to you.

Signature · 101 lines
Thanks and Regards
Srikar Dronamraju

---->8------------8<-----------------
From b63fd11cced17fcb8e133def29001b0f6aaa5e06 Mon Sep 17 00:00:00 2001
From: Srikar Dronamraju <[email protected]>
Date: Wed, 4 Sep 2019 15:17:37 +0530
Subject: [PATCH 1/2] perf stat: Reset previous counts on repeat with interval

When using 'perf stat' with repeat and interval option, it shows wrong
values for events.

The wrong values will be shown for the first interval on the second and
subsequent repetitions.

Without the fix:

  # perf stat -r 3 -I 2000 -e faults -e sched:sched_switch -a sleep 5

     2.000282489                 53      faults
     2.000282489                513      sched:sched_switch
     4.005478208              3,721      faults
     4.005478208              2,666      sched:sched_switch
     5.025470933                395      faults
     5.025470933              1,307      sched:sched_switch
     2.009602825 1,84,46,74,40,73,70,95,47,520      faults 		<------
     2.009602825 1,84,46,74,40,73,70,95,49,568      sched:sched_switch  <------
     4.019612206              4,730      faults
     4.019612206              2,746      sched:sched_switch
     5.039615484              3,953      faults
     5.039615484              1,496      sched:sched_switch
     2.000274620 1,84,46,74,40,73,70,95,47,520      faults		<------
     2.000274620 1,84,46,74,40,73,70,95,47,520      sched:sched_switch	<------
     4.000480342              4,282      faults
     4.000480342              2,303      sched:sched_switch
     5.000916811              1,322      faults
     5.000916811              1,064      sched:sched_switch
  #

prev_raw_counts is allocated when using intervals. This is used when
calculating the difference in the counts of events when using interval.

The current counts are stored in prev_raw_counts to calculate the
differences in the next iteration.

On the first interval of the second and subsequent repetitions,
prev_raw_counts would be the values stored in the last interval of the
previous repetitions, while the current counts will only be for the
first interval of the current repetition.

Hence there is a possibility of events showing up as big number.

Fix this by resetting prev_raw_counts whenever perf stat repeats the
command.

With the fix:

  # perf stat -r 3 -I 2000 -e faults -e sched:sched_switch -a sleep 5

     2.019349347              2,597      faults
     2.019349347              2,753      sched:sched_switch
     4.019577372              3,098      faults
     4.019577372              2,532      sched:sched_switch
     5.019415481              1,879      faults
     5.019415481              1,356      sched:sched_switch
     2.000178813              8,468      faults
     2.000178813              2,254      sched:sched_switch
     4.000404621              7,440      faults
     4.000404621              1,266      sched:sched_switch
     5.040196079              2,458      faults
     5.040196079                556      sched:sched_switch
     2.000191939              6,870      faults
     2.000191939              1,170      sched:sched_switch
     4.000414103                541      faults
     4.000414103                902      sched:sched_switch
     5.000809863                450      faults
     5.000809863                364      sched:sched_switch
  #

Committer notes:

This was broken since the cset introducing the --interval feature, i.e.
--repeat + --interval wasn't tested at that point, add the Fixes tag so
that automatic scripts can pick this up.

Fixes: 13370a9b5bb8 ("perf stat: Add interval printing")
Signed-off-by: Srikar Dronamraju <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Tested-by: Arnaldo Carvalho de Melo <[email protected]>
Tested-by: Ravi Bangoria <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Naveen N. Rao <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: [email protected] # v3.9+
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
 tools/perf/builtin-stat.c |  3 +++
 tools/perf/util/stat.c    | 17 +++++++++++++++++
 tools/perf/util/stat.h    |  1 +
 3 files changed, 21 insertions(+)
tools/perf/builtin-stat.c +3 -0
index 352cf39d7c2f..eda451842bfd 100644
@@ -1961,6 +1961,9 @@ int cmd_stat(int argc, const char **argv)
 			fprintf(output, "[ perf stat: executing run #%d ... ]\n",
 				run_idx + 1);
 
+		if (run_idx != 0)
+			perf_evlist__reset_prev_raw_counts(evsel_list);
+
 		status = run_perf_stat(argc, argv, run_idx);
 		if (forever && status != -1) {
 			print_counters(NULL, argc, argv);
tools/perf/util/stat.c +17 -0
index db8a6cf336be..773f29d4f6a7 100644
@@ -155,6 +155,15 @@ static void perf_evsel__free_prev_raw_counts(struct perf_evsel *evsel)
 	evsel->prev_raw_counts = NULL;
 }
 
+static void perf_evsel__reset_prev_raw_counts(struct perf_evsel *evsel)
+{
+	if (evsel->prev_raw_counts) {
+		evsel->prev_raw_counts->aggr.val = 0;
+		evsel->prev_raw_counts->aggr.ena = 0;
+		evsel->prev_raw_counts->aggr.run = 0;
+       }
+}
+
 static int perf_evsel__alloc_stats(struct perf_evsel *evsel, bool alloc_raw)
 {
 	int ncpus = perf_evsel__nr_cpus(evsel);
@@ -205,6 +214,14 @@ void perf_evlist__reset_stats(struct perf_evlist *evlist)
 	}
 }
 
+void perf_evlist__reset_prev_raw_counts(struct perf_evlist *evlist)
+{
+	struct perf_evsel *evsel;
+
+	evlist__for_each_entry(evlist, evsel)
+		perf_evsel__reset_prev_raw_counts(evsel);
+}
+
 static void zero_per_pkg(struct perf_evsel *counter)
 {
 	if (counter->per_pkg_mask)
tools/perf/util/stat.h +1 -0
index 0f9c9f6e2041..edbeb2f63e8d 100644
@@ -194,6 +194,7 @@ void perf_stat__collect_metric_expr(struct perf_evlist *);
 int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw);
 void perf_evlist__free_stats(struct perf_evlist *evlist);
 void perf_evlist__reset_stats(struct perf_evlist *evlist);
+void perf_evlist__reset_prev_raw_counts(struct perf_evlist *evlist);
 
 int perf_stat_process_counter(struct perf_stat_config *config,
 			      struct perf_evsel *counter);
Signature · 1 line
2.18.1
author maintainer
#31 lore raw

PATCH 27/31 perf stat: Fix a segmentation fault when using repeat forever

In reply to Arnaldo Carvalho de Melo

From: Srikar Dronamraju <[email protected]>

Observe a segmentation fault when 'perf stat' is asked to repeat forever with the interval option.

Without fix:

  # perf stat -r 0 -I 5000 -e cycles -a sleep 10
  #           time             counts unit events
       5.000211692  3,13,89,82,34,157      cycles
      10.000380119  1,53,98,52,22,294      cycles
      10.040467280       17,16,79,265      cycles
  Segmentation fault

This problem was only observed when we use forever option aka -r 0 and works with limited repeats. Calling print_counter with ts being set to NULL, is not a correct option when interval is set. Hence avoid print_counter(NULL,..) if interval is set.

With fix:

  # perf stat -r 0 -I 5000 -e cycles -a sleep 10
   #           time             counts unit events
       5.019866622  3,15,14,43,08,697      cycles
      10.039865756  3,15,16,31,95,261      cycles
      10.059950628     1,26,05,47,158      cycles
       5.009902655  3,14,52,62,33,932      cycles
      10.019880228  3,14,52,22,89,154      cycles
      10.030543876       66,90,18,333      cycles
       5.009848281  3,14,51,98,25,437      cycles
      10.029854402  3,15,14,93,04,918      cycles
       5.009834177  3,14,51,95,92,316      cycles

Committer notes:

Did the 'git bisect' to find the cset introducing the problem to add the Fixes tag below, and at that time the problem reproduced as:

(gdb) run stat -r0 -I500 sleep 1
<SNIP>
Program received signal SIGSEGV, Segmentation fault.
print_interval (prefix=prefix@entry=0x7fffffffc8d0 "", ts=ts@entry=0x0) at builtin-stat.c:866
866 sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, csv_sep);
(gdb) bt

  #0  print_interval (prefix=prefix@entry=0x7fffffffc8d0 "", ts=ts@entry=0x0) at builtin-stat.c:866
  #1  0x000000000041860a in print_counters (ts=ts@entry=0x0, argc=argc@entry=2, argv=argv@entry=0x7fffffffd640) at builtin-stat.c:938
  #2  0x0000000000419a7f in cmd_stat (argc=2, argv=0x7fffffffd640, prefix=<optimized out>) at builtin-stat.c:1411
  #3  0x000000000045c65a in run_builtin (p=p@entry=0x6291b8 <commands+216>, argc=argc@entry=5, argv=argv@entry=0x7fffffffd640) at perf.c:370
  #4  0x000000000045c893 in handle_internal_command (argc=5, argv=0x7fffffffd640) at perf.c:429
  #5  0x000000000045c8f1 in run_argv (argcp=argcp@entry=0x7fffffffd4ac, argv=argv@entry=0x7fffffffd4a0) at perf.c:473
  #6  0x000000000045cac9 in main (argc=<optimized out>, argv=<optimized out>) at perf.c:588

(gdb)

Mostly the same as just before this patch:

Program received signal SIGSEGV, Segmentation fault.
0x00000000005874a7 in print_interval (config=0xa1f2a0 <stat_config>, evlist=0xbc9b90, prefix=0x7fffffffd1c0 "`", ts=0x0) at util/stat-display.c:964
964 sprintf(prefix, "%6lu.%09lu%s", ts->tv_sec, ts->tv_nsec, config->csv_sep);
(gdb) bt
#0 0x00000000005874a7 in print_interval (config=0xa1f2a0 <stat_config>, evlist=0xbc9b90, prefix=0x7fffffffd1c0 "`", ts=0x0) at util/stat-display.c:964 #1 0x0000000000588047 in perf_evlist__print_counters (evlist=0xbc9b90, config=0xa1f2a0 <stat_config>, _target=0xa1f0c0 <target>, ts=0x0, argc=2, argv=0x7fffffffd670)

      at util/stat-display.c:1172
  #2  0x000000000045390f in print_counters (ts=0x0, argc=2, argv=0x7fffffffd670) at builtin-stat.c:656
  #3  0x0000000000456bb5 in cmd_stat (argc=2, argv=0x7fffffffd670) at builtin-stat.c:1960
  #4  0x00000000004dd2e0 in run_builtin (p=0xa30e00 <commands+288>, argc=5, argv=0x7fffffffd670) at perf.c:310
  #5  0x00000000004dd54d in handle_internal_command (argc=5, argv=0x7fffffffd670) at perf.c:362
  #6  0x00000000004dd694 in run_argv (argcp=0x7fffffffd4cc, argv=0x7fffffffd4c0) at perf.c:406
  #7  0x00000000004dda11 in main (argc=5, argv=0x7fffffffd670) at perf.c:531
  (gdb)
---
 tools/perf/builtin-stat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-stat.c +1 -1
index fa4b148ecfca..60cdd383af81 100644
@@ -1956,7 +1956,7 @@ int cmd_stat(int argc, const char **argv)
 			perf_evlist__reset_prev_raw_counts(evsel_list);
 
 		status = run_perf_stat(argc, argv, run_idx);
-		if (forever && status != -1) {
+		if (forever && status != -1 && !interval) {
 			print_counters(NULL, argc, argv);
 			perf_stat__reset_stats();
 		}
Signature · 1 line
2.21.0
author maintainer
#32 lore raw

PATCH 28/31 perf test: Fix spelling mistake "allos" -> "allocate"

In reply to Arnaldo Carvalho de Melo

From: Colin Ian King <[email protected]>

There is a spelling mistake in a TEST_ASSERT_VAL message. Fix it.

---
 tools/perf/tests/event_update.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/event_update.c +1 -1
index 4bb772e2b73d..0497d900ced2 100644
@@ -94,7 +94,7 @@ int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unu
 
 	evsel = perf_evlist__first(evlist);
 
-	TEST_ASSERT_VAL("failed to allos ids",
+	TEST_ASSERT_VAL("failed to allocate ids",
 			!perf_evsel__alloc_id(evsel, 1, 1));
 
 	perf_evlist__id_add(evlist, evsel, 0, 0, 123);
Signature · 1 line
2.21.0
author maintainer
#33 lore raw

PATCH 29/31 perf kvm: Move kvm-stat header file from conditional inclusion to common include section

In reply to Arnaldo Carvalho de Melo

From: Anju T Sudhakar <[email protected]>

Move kvm-stat header file to the common include section, and make the definitions in the header file under the conditional inclusion #ifdef HAVE_KVM_STAT_SUPPORT.

This helps to define other 'perf kvm' related function prototypes in kvm-stat header file, which may not need kvm-stat support.

---
 tools/perf/builtin-kvm.c   | 2 +-
 tools/perf/util/kvm-stat.h | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
tools/perf/builtin-kvm.c +1 -1
index ac6d6e061dc5..2b822be87673 100644
@@ -21,6 +21,7 @@
 #include "util/top.h"
 #include "util/data.h"
 #include "util/ordered-events.h"
+#include "util/kvm-stat.h"
 #include "ui/ui.h"
 
 #include <sys/prctl.h>
@@ -59,7 +60,6 @@ static const char *get_filename_for_perf_kvm(void)
 }
 
 #ifdef HAVE_KVM_STAT_SUPPORT
-#include "util/kvm-stat.h"
 
 void exit_event_get_key(struct evsel *evsel,
 			struct perf_sample *sample,
tools/perf/util/kvm-stat.h +3 -0
index 46913637085b..8fd6ec20662c 100644
@@ -2,6 +2,8 @@
 #ifndef __PERF_KVM_STAT_H
 #define __PERF_KVM_STAT_H
 
+#ifdef HAVE_KVM_STAT_SUPPORT
+
 #include "tool.h"
 #include "stat.h"
 #include "record.h"
@@ -144,5 +146,6 @@ extern const int decode_str_len;
 extern const char *kvm_exit_reason;
 extern const char *kvm_entry_trace;
 extern const char *kvm_exit_trace;
+#endif /* HAVE_KVM_STAT_SUPPORT */
 
 #endif /* __PERF_KVM_STAT_H */
Signature · 1 line
2.21.0
author maintainer
#34 lore raw

PATCH 30/31 perf kvm: Add arch neutral function to choose event for perf kvm record

In reply to Arnaldo Carvalho de Melo

From: Anju T Sudhakar <[email protected]>

'perf kvm record' uses 'cycles'(if the user did not specify any event) as the default event to profile the guest.

This will not provide any proper samples from the guest incase of powerpc architecture, since in powerpc the PMUs are controlled by the guest rather than the host.

Patch adds a function to pick an arch specific event for 'perf kvm record', instead of selecting 'cycles' as a default event for all architectures.

For powerpc this function checks for any user specified event, and if there isn't any it returns invalid instead of proceeding with 'cycles' event.

---
 tools/perf/arch/powerpc/util/kvm-stat.c | 37 +++++++++++++++++++++++++
 tools/perf/builtin-kvm.c                | 12 +++++++-
 tools/perf/util/kvm-stat.h              |  1 +
 3 files changed, 49 insertions(+), 1 deletion(-)
tools/perf/arch/powerpc/util/kvm-stat.c +37 -0
index f0dbf7b075c8..ec5b771029e4 100644
@@ -8,6 +8,7 @@
 
 #include "book3s_hv_exits.h"
 #include "book3s_hcalls.h"
+#include <subcmd/parse-options.h>
 
 #define NR_TPS 4
 
@@ -172,3 +173,39 @@ int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid __maybe_unused)
 
 	return ret;
 }
+
+/*
+ * Incase of powerpc architecture, pmu registers are programmable
+ * by guest kernel. So monitoring guest via host may not provide
+ * valid samples. It is better to fail the "perf kvm record"
+ * with default "cycles" event to monitor guest in powerpc.
+ *
+ * Function to parse the arguments and return appropriate values.
+ */
+int kvm_add_default_arch_event(int *argc, const char **argv)
+{
+	const char **tmp;
+	bool event = false;
+	int i, j = *argc;
+
+	const struct option event_options[] = {
+		OPT_BOOLEAN('e', "event", &event, NULL),
+		OPT_END()
+	};
+
+	tmp = calloc(j + 1, sizeof(char *));
+	if (!tmp)
+		return -EINVAL;
+
+	for (i = 0; i < j; i++)
+		tmp[i] = argv[i];
+
+	parse_options(j, tmp, event_options, NULL, PARSE_OPT_KEEP_UNKNOWN);
+	if (!event) {
+		free(tmp);
+		return -EINVAL;
+	}
+
+	free(tmp);
+	return 0;
+}
tools/perf/builtin-kvm.c +11 -1
index 2b822be87673..6e3e36658900 100644
@@ -1514,11 +1514,21 @@ static int kvm_cmd_stat(const char *file_name, int argc, const char **argv)
 }
 #endif /* HAVE_KVM_STAT_SUPPORT */
 
+int __weak kvm_add_default_arch_event(int *argc __maybe_unused,
+					const char **argv __maybe_unused)
+{
+	return 0;
+}
+
 static int __cmd_record(const char *file_name, int argc, const char **argv)
 {
-	int rec_argc, i = 0, j;
+	int rec_argc, i = 0, j, ret;
 	const char **rec_argv;
 
+	ret = kvm_add_default_arch_event(&argc, argv);
+	if (ret)
+		return -EINVAL;
+
 	rec_argc = argc + 2;
 	rec_argv = calloc(rec_argc + 1, sizeof(char *));
 	rec_argv[i++] = strdup("record");
tools/perf/util/kvm-stat.h +1 -0
index 8fd6ec20662c..6f0fa05b62b6 100644
@@ -148,4 +148,5 @@ extern const char *kvm_entry_trace;
 extern const char *kvm_exit_trace;
 #endif /* HAVE_KVM_STAT_SUPPORT */
 
+extern int kvm_add_default_arch_event(int *argc, const char **argv);
 #endif /* __PERF_KVM_STAT_H */
Signature · 1 line
2.21.0
author maintainer
#35 lore raw

PATCH 31/31 perf kvm stat: Set 'trace_cycles' as default event for 'perf kvm record' in powerpc

In reply to Arnaldo Carvalho de Melo

From: Anju T Sudhakar <[email protected]>

Use 'trace_imc/trace_cycles' as the default event for 'perf kvm record' in powerpc.

Cc Alexander Shishkin <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Madhavan Srinivasan <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
[ Add missing pmu.h header, needed because this patch uses pmu_have_event() ]
---
 tools/perf/arch/powerpc/util/kvm-stat.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
tools/perf/arch/powerpc/util/kvm-stat.c +12 -4
index ec5b771029e4..9cc1c4a9dec4 100644
@@ -5,6 +5,7 @@
 #include "util/debug.h"
 #include "util/evsel.h"
 #include "util/evlist.h"
+#include "util/pmu.h"
 
 #include "book3s_hv_exits.h"
 #include "book3s_hcalls.h"
@@ -177,8 +178,9 @@ int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid __maybe_unused)
 /*
  * Incase of powerpc architecture, pmu registers are programmable
  * by guest kernel. So monitoring guest via host may not provide
- * valid samples. It is better to fail the "perf kvm record"
- * with default "cycles" event to monitor guest in powerpc.
+ * valid samples with default 'cycles' event. It is better to use
+ * 'trace_imc/trace_cycles' event for guest profiling, since it
+ * can track the guest instruction pointer in the trace-record.
  *
  * Function to parse the arguments and return appropriate values.
  */
@@ -202,8 +204,14 @@ int kvm_add_default_arch_event(int *argc, const char **argv)
 
 	parse_options(j, tmp, event_options, NULL, PARSE_OPT_KEEP_UNKNOWN);
 	if (!event) {
-		free(tmp);
-		return -EINVAL;
+		if (pmu_have_event("trace_imc", "trace_cycles")) {
+			argv[j++] = strdup("-e");
+			argv[j++] = strdup("trace_imc/trace_cycles/");
+			*argc += 2;
+		} else {
+			free(tmp);
+			return -EINVAL;
+		}
 	}
 
 	free(tmp);
Signature · 1 line
2.21.0
#36 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 309 lines · Arnaldo Carvalho de Melo

Hi Ingo/Thomas,

Please consider pulling,

Best regards,

- Arnaldo

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

The following changes since commit e336b4027775cb458dc713745e526fa1a1996b2a:

kprobes: Prohibit probing on BUG() and WARN() address (2019-09-05 10:15:16 +0200)

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.4-20190920-2

for you to fetch changes up to 2bff2b828502b5e5d5ea5a52643d3542053df03f:

perf kvm stat: Set 'trace_cycles' as default event for 'perf kvm record' in powerpc (2019-09-20 10:28:26 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

perf stat:

Srikar Dronamraju:

- Fix a segmentation fault when using repeat forever.

- Reset previous counts on repeat with interval.

aarch64:

James Clark:

- Add PMU event JSON files for Cortex-A76 and Neoverse N1.

PowerPC:

Anju T Sudhakar:

- Make 'trace_cycles' the default event for 'perf kvm record' in PowerPC.

S/390:

- Link libjvmti to tools/lib/string.o to have a weak strlcpy() implementation, providing previously unresolved symbol on s/390.

perf test:

Jiri Olsa:

- Add libperf automated tests to 'make -C tools/perf build-test'.

Colin Ian King:

- Fix spelling mistake.

Tree wide:

Arnaldo Carvalho de Melo:

- Some more header file sanitization.

libperf:

Jiri Olsa:

- Add dependency on libperf for python.so binding.

libtraceevent:

Sakari Ailus:

- Convert remaining %p[fF] users to %p[sS].

----------------------------------------------------------------
Anju T Sudhakar (3):
perf kvm: Move kvm-stat header file from conditional inclusion to common include section perf kvm: Add arch neutral function to choose event for perf kvm record perf kvm stat: Set 'trace_cycles' as default event for 'perf kvm record' in powerpc

Arnaldo Carvalho de Melo (19):
perf jvmti: Link against tools/lib/string.o to have weak strlcpy() perf tools: Remove needless builtin.h include directives perf debug: No need to include ui/util.h
perf tools: Remove debug.h from places where it is not needed perf tools: Remove util.h from where it is not needed perf probe: Add missing build-id.h header.
perf symbols: Add missing dso.h header
perf env: Remove needless cpumap.h header
perf event: Move perf_event__synthesize* to event.h perf stat: Move perf_stat_synthesize_config() to event.h perf callchain: Remove needless event.h include
perf python: Remove debug.h
perf hist: Add missing 'struct branch_stack' forward declaration perf annotate: Add missing machine.h include directive perf sched: Add missing event.h include directive
perf auxtrace: Add missing 'struct perf_sample' forward declaration perf tools: Move event synthesizing routines to separate header perf memswap: Adopt 'struct u64_swap' from evsel.h
perf tools: Move event synthesizing routines to separate .c file

Colin Ian King (1):

      perf test: Fix spelling mistake "allos" -> "allocate"

James Clark (1):
perf tools: Add PMU event JSON files for ARM Cortex-A76 and, Neoverse N1.

Jiri Olsa (4):
perf python: Add missing python/perf.so dependency for libperf perf tests: Add libperf automated test for 'make -C tools/perf build-test'
libperf: Add missing event.h file to install rule
libperf: Adopt perf_cpu_map__max() function

Sakari Ailus (1):
tools lib traceevent: Convert remaining %p[fF] users to %p[sS]

Srikar Dronamraju (2):
perf stat: Reset previous counts on repeat with interval perf stat: Fix a segmentation fault when using repeat forever

 .../Documentation/libtraceevent-func_apis.txt      |   10 +-
 tools/lib/traceevent/event-parse.c                 |   18 +-
 tools/perf/Makefile.perf                           |    2 +-
 tools/perf/arch/arm/util/cs-etm.c                  |    2 +-
 tools/perf/arch/arm64/util/arm-spe.c               |    2 +-
 tools/perf/arch/arm64/util/dwarf-regs.c            |    1 -
 tools/perf/arch/arm64/util/header.c                |    4 +-
 tools/perf/arch/arm64/util/unwind-libunwind.c      |    2 +-
 tools/perf/arch/powerpc/util/dwarf-regs.c          |    1 -
 tools/perf/arch/powerpc/util/header.c              |    1 -
 tools/perf/arch/powerpc/util/kvm-stat.c            |   45 +
 tools/perf/arch/powerpc/util/skip-callchain-idx.c  |    1 +
 tools/perf/arch/powerpc/util/sym-handling.c        |    1 -
 tools/perf/arch/s390/util/machine.c                |    2 +-
 tools/perf/arch/x86/tests/intel-cqm.c              |    1 -
 tools/perf/arch/x86/tests/perf-time-to-tsc.c       |    1 -
 tools/perf/arch/x86/tests/rdpmc.c                  |    2 +-
 tools/perf/arch/x86/util/archinsn.c                |    1 +
 tools/perf/arch/x86/util/event.c                   |    2 +
 tools/perf/arch/x86/util/intel-bts.c               |    2 +-
 tools/perf/arch/x86/util/intel-pt.c                |    2 +-
 tools/perf/arch/x86/util/machine.c                 |    3 +-
 tools/perf/arch/x86/util/tsc.c                     |    2 +
 tools/perf/bench/epoll-ctl.c                       |    2 +-
 tools/perf/bench/epoll-wait.c                      |    2 +-
 tools/perf/bench/futex-hash.c                      |    2 +-
 tools/perf/bench/futex-lock-pi.c                   |    2 +-
 tools/perf/bench/futex-requeue.c                   |    2 +-
 tools/perf/bench/futex-wake-parallel.c             |    3 +-
 tools/perf/bench/futex-wake.c                      |    2 +-
 tools/perf/bench/numa.c                            |    1 -
 tools/perf/bench/sched-messaging.c                 |    2 -
 tools/perf/bench/sched-pipe.c                      |    2 -
 tools/perf/builtin-annotate.c                      |    1 +
 tools/perf/builtin-c2c.c                           |    1 +
 tools/perf/builtin-config.c                        |    1 -
 tools/perf/builtin-evlist.c                        |    2 -
 tools/perf/builtin-inject.c                        |    1 +
 tools/perf/builtin-kvm.c                           |   15 +-
 tools/perf/builtin-record.c                        |   10 +-
 tools/perf/builtin-report.c                        |    2 +-
 tools/perf/builtin-sched.c                         |    3 +
 tools/perf/builtin-stat.c                          |   24 +-
 tools/perf/builtin-top.c                           |    1 +
 tools/perf/builtin-trace.c                         |    1 +
 tools/perf/jvmti/Build                             |    9 +
 tools/perf/lib/Makefile                            |    1 +
 tools/perf/lib/cpumap.c                            |   12 +
 tools/perf/lib/include/perf/cpumap.h               |    1 +
 tools/perf/lib/libperf.map                         |    1 +
 tools/perf/perf.c                                  |    2 +-
 .../arch/arm64/arm/cortex-a76-n1/branch.json       |   14 +
 .../arch/arm64/arm/cortex-a76-n1/bus.json          |   24 +
 .../arch/arm64/arm/cortex-a76-n1/cache.json        |  207 +++
 .../arch/arm64/arm/cortex-a76-n1/exception.json    |   52 +
 .../arch/arm64/arm/cortex-a76-n1/instruction.json  |  108 ++
 .../arch/arm64/arm/cortex-a76-n1/memory.json       |   23 +
 .../arch/arm64/arm/cortex-a76-n1/other.json        |    7 +
 .../arch/arm64/arm/cortex-a76-n1/pipeline.json     |   14 +
 tools/perf/pmu-events/arch/arm64/mapfile.csv       |    2 +
 tools/perf/tests/bitmap.c                          |    2 +-
 tools/perf/tests/clang.c                           |    2 -
 tools/perf/tests/code-reading.c                    |    2 +-
 tools/perf/tests/cpumap.c                          |    1 +
 tools/perf/tests/dso-data.c                        |    1 -
 tools/perf/tests/dwarf-unwind.c                    |    1 +
 tools/perf/tests/event-times.c                     |    1 -
 tools/perf/tests/event_update.c                    |    4 +-
 tools/perf/tests/hists_common.c                    |    2 +
 tools/perf/tests/keep-tracking.c                   |    3 +-
 tools/perf/tests/llvm.c                            |    1 -
 tools/perf/tests/make                              |    6 +-
 tools/perf/tests/mem2node.c                        |    2 +-
 tools/perf/tests/mmap-basic.c                      |    3 +-
 tools/perf/tests/mmap-thread-lookup.c              |    4 +-
 tools/perf/tests/openat-syscall-all-cpus.c         |    5 +-
 tools/perf/tests/parse-events.c                    |    1 -
 tools/perf/tests/parse-no-sample-id-all.c          |    2 -
 tools/perf/tests/perf-hooks.c                      |    1 -
 tools/perf/tests/pmu.c                             |    1 -
 tools/perf/tests/sample-parsing.c                  |    2 +-
 tools/perf/tests/stat.c                            |    1 +
 tools/perf/tests/switch-tracking.c                 |    1 -
 tools/perf/tests/task-exit.c                       |    2 +-
 tools/perf/tests/thread-map.c                      |    1 +
 tools/perf/tests/topology.c                        |    2 +-
 tools/perf/tests/vmlinux-kallsyms.c                |    2 +-
 tools/perf/ui/browser.c                            |    1 -
 tools/perf/ui/browsers/annotate.c                  |    1 -
 tools/perf/ui/browsers/header.c                    |    1 -
 tools/perf/ui/browsers/map.c                       |    1 -
 tools/perf/ui/browsers/res_sample.c                |    2 +-
 tools/perf/ui/browsers/scripts.c                   |    3 +-
 tools/perf/ui/gtk/helpline.c                       |    1 -
 tools/perf/ui/gtk/progress.c                       |    1 -
 tools/perf/ui/gtk/setup.c                          |    3 +-
 tools/perf/ui/gtk/util.c                           |    1 -
 tools/perf/ui/helpline.c                           |    2 -
 tools/perf/ui/hist.c                               |    1 -
 tools/perf/ui/setup.c                              |    2 +-
 tools/perf/ui/stdio/hist.c                         |    1 +
 tools/perf/ui/tui/helpline.c                       |    1 -
 tools/perf/ui/tui/setup.c                          |    2 +-
 tools/perf/ui/tui/util.c                           |    1 -
 tools/perf/util/Build                              |    1 +
 tools/perf/util/annotate.c                         |    2 +-
 tools/perf/util/arm-spe.c                          |    1 -
 tools/perf/util/auxtrace.c                         |    6 +-
 tools/perf/util/auxtrace.h                         |   18 +-
 tools/perf/util/bpf-event.c                        |    1 +
 tools/perf/util/bpf-event.h                        |   15 +-
 tools/perf/util/branch.c                           |    2 -
 tools/perf/util/branch.h                           |    9 +-
 tools/perf/util/build-id.c                         |    2 +-
 tools/perf/util/callchain.c                        |    1 +
 tools/perf/util/callchain.h                        |    5 +-
 tools/perf/util/cloexec.c                          |    2 +-
 tools/perf/util/cs-etm-decoder/cs-etm-decoder.c    |    1 -
 tools/perf/util/cs-etm.c                           |    2 +-
 tools/perf/util/data.c                             |    3 +-
 tools/perf/util/debug.c                            |    1 -
 tools/perf/util/debug.h                            |    2 +-
 tools/perf/util/demangle-java.c                    |    1 -
 tools/perf/util/demangle-rust.c                    |    1 -
 tools/perf/util/dwarf-regs.c                       |    1 -
 tools/perf/util/env.h                              |    3 +-
 tools/perf/util/event.c                            | 1109 +-----------
 tools/perf/util/event.h                            |   77 +-
 tools/perf/util/evlist.c                           |    2 +-
 tools/perf/util/evsel.c                            |  280 +--
 tools/perf/util/evsel.h                            |    5 -
 tools/perf/util/evsel_fprintf.c                    |    1 +
 tools/perf/util/header.c                           |  395 +---
 tools/perf/util/header.h                           |   60 +-
 tools/perf/util/hist.h                             |    1 +
 tools/perf/util/intel-bts.c                        |    2 +-
 tools/perf/util/intel-pt.c                         |    1 +
 tools/perf/util/jitdump.c                          |    2 -
 tools/perf/util/kvm-stat.h                         |    4 +
 tools/perf/util/libunwind/arm64.c                  |    1 -
 tools/perf/util/libunwind/x86_32.c                 |    1 -
 tools/perf/util/llvm-utils.c                       |    1 +
 tools/perf/util/lzma.c                             |    2 +-
 tools/perf/util/machine.c                          |   15 -
 tools/perf/util/machine.h                          |   15 -
 tools/perf/util/memswap.h                          |    7 +
 tools/perf/util/namespaces.c                       |   18 +
 tools/perf/util/namespaces.h                       |    2 +
 tools/perf/util/parse-events.c                     |    1 -
 tools/perf/util/perf-hooks.c                       |    1 -
 tools/perf/util/pmu.c                              |    1 -
 tools/perf/util/probe-file.c                       |    1 +
 tools/perf/util/python.c                           |    4 +-
 tools/perf/util/record.c                           |    2 -
 tools/perf/util/rwsem.c                            |    1 +
 tools/perf/util/s390-cpumsf.c                      |    1 -
 tools/perf/util/s390-sample-raw.c                  |    1 -
 .../util/scripting-engines/trace-event-python.c    |    2 -
 tools/perf/util/session.c                          |   72 +-
 tools/perf/util/session.h                          |    5 -
 tools/perf/util/srccode.c                          |    2 +-
 tools/perf/util/stat.c                             |   60 +-
 tools/perf/util/stat.h                             |    9 +-
 tools/perf/util/svghelper.c                        |    2 +-
 tools/perf/util/symbol-elf.c                       |    3 +
 tools/perf/util/symbol-minimal.c                   |    3 +-
 tools/perf/util/symbol.c                           |    2 +-
 tools/perf/util/synthetic-events.c                 | 1884 ++++++++++++++++++++
 tools/perf/util/synthetic-events.h                 |  103 ++
 tools/perf/util/target.c                           |    2 -
 tools/perf/util/top.c                              |    1 -
 tools/perf/util/trace-event-info.c                 |    2 +-
 tools/perf/util/trace-event-read.c                 |    1 -
 tools/perf/util/trace-event.c                      |    1 -
 tools/perf/util/tsc.h                              |   14 +-
 tools/perf/util/unwind-libdw.c                     |    1 -
 tools/perf/util/unwind-libunwind-local.c           |    1 -
 tools/perf/util/usage.c                            |    1 -
 tools/perf/util/vdso.c                             |    2 +-
 tools/perf/util/zlib.c                             |    4 +-
 180 files changed, 2763 insertions(+), 2256 deletions(-)
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/branch.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/bus.json
Quoted 8 lines
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/cache.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/exception.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/instruction.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/memory.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/other.json
 create mode 100644 tools/perf/pmu-events/arch/arm64/arm/cortex-a76-n1/pipeline.json
 create mode 100644 tools/perf/util/synthetic-events.c
 create mode 100644 tools/perf/util/synthetic-events.h

Pulled, thanks a lot Arnaldo!

Ingo