Skip to contentSkip to conversation

perf/core improvements and fixes

GIT PULL New Arnaldo Carvalho de Melo 2 participants 27 messages Aug 22, 2019 – Aug 23, 2019

Subsystems (3)
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 4e92b18e5b0b61211f4511cdbc5803300eeead40:

Merge tag 'perf-core-for-mingo-5.4-20190820' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2019-08-20 21:38:22 +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-20190822

for you to fetch changes up to d9c5c083416500e95da098c01be092b937def7fa:

libperf: Fix alignment trap with xyarray contents in 'perf stat' (2019-08-22 17:16:57 -0300)

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

perf c2c:

Ravi Bangoria:

- Fix report with offline cpus.

libperf:

Gerald BAEZA:

- Fix alignment trap with xyarray contents in 'perf stat', noticed on ARMv7.

Jiri Olsa:

- Move some more cpu_map and thread_map methods from tools/perf/util/ to libperf.

headers:

Arnaldo Carvalho de Melo:

- Do some house cleaning on the headers, removing needless includes in some places, providing forward declarations when those are the only thing needed, and fixing up the fallout from that for cases where we were using stuff and not adding the necessary headers. Should speed up the build and avoid needless rebuilds when something unrelated gets touched.

----------------------------------------------------------------
Arnaldo Carvalho de Melo (18):
perf arm64: Add missing debug.h header
perf kvm s390: Add missing string.h header
perf metricgroup: Remove needless includes from metricgroup.h perf evsel: Move xyarray.h from evsel.c to evsel.h to reduce include dep tree perf counts: Add missing headers needed for types used
perf bpf: Add missing xyarray.h header
perf evlist: Add missing xyarray.h header
perf script: Add missing counts.h
perf tests: Add missing counts.h
perf stat: Add missing counts.h
perf scripting python: Add missing counts.h header
perf evsel: Add missing perf/evsel.h header in util/evsel.h
perf evsel: Remove needless counts.h header from util/evsel.h perf evsel: Remove needless stddef.h from util/evsel.h
perf evsel: util/evsel.h needs stdio.h as it uses FILE
perf x86 kvm-stat: Add missing string.h header
perf evsel: Switch to libperf's cpumap.h
perf cpumap: Remove needless includes from cpumap.h

Gerald BAEZA (1):
libperf: Fix alignment trap with xyarray contents in 'perf stat'

Jiri Olsa (5):
tools headers: Add missing perf_event.h include
perf tools: Use perf_cpu_map__nr instead of cpu_map__nr
libperf: Move perf's cpu_map__empty() to perf_cpu_map__empty()
libperf: Move perf's cpu_map__idx() to perf_cpu_map__idx()
libperf: Add perf_thread_map__nr/perf_thread_map__pid functions

Ravi Bangoria (1):
perf c2c: Fix report with offline cpus

 tools/include/linux/ring_buffer.h                  |  1 +
 tools/perf/arch/arm/util/cs-etm.c                  | 12 ++++----
 tools/perf/arch/arm64/util/header.c                |  1 +
 tools/perf/arch/s390/util/kvm-stat.c               |  1 +
 tools/perf/arch/x86/util/header.c                  |  1 +
 tools/perf/arch/x86/util/intel-bts.c               |  4 +--
 tools/perf/arch/x86/util/intel-pt.c                | 10 +++----
 tools/perf/arch/x86/util/kvm-stat.c                |  1 +
 tools/perf/builtin-c2c.c                           |  4 +--
 tools/perf/builtin-ftrace.c                        |  2 +-
 tools/perf/builtin-script.c                        |  5 ++--
 tools/perf/builtin-stat.c                          |  8 +++---
 tools/perf/builtin-trace.c                         |  4 +--
 tools/perf/lib/cpumap.c                            | 17 ++++++++++++
 tools/perf/lib/include/internal/cpumap.h           |  2 ++
 tools/perf/lib/include/internal/xyarray.h          |  3 +-
 tools/perf/lib/include/perf/cpumap.h               |  2 ++
 tools/perf/lib/include/perf/threadmap.h            |  2 ++
 tools/perf/lib/libperf.map                         |  3 ++
 tools/perf/lib/threadmap.c                         | 10 +++++++
 tools/perf/tests/mem2node.c                        |  1 +
 tools/perf/tests/openat-syscall-all-cpus.c         |  1 +
 tools/perf/tests/openat-syscall.c                  |  1 +
 tools/perf/tests/thread-map.c                      |  6 ++--
 tools/perf/util/auxtrace.c                         |  4 +--
 tools/perf/util/bpf-loader.c                       |  2 ++
 tools/perf/util/counts.h                           |  4 +++
 tools/perf/util/cpumap.c                           | 22 ++++-----------
 tools/perf/util/cpumap.h                           | 17 ++----------
 tools/perf/util/cputopo.c                          |  2 ++
 tools/perf/util/env.c                              |  1 +
 tools/perf/util/event.c                            | 10 +++----
 tools/perf/util/evlist.c                           | 32 ++++++++++++----------
 tools/perf/util/evsel.c                            |  6 ++--
 tools/perf/util/evsel.h                            | 12 +++++---
 tools/perf/util/mem2node.c                         |  1 +
 tools/perf/util/metricgroup.c                      |  3 +-
 tools/perf/util/metricgroup.h                      | 13 +++++----
 tools/perf/util/mmap.c                             |  2 +-
 tools/perf/util/pmu.c                              |  1 +
 tools/perf/util/record.c                           |  2 +-
 .../util/scripting-engines/trace-event-python.c    |  3 +-
 tools/perf/util/stat-display.c                     |  7 +++--
 tools/perf/util/stat.c                             |  7 +++--
 tools/perf/util/svghelper.c                        |  1 +
 tools/perf/util/thread_map.c                       |  4 +--
 tools/perf/util/thread_map.h                       | 10 -------
 47 files changed, 155 insertions(+), 113 deletions(-)

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-rc5.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-36), clang version 3.4.2 (tags/RELEASE_34/dot2-final)
  16 clearlinux:latest             : Ok   gcc (Clear Linux OS for Intel Architecture) 9.1.1 20190808 gcc-9-branch@274204, 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 8.3.0-19) 8.3.0, clang version 7.0.1-9 (tags/RELEASE_701/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.0, 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.1.1 20190805 [gcc-9-branch revision 274114], 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.1.0-9ubuntu2) 9.1.0, clang version 8.0.1-+rc4-1 (tags/RELEASE_801/rc4)
  # uname -a
  Linux quaco 5.2.6-200.fc30.x86_64 #1 SMP Mon Aug 5 13:20:47 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  # git log --oneline -1
  d9c5c0834165 libperf: Fix alignment trap with xyarray contents in 'perf stat'
  # perf version --build-options
  perf version 5.3.rc5.gd9c5c0834165
                   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_debug_O: make DEBUG=1
                    make_doc_O: make doc
                make_no_newt_O: make NO_NEWT=1
           make_no_libpython_O: make NO_LIBPYTHON=1
                   make_pure_O: make
       make_util_pmu_bison_o_O: make util/pmu-bison.o
           make_no_libunwind_O: make NO_LIBUNWIND=1
                   make_tags_O: make tags
         make_with_clangllvm_O: make LIBCLANGLLVM=1
                 make_static_O: make LDFLAGS=-static
           make_no_libbionic_O: make NO_LIBBIONIC=1
               make_no_slang_O: make NO_SLANG=1
                   make_help_O: make help
              make_no_libbpf_O: make NO_LIBBPF=1
           make_no_backtrace_O: make NO_BACKTRACE=1
              make_clean_all_O: make clean all
              make_no_libelf_O: make NO_LIBELF=1
            make_no_libaudit_O: make NO_LIBAUDIT=1
                  make_no_ui_O: make NO_NEWT=1 NO_SLANG=1 NO_GTK2=1
                make_install_O: make install
         make_install_prefix_O: make install prefix=/tmp/krava
  make_no_libdw_dwarf_unwind_O: make NO_LIBDW_DWARF_UNWIND=1
                make_no_gtk2_O: make NO_GTK2=1
            make_no_demangle_O: make NO_DEMANGLE=1
                 make_cscope_O: make cscope
        make_with_babeltrace_O: make LIBBABELTRACE=1
                make_minimal_O: make NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1 NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1 NO_LIBZSTD=1 NO_LIBCAP=1
   make_install_prefix_slash_O: make install prefix=/tmp/krava/
            make_install_bin_O: make install-bin
             make_no_scripts_O: make NO_LIBPYTHON=1 NO_LIBPERL=1
                 make_perf_o_O: make perf.o
             make_util_map_o_O: make util/map.o
             make_no_libnuma_O: make NO_LIBNUMA=1
            make_no_auxtrace_O: make NO_AUXTRACE=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/25 tools headers: Add missing perf_event.h include

From: Jiri Olsa <[email protected]>

We need perf_event.h include for 'struct perf_event_mmap_page'.

---
 tools/include/linux/ring_buffer.h | 1 +
 1 file changed, 1 insertion(+)
tools/include/linux/ring_buffer.h +1 -0
index 9a083ae60473..6c02617377c2 100644
@@ -2,6 +2,7 @@
 #define _TOOLS_LINUX_RING_BUFFER_H_
 
 #include <asm/barrier.h>
+#include <linux/perf_event.h>
 
 /*
  * Contract with kernel for walking the perf ring buffer from
Signature · 1 line
2.21.0
author maintainer
#2 lore raw

PATCH 2/25 perf tools: Use perf_cpu_map__nr instead of cpu_map__nr

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

Switch the rest of the perf code to use libperf's perf_cpu_map__nr(), which is the same as current cpu_map__nr() and remove the cpu_map__nr() function.

---
 tools/perf/arch/arm/util/cs-etm.c |  4 ++--
 tools/perf/util/cpumap.h          |  5 -----
 tools/perf/util/evlist.c          | 10 +++++-----
 tools/perf/util/mmap.c            |  2 +-
 tools/perf/util/stat-display.c    |  2 +-
 5 files changed, 9 insertions(+), 14 deletions(-)
tools/perf/arch/arm/util/cs-etm.c +2 -2
index 5cb07e8cb296..c786ab095d15 100644
@@ -653,7 +653,7 @@ static int cs_etm_info_fill(struct auxtrace_record *itr,
 		cpu_map = online_cpus;
 	} else {
 		/* Make sure all specified CPUs are online */
-		for (i = 0; i < cpu_map__nr(event_cpus); i++) {
+		for (i = 0; i < perf_cpu_map__nr(event_cpus); i++) {
 			if (cpu_map__has(event_cpus, i) &&
 			    !cpu_map__has(online_cpus, i))
 				return -EINVAL;
@@ -662,7 +662,7 @@ static int cs_etm_info_fill(struct auxtrace_record *itr,
 		cpu_map = event_cpus;
 	}
 
-	nr_cpu = cpu_map__nr(cpu_map);
+	nr_cpu = perf_cpu_map__nr(cpu_map);
 	/* Get PMU type as dynamically assigned by the core */
 	type = cs_etm_pmu->type;
 
tools/perf/util/cpumap.h +0 -5
index a3d27f4131be..77f85e9c88d4 100644
@@ -49,11 +49,6 @@ static inline int cpu_map__id_to_cpu(int id)
 	return id & 0xffff;
 }
 
-static inline int cpu_map__nr(const struct perf_cpu_map *map)
-{
-	return map ? map->nr : 1;
-}
-
 static inline bool cpu_map__empty(const struct perf_cpu_map *map)
 {
 	return map ? map->map[0] == -1 : true;
tools/perf/util/evlist.c +5 -5
index c4489a1ad6bc..15d1046014d7 100644
@@ -370,7 +370,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist,
 					    int thread)
 {
 	int cpu;
-	int nr_cpus = cpu_map__nr(evlist->core.cpus);
+	int nr_cpus = perf_cpu_map__nr(evlist->core.cpus);
 
 	if (!evsel->core.fd)
 		return -EINVAL;
@@ -396,7 +396,7 @@ int perf_evlist__enable_event_idx(struct evlist *evlist,
 
 int perf_evlist__alloc_pollfd(struct evlist *evlist)
 {
-	int nr_cpus = cpu_map__nr(evlist->core.cpus);
+	int nr_cpus = perf_cpu_map__nr(evlist->core.cpus);
 	int nr_threads = thread_map__nr(evlist->core.threads);
 	int nfds = 0;
 	struct evsel *evsel;
@@ -692,7 +692,7 @@ static struct perf_mmap *perf_evlist__alloc_mmap(struct evlist *evlist,
 	int i;
 	struct perf_mmap *map;
 
-	evlist->nr_mmaps = cpu_map__nr(evlist->core.cpus);
+	evlist->nr_mmaps = perf_cpu_map__nr(evlist->core.cpus);
 	if (cpu_map__empty(evlist->core.cpus))
 		evlist->nr_mmaps = thread_map__nr(evlist->core.threads);
 	map = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
@@ -807,7 +807,7 @@ static int perf_evlist__mmap_per_cpu(struct evlist *evlist,
 				     struct mmap_params *mp)
 {
 	int cpu, thread;
-	int nr_cpus = cpu_map__nr(evlist->core.cpus);
+	int nr_cpus = perf_cpu_map__nr(evlist->core.cpus);
 	int nr_threads = thread_map__nr(evlist->core.threads);
 
 	pr_debug2("perf event ring buffer mmapped per cpu\n");
@@ -1014,7 +1014,7 @@ int perf_evlist__mmap_ex(struct evlist *evlist, unsigned int pages,
 	evlist__for_each_entry(evlist, evsel) {
 		if ((evsel->core.attr.read_format & PERF_FORMAT_ID) &&
 		    evsel->sample_id == NULL &&
-		    perf_evsel__alloc_id(evsel, cpu_map__nr(cpus), threads->nr) < 0)
+		    perf_evsel__alloc_id(evsel, perf_cpu_map__nr(cpus), threads->nr) < 0)
 			return -ENOMEM;
 	}
 
tools/perf/util/mmap.c +1 -1
index 42a5971146ae..5f3532e51ec9 100644
@@ -331,7 +331,7 @@ static void build_node_mask(int node, cpu_set_t *mask)
 	if (!cpu_map)
 		return;
 
-	nr_cpus = cpu_map__nr(cpu_map);
+	nr_cpus = perf_cpu_map__nr(cpu_map);
 	for (c = 0; c < nr_cpus; c++) {
 		cpu = cpu_map->map[c]; /* map c index to online cpu index */
 		if (cpu__get_node(cpu) == node)
tools/perf/util/stat-display.c +1 -1
index f7b39f4bc51e..3df0e39ccd52 100644
@@ -745,7 +745,7 @@ static void print_aggr_thread(struct perf_stat_config *config,
 {
 	FILE *output = config->output;
 	int nthreads = thread_map__nr(counter->core.threads);
-	int ncpus = cpu_map__nr(counter->core.cpus);
+	int ncpus = perf_cpu_map__nr(counter->core.cpus);
 	int thread, sorted_threads, id;
 	struct perf_aggr_thread_value *buf;
 
Signature · 1 line
2.21.0
author maintainer
#3 lore raw

PATCH 3/25 libperf: Move perf's cpu_map__empty() to perf_cpu_map__empty()

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

So it's part of the libperf library as one of basic functions operating on the perf_cpu_map class.

---
 tools/perf/arch/arm/util/cs-etm.c    |  8 ++++----
 tools/perf/arch/x86/util/intel-bts.c |  4 ++--
 tools/perf/arch/x86/util/intel-pt.c  | 10 +++++-----
 tools/perf/builtin-c2c.c             |  2 +-
 tools/perf/builtin-stat.c            |  4 ++--
 tools/perf/lib/cpumap.c              |  5 +++++
 tools/perf/lib/include/perf/cpumap.h |  2 ++
 tools/perf/lib/libperf.map           |  1 +
 tools/perf/util/cpumap.c             |  6 +++---
 tools/perf/util/cpumap.h             |  7 +------
 tools/perf/util/event.c              |  2 +-
 tools/perf/util/evlist.c             |  6 +++---
 tools/perf/util/record.c             |  2 +-
 tools/perf/util/stat.c               |  2 +-
 14 files changed, 32 insertions(+), 29 deletions(-)
tools/perf/arch/arm/util/cs-etm.c +4 -4
index c786ab095d15..c73da3245b67 100644
@@ -396,7 +396,7 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,
 	 * AUX event.  We also need the contextID in order to be notified
 	 * when a context switch happened.
 	 */
-	if (!cpu_map__empty(cpus)) {
+	if (!perf_cpu_map__empty(cpus)) {
 		perf_evsel__set_sample_bit(cs_etm_evsel, CPU);
 
 		err = cs_etm_set_option(itr, cs_etm_evsel,
@@ -420,7 +420,7 @@ static int cs_etm_recording_options(struct auxtrace_record *itr,
 		tracking_evsel->core.attr.sample_period = 1;
 
 		/* In per-cpu case, always need the time of mmap events etc */
-		if (!cpu_map__empty(cpus))
+		if (!perf_cpu_map__empty(cpus))
 			perf_evsel__set_sample_bit(tracking_evsel, TIME);
 	}
 
@@ -493,7 +493,7 @@ cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused,
 	struct perf_cpu_map *online_cpus = perf_cpu_map__new(NULL);
 
 	/* cpu map is not empty, we have specific CPUs to work with */
-	if (!cpu_map__empty(event_cpus)) {
+	if (!perf_cpu_map__empty(event_cpus)) {
 		for (i = 0; i < cpu__max_cpu(); i++) {
 			if (!cpu_map__has(event_cpus, i) ||
 			    !cpu_map__has(online_cpus, i))
@@ -649,7 +649,7 @@ static int cs_etm_info_fill(struct auxtrace_record *itr,
 		return -EINVAL;
 
 	/* If the cpu_map is empty all online CPUs are involved */
-	if (cpu_map__empty(event_cpus)) {
+	if (perf_cpu_map__empty(event_cpus)) {
 		cpu_map = online_cpus;
 	} else {
 		/* Make sure all specified CPUs are online */
tools/perf/arch/x86/util/intel-bts.c +2 -2
index 7b23318ebd7b..2d5d8a12dd1f 100644
@@ -133,7 +133,7 @@ static int intel_bts_recording_options(struct auxtrace_record *itr,
 	if (!opts->full_auxtrace)
 		return 0;
 
-	if (opts->full_auxtrace && !cpu_map__empty(cpus)) {
+	if (opts->full_auxtrace && !perf_cpu_map__empty(cpus)) {
 		pr_err(INTEL_BTS_PMU_NAME " does not support per-cpu recording\n");
 		return -EINVAL;
 	}
@@ -214,7 +214,7 @@ static int intel_bts_recording_options(struct auxtrace_record *itr,
 		 * In the case of per-cpu mmaps, we need the CPU on the
 		 * AUX event.
 		 */
-		if (!cpu_map__empty(cpus))
+		if (!perf_cpu_map__empty(cpus))
 			perf_evsel__set_sample_bit(intel_bts_evsel, CPU);
 	}
 
tools/perf/arch/x86/util/intel-pt.c +5 -5
index a8e633aa278a..c72a77a82b39 100644
@@ -365,7 +365,7 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,
 			ui__warning("Intel Processor Trace: TSC not available\n");
 	}
 
-	per_cpu_mmaps = !cpu_map__empty(session->evlist->core.cpus);
+	per_cpu_mmaps = !perf_cpu_map__empty(session->evlist->core.cpus);
 
 	auxtrace_info->type = PERF_AUXTRACE_INTEL_PT;
 	auxtrace_info->priv[INTEL_PT_PMU_TYPE] = intel_pt_pmu->type;
@@ -702,7 +702,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
 	 * Per-cpu recording needs sched_switch events to distinguish different
 	 * threads.
 	 */
-	if (have_timing_info && !cpu_map__empty(cpus)) {
+	if (have_timing_info && !perf_cpu_map__empty(cpus)) {
 		if (perf_can_record_switch_events()) {
 			bool cpu_wide = !target__none(&opts->target) &&
 					!target__has_task(&opts->target);
@@ -760,7 +760,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
 		 * In the case of per-cpu mmaps, we need the CPU on the
 		 * AUX event.
 		 */
-		if (!cpu_map__empty(cpus))
+		if (!perf_cpu_map__empty(cpus))
 			perf_evsel__set_sample_bit(intel_pt_evsel, CPU);
 	}
 
@@ -784,7 +784,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
 			tracking_evsel->immediate = true;
 
 		/* In per-cpu case, always need the time of mmap events etc */
-		if (!cpu_map__empty(cpus)) {
+		if (!perf_cpu_map__empty(cpus)) {
 			perf_evsel__set_sample_bit(tracking_evsel, TIME);
 			/* And the CPU for switch events */
 			perf_evsel__set_sample_bit(tracking_evsel, CPU);
@@ -796,7 +796,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
 	 * Warn the user when we do not have enough information to decode i.e.
 	 * per-cpu with no sched_switch (except workload-only).
 	 */
-	if (!ptr->have_sched_switch && !cpu_map__empty(cpus) &&
+	if (!ptr->have_sched_switch && !perf_cpu_map__empty(cpus) &&
 	    !target__none(&opts->target))
 		ui__warning("Intel Processor Trace decoding will not be possible except for kernel tracing!\n");
 
tools/perf/builtin-c2c.c +1 -1
index f0aae6e13a33..01629f5b6d1f 100644
@@ -2059,7 +2059,7 @@ static int setup_nodes(struct perf_session *session)
 		nodes[node] = set;
 
 		/* empty node, skip */
-		if (cpu_map__empty(map))
+		if (perf_cpu_map__empty(map))
 			continue;
 
 		for (cpu = 0; cpu < map->nr; cpu++) {
tools/perf/builtin-stat.c +2 -2
index b19df671111e..90636a811b36 100644
@@ -928,7 +928,7 @@ static int perf_stat_init_aggr_mode(void)
 	 * the aggregation translate cpumap.
 	 */
 	nr = cpu_map__get_max(evsel_list->core.cpus);
-	stat_config.cpus_aggr_map = cpu_map__empty_new(nr + 1);
+	stat_config.cpus_aggr_map = perf_cpu_map__empty_new(nr + 1);
 	return stat_config.cpus_aggr_map ? 0 : -ENOMEM;
 }
 
@@ -1493,7 +1493,7 @@ int process_stat_config_event(struct perf_session *session,
 
 	perf_event__read_stat_config(&stat_config, &event->stat_config);
 
-	if (cpu_map__empty(st->cpus)) {
+	if (perf_cpu_map__empty(st->cpus)) {
 		if (st->aggr_mode != AGGR_UNSET)
 			pr_warning("warning: processing task data, aggregation mode not set\n");
 		return 0;
tools/perf/lib/cpumap.c +5 -0
index 1ddb69e796e5..63f7df7e47ff 100644
@@ -237,3 +237,8 @@ int perf_cpu_map__nr(const struct perf_cpu_map *cpus)
 {
 	return cpus ? cpus->nr : 1;
 }
+
+bool perf_cpu_map__empty(const struct perf_cpu_map *map)
+{
+	return map ? map->map[0] == -1 : true;
+}
tools/perf/lib/include/perf/cpumap.h +2 -0
index 1b6e7db3fa2b..8aa995c59498 100644
@@ -4,6 +4,7 @@
 
 #include <perf/core.h>
 #include <stdio.h>
+#include <stdbool.h>
 
 struct perf_cpu_map;
 
@@ -14,6 +15,7 @@ LIBPERF_API struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map);
 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);
 
 #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 e24d3cec01c1..3373dd51fcda 100644
@@ -8,6 +8,7 @@ LIBPERF_0.0.1 {
 		perf_cpu_map__read;
 		perf_cpu_map__nr;
 		perf_cpu_map__cpu;
+		perf_cpu_map__empty;
 		perf_thread_map__new_dummy;
 		perf_thread_map__set_pid;
 		perf_thread_map__comm;
tools/perf/util/cpumap.c +3 -3
index beb3525e9e45..4402e67445a4 100644
@@ -21,7 +21,7 @@ static struct perf_cpu_map *cpu_map__from_entries(struct cpu_map_entries *cpus)
 {
 	struct perf_cpu_map *map;
 
-	map = cpu_map__empty_new(cpus->nr);
+	map = perf_cpu_map__empty_new(cpus->nr);
 	if (map) {
 		unsigned i;
 
@@ -48,7 +48,7 @@ static struct perf_cpu_map *cpu_map__from_mask(struct cpu_map_mask *mask)
 
 	nr = bitmap_weight(mask->mask, nbits);
 
-	map = cpu_map__empty_new(nr);
+	map = perf_cpu_map__empty_new(nr);
 	if (map) {
 		int cpu, i = 0;
 
@@ -77,7 +77,7 @@ size_t cpu_map__fprintf(struct perf_cpu_map *map, FILE *fp)
 #undef BUFSIZE
 }
 
-struct perf_cpu_map *cpu_map__empty_new(int nr)
+struct perf_cpu_map *perf_cpu_map__empty_new(int nr)
 {
 	struct perf_cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(int) * nr);
 
tools/perf/util/cpumap.h +1 -6
index 77f85e9c88d4..3e068090612f 100644
@@ -11,7 +11,7 @@
 #include "perf.h"
 #include "util/debug.h"
 
-struct perf_cpu_map *cpu_map__empty_new(int nr);
+struct perf_cpu_map *perf_cpu_map__empty_new(int nr);
 struct perf_cpu_map *cpu_map__new_data(struct cpu_map_data *data);
 size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size);
 size_t cpu_map__snprint_mask(struct perf_cpu_map *map, char *buf, size_t size);
@@ -49,11 +49,6 @@ static inline int cpu_map__id_to_cpu(int id)
 	return id & 0xffff;
 }
 
-static inline bool cpu_map__empty(const struct perf_cpu_map *map)
-{
-	return map ? map->map[0] == -1 : true;
-}
-
 int cpu__setup_cpunode_map(void);
 
 int cpu__max_node(void);
tools/perf/util/event.c +1 -1
index f440fdc3e953..f433da85c45e 100644
@@ -1055,7 +1055,7 @@ static size_t mask_size(struct perf_cpu_map *map, int *max)
 void *cpu_map_data__alloc(struct perf_cpu_map *map, size_t *size, u16 *type, int *max)
 {
 	size_t size_cpus, size_mask;
-	bool is_dummy = cpu_map__empty(map);
+	bool is_dummy = perf_cpu_map__empty(map);
 
 	/*
 	 * Both array and mask data have variable size based
tools/perf/util/evlist.c +3 -3
index 15d1046014d7..ba49b5ecffd0 100644
@@ -386,7 +386,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist,
 int perf_evlist__enable_event_idx(struct evlist *evlist,
 				  struct evsel *evsel, int idx)
 {
-	bool per_cpu_mmaps = !cpu_map__empty(evlist->core.cpus);
+	bool per_cpu_mmaps = !perf_cpu_map__empty(evlist->core.cpus);
 
 	if (per_cpu_mmaps)
 		return perf_evlist__enable_event_cpu(evlist, evsel, idx);
@@ -693,7 +693,7 @@ static struct perf_mmap *perf_evlist__alloc_mmap(struct evlist *evlist,
 	struct perf_mmap *map;
 
 	evlist->nr_mmaps = perf_cpu_map__nr(evlist->core.cpus);
-	if (cpu_map__empty(evlist->core.cpus))
+	if (perf_cpu_map__empty(evlist->core.cpus))
 		evlist->nr_mmaps = thread_map__nr(evlist->core.threads);
 	map = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
 	if (!map)
@@ -1018,7 +1018,7 @@ int perf_evlist__mmap_ex(struct evlist *evlist, unsigned int pages,
 			return -ENOMEM;
 	}
 
-	if (cpu_map__empty(cpus))
+	if (perf_cpu_map__empty(cpus))
 		return perf_evlist__mmap_per_thread(evlist, &mp);
 
 	return perf_evlist__mmap_per_cpu(evlist, &mp);
tools/perf/util/record.c +1 -1
index e59382d99196..51bbd0714e6d 100644
@@ -275,7 +275,7 @@ bool perf_evlist__can_select_event(struct evlist *evlist, const char *str)
 
 	evsel = perf_evlist__last(temp_evlist);
 
-	if (!evlist || cpu_map__empty(evlist->core.cpus)) {
+	if (!evlist || perf_cpu_map__empty(evlist->core.cpus)) {
 		struct perf_cpu_map *cpus = perf_cpu_map__new(NULL);
 
 		cpu =  cpus ? cpus->map[0] : 0;
tools/perf/util/stat.c +1 -1
index e4e4e3bf8b2b..2715112290cf 100644
@@ -223,7 +223,7 @@ static int check_per_pkg(struct evsel *counter,
 	if (!counter->per_pkg)
 		return 0;
 
-	if (cpu_map__empty(cpus))
+	if (perf_cpu_map__empty(cpus))
 		return 0;
 
 	if (!mask) {
Signature · 1 line
2.21.0
author maintainer
#4 lore raw

PATCH 4/25 libperf: Move perf's cpu_map__idx() to perf_cpu_map__idx()

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

As an internal function that will be used by both perf and libperf, but is not exported at this point.

---
 tools/perf/lib/cpumap.c                  | 12 ++++++++++++
 tools/perf/lib/include/internal/cpumap.h |  2 ++
 tools/perf/util/cpumap.c                 | 14 +-------------
 tools/perf/util/cpumap.h                 |  1 -
 tools/perf/util/evlist.c                 |  2 +-
 5 files changed, 16 insertions(+), 15 deletions(-)
tools/perf/lib/cpumap.c +12 -0
index 63f7df7e47ff..2834753576b2 100644
@@ -242,3 +242,15 @@ bool perf_cpu_map__empty(const struct perf_cpu_map *map)
 {
 	return map ? map->map[0] == -1 : true;
 }
+
+int perf_cpu_map__idx(struct perf_cpu_map *cpus, int cpu)
+{
+	int i;
+
+	for (i = 0; i < cpus->nr; ++i) {
+		if (cpus->map[i] == cpu)
+			return i;
+	}
+
+	return -1;
+}
tools/perf/lib/include/internal/cpumap.h +2 -0
index 3306319f7df8..840d4032587b 100644
@@ -14,4 +14,6 @@ struct perf_cpu_map {
 #define MAX_NR_CPUS	2048
 #endif
 
+int perf_cpu_map__idx(struct perf_cpu_map *cpus, int cpu);
+
 #endif /* __LIBPERF_INTERNAL_CPUMAP_H */
tools/perf/util/cpumap.c +1 -13
index 4402e67445a4..8e6c2cbffedc 100644
@@ -458,19 +458,7 @@ int cpu__setup_cpunode_map(void)
 
 bool cpu_map__has(struct perf_cpu_map *cpus, int cpu)
 {
-	return cpu_map__idx(cpus, cpu) != -1;
-}
-
-int cpu_map__idx(struct perf_cpu_map *cpus, int cpu)
-{
-	int i;
-
-	for (i = 0; i < cpus->nr; ++i) {
-		if (cpus->map[i] == cpu)
-			return i;
-	}
-
-	return -1;
+	return perf_cpu_map__idx(cpus, cpu) != -1;
 }
 
 int cpu_map__cpu(struct perf_cpu_map *cpus, int idx)
tools/perf/util/cpumap.h +0 -1
index 3e068090612f..8dbedda7af45 100644
@@ -62,5 +62,4 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct perf_cpu_map **res,
 
 int cpu_map__cpu(struct perf_cpu_map *cpus, int idx);
 bool cpu_map__has(struct perf_cpu_map *cpus, int cpu);
-int cpu_map__idx(struct perf_cpu_map *cpus, int cpu);
 #endif /* __PERF_CPUMAP_H */
tools/perf/util/evlist.c +1 -1
index ba49b5ecffd0..8582560b59af 100644
@@ -758,7 +758,7 @@ static int perf_evlist__mmap_per_evsel(struct evlist *evlist, int idx,
 		if (evsel->system_wide && thread)
 			continue;
 
-		cpu = cpu_map__idx(evsel->core.cpus, evlist_cpu);
+		cpu = perf_cpu_map__idx(evsel->core.cpus, evlist_cpu);
 		if (cpu == -1)
 			continue;
 
Signature · 1 line
2.21.0
author maintainer
#5 lore raw

PATCH 5/25 perf arm64: Add missing debug.h header

In reply to Arnaldo Carvalho de Melo

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

This file uses pr_debug() but isn't including debug.h, getting it by luck, fix it.

---
 tools/perf/arch/arm64/util/header.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/arch/arm64/util/header.c +1 -0
index 602caf550e7f..e41defaaa2e6 100644
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <api/fs/fs.h>
+#include "debug.h"
 #include "header.h"
 
 #define MIDR "/regs/identification/midr_el1"
Signature · 1 line
2.21.0
author maintainer
#6 lore raw

PATCH 6/25 perf kvm s390: Add missing string.h header

In reply to Arnaldo Carvalho de Melo

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

It uses strstr(), needs to include string.h or its not going to build when we remove string.h from the place it is getting from indirectly, by luck.

---
 tools/perf/arch/s390/util/kvm-stat.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/arch/s390/util/kvm-stat.c +1 -0
index dac78441338c..0fd4e9f49ed0 100644
@@ -7,6 +7,7 @@
  */
 
 #include <errno.h>
+#include <string.h>
 #include "../../util/kvm-stat.h"
 #include "../../util/evsel.h"
 #include <asm/sie.h>
Signature · 1 line
2.21.0
author maintainer
#7 lore raw

PATCH 7/25 perf metricgroup: Remove needless includes from metricgroup.h

In reply to Arnaldo Carvalho de Melo

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

There we need just some struct forward declarations, do that instead and add the includes needed by metricgroup.c.

That should help with needless rebuilds when changing the removed headers from metricgroup.h.

---
 tools/perf/util/metricgroup.c |  3 ++-
 tools/perf/util/metricgroup.h | 13 ++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)
tools/perf/util/metricgroup.c +2 -1
index fdb0d1c5c5cf..aaf55444f81b 100644
@@ -7,18 +7,19 @@
 
 #include "metricgroup.h"
 #include "evlist.h"
+#include "evsel.h"
 #include "strbuf.h"
 #include "pmu.h"
 #include "expr.h"
 #include "rblist.h"
 #include <string.h>
-#include <stdbool.h>
 #include <errno.h>
 #include "pmu-events/pmu-events.h"
 #include "strlist.h"
 #include <assert.h>
 #include <linux/ctype.h>
 #include <linux/zalloc.h>
+#include <subcmd/parse-options.h>
 
 struct metric_event *metricgroup__lookup(struct rblist *metric_events,
 					 struct evsel *evsel,
tools/perf/util/metricgroup.h +8 -5
index 500e828533f8..e5092f6404ae 100644
@@ -1,11 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0-only
 #ifndef METRICGROUP_H
 #define METRICGROUP_H 1
 
-#include "linux/list.h"
-#include "rblist.h"
-#include <subcmd/parse-options.h>
-#include "evlist.h"
-#include "strbuf.h"
+#include <linux/list.h>
+#include <linux/rbtree.h>
+#include <stdbool.h>
+
+struct evsel;
+struct option;
+struct rblist;
 
 struct metric_event {
 	struct rb_node nd;
Signature · 1 line
2.21.0
author maintainer
#8 lore raw

PATCH 8/25 perf evsel: Move xyarray.h from evsel.c to evsel.h to reduce include dep tree

In reply to Arnaldo Carvalho de Melo

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

All we need in util/evsel.h is the foward declaration of 'struct xyarray', not the internal/xyarray.h, that can be moved to util/evsel.c and then we reduce the header dependency tree.

---
 tools/perf/util/evsel.c | 1 +
 tools/perf/util/evsel.h | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/evsel.c +1 -0
index 0a33f7322ecc..477c47c84971 100644
@@ -39,6 +39,7 @@
 #include "string2.h"
 #include "memswap.h"
 #include "util/parse-branch-options.h"
+#include <internal/xyarray.h>
 
 #include <linux/ctype.h>
 
tools/perf/util/evsel.h +1 -1
index efe08065838f..2928eee78427 100644
@@ -8,7 +8,6 @@
 #include <linux/perf_event.h>
 #include <linux/types.h>
 #include <internal/evsel.h>
-#include <internal/xyarray.h>
 #include "symbol_conf.h"
 #include "cpumap.h"
 #include "counts.h"
@@ -93,6 +92,7 @@ enum perf_tool_event {
 };
 
 struct bpf_object;
+struct xyarray;
 
 /** struct evsel - event selector
  *
Signature · 1 line
2.21.0
author maintainer
#9 lore raw

PATCH 9/25 perf counts: Add missing headers needed for types used

In reply to Arnaldo Carvalho de Melo

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

We get these by sheer luck, since we're cleaning unneeded headers use, this needs to be done first to avoid breakage down the line.

---
 tools/perf/util/counts.h | 4 ++++
 1 file changed, 4 insertions(+)
tools/perf/util/counts.h +4 -0
index 13430f353c19..92196df4945f 100644
@@ -2,8 +2,12 @@
 #ifndef __PERF_COUNTS_H
 #define __PERF_COUNTS_H
 
+#include <linux/types.h>
 #include <internal/xyarray.h>
 #include <perf/evsel.h>
+#include <stdbool.h>
+
+struct evsel;
 
 struct perf_counts {
 	s8			  scaled;
Signature · 1 line
2.21.0
author maintainer
#10 lore raw

PATCH 10/25 perf bpf: Add missing xyarray.h header

In reply to Arnaldo Carvalho de Melo

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

This was being obtained indirectly via evsel.h -> counts.h, since we don't need xyarray in counts.h, we need to add it here explicitely before removing it from counts.h.

---
 tools/perf/util/bpf-loader.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/bpf-loader.c +2 -0
index 9c219d413e57..e20d7c5e1925 100644
@@ -26,6 +26,8 @@
 #include "llvm-utils.h"
 #include "c++/clang-c.h"
 
+#include <internal/xyarray.h>
+
 static int libbpf_perf_print(enum libbpf_print_level level __attribute__((unused)),
 			      const char *fmt, va_list args)
 {
Signature · 1 line
2.21.0
author maintainer
#11 lore raw

PATCH 11/25 perf evlist: Add missing xyarray.h header

In reply to Arnaldo Carvalho de Melo

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

It gets it very indirectly, via evsel.h -> counts.h, and since counts.h doesn't need xyarray.h at all, add it here before we remove it there.

---
 tools/perf/util/evlist.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/util/evlist.c +2 -0
index 8582560b59af..68b7c949017e 100644
@@ -37,6 +37,8 @@
 #include <perf/evsel.h>
 #include <perf/cpumap.h>
 
+#include <internal/xyarray.h>
+
 #ifdef LACKS_SIGQUEUE_PROTOTYPE
 int sigqueue(pid_t pid, int sig, const union sigval value);
 #endif
Signature · 1 line
2.21.0
author maintainer
#12 lore raw

PATCH 12/25 perf script: Add missing counts.h

In reply to Arnaldo Carvalho de Melo

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

It is getting this via evsel.h, that don't strictly need counts.h, just forward declarations for some structs, so add it here before we remove it from there.

---
 tools/perf/builtin-script.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/builtin-script.c +1 -0
index 1764efd16cd4..e957b870869b 100644
@@ -3,6 +3,7 @@
 
 #include "perf.h"
 #include "util/cache.h"
+#include "util/counts.h"
 #include "util/debug.h"
 #include <subcmd/exec-cmd.h>
 #include "util/header.h"
Signature · 1 line
2.21.0
author maintainer
#13 lore raw

PATCH 13/25 perf tests: Add missing counts.h

In reply to Arnaldo Carvalho de Melo

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

Those are getting counts.h via evsel.h, that don't strictly need counts.h, just forward declarations for some structs, so add it here before we remove it from there.

---
 tools/perf/tests/openat-syscall-all-cpus.c | 1 +
 tools/perf/tests/openat-syscall.c          | 1 +
 2 files changed, 2 insertions(+)
tools/perf/tests/openat-syscall-all-cpus.c +1 -0
index 8322b6aa4047..4ae4dea07466 100644
@@ -16,6 +16,7 @@
 #include "cpumap.h"
 #include "debug.h"
 #include "stat.h"
+#include "util/counts.h"
 
 int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, int subtest __maybe_unused)
 {
tools/perf/tests/openat-syscall.c +1 -0
index f217972977e0..58df4bda5e12 100644
@@ -10,6 +10,7 @@
 #include "evsel.h"
 #include "debug.h"
 #include "tests.h"
+#include "util/counts.h"
 
 int test__openat_syscall_event(struct test *test __maybe_unused, int subtest __maybe_unused)
 {
Signature · 1 line
2.21.0
author maintainer
#14 lore raw

PATCH 14/25 perf stat: Add missing counts.h

In reply to Arnaldo Carvalho de Melo

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

It is getting this via evsel.h, that don't strictly need counts.h, just forward declarations for some structs, so add it here before we remove it from there.

---
 tools/perf/util/stat-display.c | 1 +
 tools/perf/util/stat.c         | 1 +
 2 files changed, 2 insertions(+)
tools/perf/util/stat-display.c +1 -0
index 3df0e39ccd52..605a1fdbda7a 100644
@@ -4,6 +4,7 @@
 #include <linux/time64.h>
 #include <math.h>
 #include "color.h"
+#include "counts.h"
 #include "evlist.h"
 #include "evsel.h"
 #include "stat.h"
tools/perf/util/stat.c +1 -0
index 2715112290cf..1e6a25abe00f 100644
@@ -2,6 +2,7 @@
 #include <errno.h>
 #include <inttypes.h>
 #include <math.h>
+#include "counts.h"
 #include "stat.h"
 #include "evlist.h"
 #include "evsel.h"
Signature · 1 line
2.21.0
author maintainer
#15 lore raw

PATCH 15/25 perf scripting python: Add missing counts.h header

In reply to Arnaldo Carvalho de Melo

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

It is getting this via evsel.h, that don't strictly need counts.h, just forward declarations for some structs, so add it here before we remove it from there.

---
 tools/perf/util/scripting-engines/trace-event-python.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/util/scripting-engines/trace-event-python.c +1 -0
index 32c17a727450..51771fc0d0df 100644
@@ -32,6 +32,7 @@
 #include <linux/time64.h>
 
 #include "../../perf.h"
+#include "../counts.h"
 #include "../debug.h"
 #include "../callchain.h"
 #include "../evsel.h"
Signature · 1 line
2.21.0
author maintainer
#16 lore raw

PATCH 16/25 perf evsel: Add missing perf/evsel.h header in util/evsel.h

In reply to Arnaldo Carvalho de Melo

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

Since util/evsel.h uses perf_evsel__cpus() that has its prototype in libperf's perf/evsel.h file, we need it explicitely included.

This was working by luck as util/evsel.h includes counts.h, but that is not necessary, just some forward declarations, so, before we remove counts.h from util/evsel.h, add what is realli needed.

---
 tools/perf/util/evsel.h | 1 +
 1 file changed, 1 insertion(+)
tools/perf/util/evsel.h +1 -0
index 2928eee78427..da91d6f57f44 100644
@@ -8,6 +8,7 @@
 #include <linux/perf_event.h>
 #include <linux/types.h>
 #include <internal/evsel.h>
+#include <perf/evsel.h>
 #include "symbol_conf.h"
 #include "cpumap.h"
 #include "counts.h"
Signature · 1 line
2.21.0
author maintainer
#17 lore raw

PATCH 17/25 perf evsel: Remove needless counts.h header from util/evsel.h

In reply to Arnaldo Carvalho de Melo

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

We need only a struct forward declaration, so prune the header dependency tree a bit more.

---
 tools/perf/util/evsel.c | 1 +
 tools/perf/util/evsel.h | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/evsel.c +1 -0
index 477c47c84971..7b4350681d64 100644
@@ -26,6 +26,7 @@
 #include "asm/bug.h"
 #include "callchain.h"
 #include "cgroup.h"
+#include "counts.h"
 #include "event.h"
 #include "evsel.h"
 #include "evlist.h"
tools/perf/util/evsel.h +1 -1
index da91d6f57f44..296390541030 100644
@@ -11,7 +11,6 @@
 #include <perf/evsel.h>
 #include "symbol_conf.h"
 #include "cpumap.h"
-#include "counts.h"
 
 struct evsel;
 
@@ -93,6 +92,7 @@ enum perf_tool_event {
 };
 
 struct bpf_object;
+struct perf_counts;
 struct xyarray;
 
 /** struct evsel - event selector
Signature · 1 line
2.21.0
author maintainer
#18 lore raw

PATCH 18/25 perf evsel: Remove needless stddef.h from util/evsel.h

In reply to Arnaldo Carvalho de Melo

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

We added it in 07ac002f2fcc ("perf evsel: Introduce is_group_member method") but we already ditched that function, and there was nothing else left that needed NULL nor anything else from stddef.h, ditch it.

---
 tools/perf/util/evsel.h | 1 -
 1 file changed, 1 deletion(-)
tools/perf/util/evsel.h +0 -1
index 296390541030..1f749a783d8f 100644
@@ -4,7 +4,6 @@
 
 #include <linux/list.h>
 #include <stdbool.h>
-#include <stddef.h>
 #include <linux/perf_event.h>
 #include <linux/types.h>
 #include <internal/evsel.h>
Signature · 1 line
2.21.0
author maintainer
#19 lore raw

PATCH 19/25 perf evsel: util/evsel.h needs stdio.h as it uses FILE

In reply to Arnaldo Carvalho de Melo

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

And it was getting it by luck from util/cpumap.h that shouldn't be included in util/evsel.h as it only needs what is in libperf, i.e. struct cpu_map, that is in internal/cpumap.h, so add stdio.h before we fix that.

---
 tools/perf/util/evsel.h | 1 +
 1 file changed, 1 insertion(+)
tools/perf/util/evsel.h +1 -0
index 1f749a783d8f..cd336cf2eaa9 100644
@@ -4,6 +4,7 @@
 
 #include <linux/list.h>
 #include <stdbool.h>
+#include <stdio.h>
 #include <linux/perf_event.h>
 #include <linux/types.h>
 #include <internal/evsel.h>
Signature · 1 line
2.21.0
author maintainer
#20 lore raw

PATCH 20/25 perf x86 kvm-stat: Add missing string.h header

In reply to Arnaldo Carvalho de Melo

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

It uses strcmp(), strstr() and was getting the required string.h header by luck, from evsel.h -> cpumap.h -> debug.h -> string.h, add the missing header.

---
 tools/perf/arch/x86/util/kvm-stat.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/arch/x86/util/kvm-stat.c +1 -0
index 81b531a707bf..c0775c39227f 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <errno.h>
+#include <string.h>
 #include "../../../util/kvm-stat.h"
 #include "../../../util/evsel.h"
 #include <asm/svm.h>
Signature · 1 line
2.21.0
author maintainer
#21 lore raw

PATCH 21/25 perf evsel: Switch to libperf's cpumap.h

In reply to Arnaldo Carvalho de Melo

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

We don't need what is in perf's util/cpumap.h, just the struct cpu_map that is in libperf's internal/cpumap.h file to cover this one case:

tools/perf/util/evsel.h:215:27: error: dereferencing pointer to incomplete type ‘struct perf_cpu_map’ 215 | return evsel__cpus(evsel)->nr;

So switch to libperf's cpumap.h and add some missing struct foward declarations and include sys/types.h to get pid_t.

---
 tools/perf/util/evsel.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/evsel.h +4 -1
index cd336cf2eaa9..5a351cae66df 100644
@@ -5,14 +5,17 @@
 #include <linux/list.h>
 #include <stdbool.h>
 #include <stdio.h>
+#include <sys/types.h>
 #include <linux/perf_event.h>
 #include <linux/types.h>
 #include <internal/evsel.h>
 #include <perf/evsel.h>
 #include "symbol_conf.h"
-#include "cpumap.h"
+#include <internal/cpumap.h>
 
+struct addr_location;
 struct evsel;
+union perf_event;
 
 /*
  * Per fd, to map back from PERF_SAMPLE_ID to evsel, only used when there are
Signature · 1 line
2.21.0
author maintainer
#22 lore raw

PATCH 22/25 perf cpumap: Remove needless includes from cpumap.h

In reply to Arnaldo Carvalho de Melo

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

The util/cpumap.h file doesn't use anything in refcount.h not in debug.h, it needs just a forward reference to 'struct cpu_map_data', that is defined in util/event.h and cpumap.h was getting indirectly via, of all things, debug.h

---
 tools/perf/arch/x86/util/header.c | 1 +
 tools/perf/tests/mem2node.c       | 1 +
 tools/perf/util/cpumap.c          | 2 ++
 tools/perf/util/cpumap.h          | 4 ++--
 tools/perf/util/cputopo.c         | 2 ++
 tools/perf/util/env.c             | 1 +
 tools/perf/util/mem2node.c        | 1 +
 tools/perf/util/pmu.c             | 1 +
 tools/perf/util/svghelper.c       | 1 +
 9 files changed, 12 insertions(+), 2 deletions(-)
tools/perf/arch/x86/util/header.c +1 -0
index af9a9f2600be..662ecf84a421 100644
@@ -6,6 +6,7 @@
 #include <string.h>
 #include <regex.h>
 
+#include "../../util/debug.h"
 #include "../../util/header.h"
 
 static inline void
tools/perf/tests/mem2node.c +1 -0
index 5ec193f7968d..73b2855acaf4 100644
@@ -4,6 +4,7 @@
 #include <linux/zalloc.h>
 #include <perf/cpumap.h>
 #include "cpumap.h"
+#include "debug.h"
 #include "mem2node.h"
 #include "tests.h"
 
tools/perf/util/cpumap.c +2 -0
index 8e6c2cbffedc..f5c21184e1fc 100644
@@ -2,6 +2,8 @@
 #include <api/fs/fs.h>
 #include "../perf.h"
 #include "cpumap.h"
+#include "debug.h"
+#include "event.h"
 #include <assert.h>
 #include <dirent.h>
 #include <stdio.h>
tools/perf/util/cpumap.h +2 -2
index 8dbedda7af45..d0c5bbfd91af 100644
@@ -4,12 +4,12 @@
 
 #include <stdio.h>
 #include <stdbool.h>
-#include <linux/refcount.h>
 #include <internal/cpumap.h>
 #include <perf/cpumap.h>
 
 #include "perf.h"
-#include "util/debug.h"
+
+struct cpu_map_data;
 
 struct perf_cpu_map *perf_cpu_map__empty_new(int nr);
 struct perf_cpu_map *cpu_map__new_data(struct cpu_map_data *data);
tools/perf/util/cputopo.c +2 -0
index 4f70155eaf83..1b52402a8923 100644
@@ -3,12 +3,14 @@
 #include <sys/utsname.h>
 #include <inttypes.h>
 #include <stdlib.h>
+#include <string.h>
 #include <api/fs/fs.h>
 #include <linux/zalloc.h>
 #include <perf/cpumap.h>
 
 #include "cputopo.h"
 #include "cpumap.h"
+#include "debug.h"
 #include "env.h"
 
 #define CORE_SIB_FMT \
tools/perf/util/env.c +1 -0
index d77912b2b5e7..571efb4f0351 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "cpumap.h"
+#include "debug.h"
 #include "env.h"
 #include <linux/ctype.h>
 #include <linux/zalloc.h>
tools/perf/util/mem2node.c +1 -0
index cacc2fc4dcbd..14fb9e72aeeb 100644
@@ -2,6 +2,7 @@
 #include <inttypes.h>
 #include <linux/bitmap.h>
 #include <linux/zalloc.h>
+#include "debug.h"
 #include "mem2node.h"
 
 struct phys_entry {
tools/perf/util/pmu.c +1 -0
index b7da21a7d627..9807be6f09bb 100644
@@ -16,6 +16,7 @@
 #include <locale.h>
 #include <regex.h>
 #include <perf/cpumap.h>
+#include "debug.h"
 #include "pmu.h"
 #include "parse-events.h"
 #include "cpumap.h"
tools/perf/util/svghelper.c +1 -0
index ae6a534a7a80..bbdd87163285 100644
@@ -14,6 +14,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <linux/bitmap.h>
+#include <linux/string.h>
 #include <linux/time64.h>
 #include <linux/zalloc.h>
 #include <perf/cpumap.h>
Signature · 1 line
2.21.0
author maintainer
#23 lore raw

PATCH 23/25 libperf: Add perf_thread_map__nr/perf_thread_map__pid functions

In reply to Arnaldo Carvalho de Melo

From: Jiri Olsa <[email protected]>

So it's part of libperf library as basic functions operating on perf_thread_map objects.

---
 tools/perf/builtin-ftrace.c                          |  2 +-
 tools/perf/builtin-script.c                          |  4 ++--
 tools/perf/builtin-stat.c                            |  4 ++--
 tools/perf/builtin-trace.c                           |  4 ++--
 tools/perf/lib/include/perf/threadmap.h              |  2 ++
 tools/perf/lib/libperf.map                           |  2 ++
 tools/perf/lib/threadmap.c                           | 10 ++++++++++
 tools/perf/tests/thread-map.c                        |  6 +++---
 tools/perf/util/auxtrace.c                           |  4 ++--
 tools/perf/util/event.c                              |  8 ++++----
 tools/perf/util/evlist.c                             | 12 ++++++------
 tools/perf/util/evsel.c                              |  4 ++--
 .../perf/util/scripting-engines/trace-event-python.c |  2 +-
 tools/perf/util/stat-display.c                       |  4 ++--
 tools/perf/util/stat.c                               |  4 ++--
 tools/perf/util/thread_map.c                         |  4 ++--
 tools/perf/util/thread_map.h                         | 10 ----------
 17 files changed, 45 insertions(+), 41 deletions(-)
tools/perf/builtin-ftrace.c +1 -1
index 1367bb5046a7..565db782c1b9 100644
@@ -158,7 +158,7 @@ static int set_tracing_pid(struct perf_ftrace *ftrace)
 	if (target__has_cpu(&ftrace->target))
 		return 0;
 
-	for (i = 0; i < thread_map__nr(ftrace->evlist->core.threads); i++) {
+	for (i = 0; i < perf_thread_map__nr(ftrace->evlist->core.threads); i++) {
 		scnprintf(buf, sizeof(buf), "%d",
 			  ftrace->evlist->core.threads->map[i]);
 		if (append_tracing_file("set_ftrace_pid", buf) < 0)
tools/perf/builtin-script.c +2 -2
index e957b870869b..9b93ddeaeafa 100644
@@ -1906,7 +1906,7 @@ static struct scripting_ops	*scripting_ops;
 
 static void __process_stat(struct evsel *counter, u64 tstamp)
 {
-	int nthreads = thread_map__nr(counter->core.threads);
+	int nthreads = perf_thread_map__nr(counter->core.threads);
 	int ncpus = perf_evsel__nr_cpus(counter);
 	int cpu, thread;
 	static int header_printed;
@@ -1928,7 +1928,7 @@ static void __process_stat(struct evsel *counter, u64 tstamp)
 
 			printf("%3d %8d %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %s\n",
 				counter->core.cpus->map[cpu],
-				thread_map__pid(counter->core.threads, thread),
+				perf_thread_map__pid(counter->core.threads, thread),
 				counts->val,
 				counts->ena,
 				counts->run,
tools/perf/builtin-stat.c +2 -2
index 90636a811b36..8a4f1a7d0cba 100644
@@ -264,7 +264,7 @@ static int read_single_counter(struct evsel *counter, int cpu,
  */
 static int read_counter(struct evsel *counter, struct timespec *rs)
 {
-	int nthreads = thread_map__nr(evsel_list->core.threads);
+	int nthreads = perf_thread_map__nr(evsel_list->core.threads);
 	int ncpus, cpu, thread;
 
 	if (target__has_cpu(&target) && !target__has_per_thread(&target))
@@ -1893,7 +1893,7 @@ int cmd_stat(int argc, const char **argv)
 		thread_map__read_comms(evsel_list->core.threads);
 		if (target.system_wide) {
 			if (runtime_stat_new(&stat_config,
-				thread_map__nr(evsel_list->core.threads))) {
+				perf_thread_map__nr(evsel_list->core.threads))) {
 				goto out;
 			}
 		}
tools/perf/builtin-trace.c +2 -2
index bc44ed29e05a..de126258ca10 100644
@@ -3188,7 +3188,7 @@ static int trace__set_filter_pids(struct trace *trace)
 			err = bpf_map__set_filter_pids(trace->filter_pids.map, trace->filter_pids.nr,
 						       trace->filter_pids.entries);
 		}
-	} else if (thread_map__pid(trace->evlist->core.threads, 0) == -1) {
+	} else if (perf_thread_map__pid(trace->evlist->core.threads, 0) == -1) {
 		err = trace__set_filter_loop_pids(trace);
 	}
 
@@ -3417,7 +3417,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
 		evlist__enable(evlist);
 	}
 
-	trace->multiple_threads = thread_map__pid(evlist->core.threads, 0) == -1 ||
+	trace->multiple_threads = perf_thread_map__pid(evlist->core.threads, 0) == -1 ||
 				  evlist->core.threads->nr > 1 ||
 				  perf_evlist__first(evlist)->core.attr.inherit;
 
tools/perf/lib/include/perf/threadmap.h +2 -0
index 456295273daa..a7c50de8d010 100644
@@ -11,6 +11,8 @@ LIBPERF_API struct perf_thread_map *perf_thread_map__new_dummy(void);
 
 LIBPERF_API void perf_thread_map__set_pid(struct perf_thread_map *map, int thread, pid_t pid);
 LIBPERF_API char *perf_thread_map__comm(struct perf_thread_map *map, int thread);
+LIBPERF_API int perf_thread_map__nr(struct perf_thread_map *threads);
+LIBPERF_API pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread);
 
 LIBPERF_API struct perf_thread_map *perf_thread_map__get(struct perf_thread_map *map);
 LIBPERF_API void perf_thread_map__put(struct perf_thread_map *map);
tools/perf/lib/libperf.map +2 -0
index 3373dd51fcda..dc4d66363bc4 100644
@@ -12,6 +12,8 @@ LIBPERF_0.0.1 {
 		perf_thread_map__new_dummy;
 		perf_thread_map__set_pid;
 		perf_thread_map__comm;
+		perf_thread_map__nr;
+		perf_thread_map__pid;
 		perf_thread_map__get;
 		perf_thread_map__put;
 		perf_evsel__new;
tools/perf/lib/threadmap.c +10 -0
index 4865b73e2586..e92c368b0a6c 100644
@@ -79,3 +79,13 @@ void perf_thread_map__put(struct perf_thread_map *map)
 	if (map && refcount_dec_and_test(&map->refcnt))
 		perf_thread_map__delete(map);
 }
+
+int perf_thread_map__nr(struct perf_thread_map *threads)
+{
+	return threads ? threads->nr : 1;
+}
+
+pid_t perf_thread_map__pid(struct perf_thread_map *map, int thread)
+{
+	return map->map[thread].pid;
+}
tools/perf/tests/thread-map.c +3 -3
index d61773cacf0b..d803eafedc60 100644
@@ -26,7 +26,7 @@ int test__thread_map(struct test *test __maybe_unused, int subtest __maybe_unuse
 
 	TEST_ASSERT_VAL("wrong nr", map->nr == 1);
 	TEST_ASSERT_VAL("wrong pid",
-			thread_map__pid(map, 0) == getpid());
+			perf_thread_map__pid(map, 0) == getpid());
 	TEST_ASSERT_VAL("wrong comm",
 			perf_thread_map__comm(map, 0) &&
 			!strcmp(perf_thread_map__comm(map, 0), NAME));
@@ -41,7 +41,7 @@ int test__thread_map(struct test *test __maybe_unused, int subtest __maybe_unuse
 	thread_map__read_comms(map);
 
 	TEST_ASSERT_VAL("wrong nr", map->nr == 1);
-	TEST_ASSERT_VAL("wrong pid", thread_map__pid(map, 0) == -1);
+	TEST_ASSERT_VAL("wrong pid", perf_thread_map__pid(map, 0) == -1);
 	TEST_ASSERT_VAL("wrong comm",
 			perf_thread_map__comm(map, 0) &&
 			!strcmp(perf_thread_map__comm(map, 0), "dummy"));
@@ -68,7 +68,7 @@ static int process_event(struct perf_tool *tool __maybe_unused,
 
 	TEST_ASSERT_VAL("wrong nr", threads->nr == 1);
 	TEST_ASSERT_VAL("wrong pid",
-			thread_map__pid(threads, 0) == getpid());
+			perf_thread_map__pid(threads, 0) == getpid());
 	TEST_ASSERT_VAL("wrong comm",
 			perf_thread_map__comm(threads, 0) &&
 			!strcmp(perf_thread_map__comm(threads, 0), NAME));
tools/perf/util/auxtrace.c +2 -2
index 60428576426e..094e6ceb3cf2 100644
@@ -132,12 +132,12 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,
 	if (per_cpu) {
 		mp->cpu = evlist->core.cpus->map[idx];
 		if (evlist->core.threads)
-			mp->tid = thread_map__pid(evlist->core.threads, 0);
+			mp->tid = perf_thread_map__pid(evlist->core.threads, 0);
 		else
 			mp->tid = -1;
 	} else {
 		mp->cpu = -1;
-		mp->tid = thread_map__pid(evlist->core.threads, idx);
+		mp->tid = perf_thread_map__pid(evlist->core.threads, idx);
 	}
 }
 
tools/perf/util/event.c +4 -4
index f433da85c45e..332edef8d394 100644
@@ -647,7 +647,7 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
 	for (thread = 0; thread < threads->nr; ++thread) {
 		if (__event__synthesize_thread(comm_event, mmap_event,
 					       fork_event, namespaces_event,
-					       thread_map__pid(threads, thread), 0,
+					       perf_thread_map__pid(threads, thread), 0,
 					       process, tool, machine,
 					       mmap_data)) {
 			err = -1;
@@ -658,12 +658,12 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool,
 		 * comm.pid is set to thread group id by
 		 * perf_event__synthesize_comm
 		 */
-		if ((int) comm_event->comm.pid != thread_map__pid(threads, thread)) {
+		if ((int) comm_event->comm.pid != perf_thread_map__pid(threads, thread)) {
 			bool need_leader = true;
 
 			/* is thread group leader in thread_map? */
 			for (j = 0; j < threads->nr; ++j) {
-				if ((int) comm_event->comm.pid == thread_map__pid(threads, j)) {
+				if ((int) comm_event->comm.pid == perf_thread_map__pid(threads, j)) {
 					need_leader = false;
 					break;
 				}
@@ -997,7 +997,7 @@ int perf_event__synthesize_thread_map2(struct perf_tool *tool,
 		if (!comm)
 			comm = (char *) "";
 
-		entry->pid = thread_map__pid(threads, i);
+		entry->pid = perf_thread_map__pid(threads, i);
 		strncpy((char *) &entry->comm, comm, sizeof(entry->comm));
 	}
 
tools/perf/util/evlist.c +6 -6
index 68b7c949017e..ff415680fe0a 100644
@@ -316,7 +316,7 @@ static int perf_evlist__nr_threads(struct evlist *evlist,
 	if (evsel->system_wide)
 		return 1;
 	else
-		return thread_map__nr(evlist->core.threads);
+		return perf_thread_map__nr(evlist->core.threads);
 }
 
 void evlist__disable(struct evlist *evlist)
@@ -399,7 +399,7 @@ int perf_evlist__enable_event_idx(struct evlist *evlist,
 int perf_evlist__alloc_pollfd(struct evlist *evlist)
 {
 	int nr_cpus = perf_cpu_map__nr(evlist->core.cpus);
-	int nr_threads = thread_map__nr(evlist->core.threads);
+	int nr_threads = perf_thread_map__nr(evlist->core.threads);
 	int nfds = 0;
 	struct evsel *evsel;
 
@@ -531,7 +531,7 @@ static void perf_evlist__set_sid_idx(struct evlist *evlist,
 	else
 		sid->cpu = -1;
 	if (!evsel->system_wide && evlist->core.threads && thread >= 0)
-		sid->tid = thread_map__pid(evlist->core.threads, thread);
+		sid->tid = perf_thread_map__pid(evlist->core.threads, thread);
 	else
 		sid->tid = -1;
 }
@@ -696,7 +696,7 @@ static struct perf_mmap *perf_evlist__alloc_mmap(struct evlist *evlist,
 
 	evlist->nr_mmaps = perf_cpu_map__nr(evlist->core.cpus);
 	if (perf_cpu_map__empty(evlist->core.cpus))
-		evlist->nr_mmaps = thread_map__nr(evlist->core.threads);
+		evlist->nr_mmaps = perf_thread_map__nr(evlist->core.threads);
 	map = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
 	if (!map)
 		return NULL;
@@ -810,7 +810,7 @@ static int perf_evlist__mmap_per_cpu(struct evlist *evlist,
 {
 	int cpu, thread;
 	int nr_cpus = perf_cpu_map__nr(evlist->core.cpus);
-	int nr_threads = thread_map__nr(evlist->core.threads);
+	int nr_threads = perf_thread_map__nr(evlist->core.threads);
 
 	pr_debug2("perf event ring buffer mmapped per cpu\n");
 	for (cpu = 0; cpu < nr_cpus; cpu++) {
@@ -838,7 +838,7 @@ static int perf_evlist__mmap_per_thread(struct evlist *evlist,
 					struct mmap_params *mp)
 {
 	int thread;
-	int nr_threads = thread_map__nr(evlist->core.threads);
+	int nr_threads = perf_thread_map__nr(evlist->core.threads);
 
 	pr_debug2("perf event ring buffer mmapped per thread\n");
 	for (thread = 0; thread < nr_threads; thread++) {
tools/perf/util/evsel.c +2 -2
index 7b4350681d64..e983e721beca 100644
@@ -1653,7 +1653,7 @@ static bool ignore_missing_thread(struct evsel *evsel,
 				  struct perf_thread_map *threads,
 				  int thread, int err)
 {
-	pid_t ignore_pid = thread_map__pid(threads, thread);
+	pid_t ignore_pid = perf_thread_map__pid(threads, thread);
 
 	if (!evsel->ignore_missing_thread)
 		return false;
@@ -1816,7 +1816,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,
 			int fd, group_fd;
 
 			if (!evsel->cgrp && !evsel->system_wide)
-				pid = thread_map__pid(threads, thread);
+				pid = perf_thread_map__pid(threads, thread);
 
 			group_fd = get_group_fd(evsel, cpu, thread);
 retry_open:
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
index 51771fc0d0df..78c8bc9380bd 100644
@@ -1406,7 +1406,7 @@ static void python_process_stat(struct perf_stat_config *config,
 	for (thread = 0; thread < threads->nr; thread++) {
 		for (cpu = 0; cpu < cpus->nr; cpu++) {
 			process_stat(counter, cpus->map[cpu],
-				     thread_map__pid(threads, thread), tstamp,
+				     perf_thread_map__pid(threads, thread), tstamp,
 				     perf_counts(counter->counts, cpu, thread));
 		}
 	}
tools/perf/util/stat-display.c +2 -2
index 605a1fdbda7a..51d6781aa90d 100644
@@ -119,7 +119,7 @@ static void aggr_printout(struct perf_stat_config *config,
 			config->csv_output ? 0 : 16,
 			perf_thread_map__comm(evsel->core.threads, id),
 			config->csv_output ? 0 : -8,
-			thread_map__pid(evsel->core.threads, id),
+			perf_thread_map__pid(evsel->core.threads, id),
 			config->csv_sep);
 		break;
 	case AGGR_GLOBAL:
@@ -745,7 +745,7 @@ static void print_aggr_thread(struct perf_stat_config *config,
 			      struct evsel *counter, char *prefix)
 {
 	FILE *output = config->output;
-	int nthreads = thread_map__nr(counter->core.threads);
+	int nthreads = perf_thread_map__nr(counter->core.threads);
 	int ncpus = perf_cpu_map__nr(counter->core.cpus);
 	int thread, sorted_threads, id;
 	struct perf_aggr_thread_value *buf;
tools/perf/util/stat.c +2 -2
index 1e6a25abe00f..0cbfd1eca1dd 100644
@@ -159,7 +159,7 @@ static void perf_evsel__free_prev_raw_counts(struct evsel *evsel)
 static int perf_evsel__alloc_stats(struct evsel *evsel, bool alloc_raw)
 {
 	int ncpus = perf_evsel__nr_cpus(evsel);
-	int nthreads = thread_map__nr(evsel->core.threads);
+	int nthreads = perf_thread_map__nr(evsel->core.threads);
 
 	if (perf_evsel__alloc_stat_priv(evsel) < 0 ||
 	    perf_evsel__alloc_counts(evsel, ncpus, nthreads) < 0 ||
@@ -309,7 +309,7 @@ process_counter_values(struct perf_stat_config *config, struct evsel *evsel,
 static int process_counter_maps(struct perf_stat_config *config,
 				struct evsel *counter)
 {
-	int nthreads = thread_map__nr(counter->core.threads);
+	int nthreads = perf_thread_map__nr(counter->core.threads);
 	int ncpus = perf_evsel__nr_cpus(counter);
 	int cpu, thread;
 
tools/perf/util/thread_map.c +2 -2
index c58385ea05be..3e64525bf604 100644
@@ -310,7 +310,7 @@ size_t thread_map__fprintf(struct perf_thread_map *threads, FILE *fp)
 	size_t printed = fprintf(fp, "%d thread%s: ",
 				 threads->nr, threads->nr > 1 ? "s" : "");
 	for (i = 0; i < threads->nr; ++i)
-		printed += fprintf(fp, "%s%d", i ? ", " : "", thread_map__pid(threads, i));
+		printed += fprintf(fp, "%s%d", i ? ", " : "", perf_thread_map__pid(threads, i));
 
 	return printed + fprintf(fp, "\n");
 }
@@ -341,7 +341,7 @@ static int get_comm(char **comm, pid_t pid)
 
 static void comm_init(struct perf_thread_map *map, int i)
 {
-	pid_t pid = thread_map__pid(map, i);
+	pid_t pid = perf_thread_map__pid(map, i);
 	char *comm = NULL;
 
 	/* dummy pid comm initialization */
tools/perf/util/thread_map.h +0 -10
index ba45c760be72..ca165fdf6cb0 100644
@@ -25,16 +25,6 @@ struct perf_thread_map *thread_map__new_by_tid_str(const char *tid_str);
 
 size_t thread_map__fprintf(struct perf_thread_map *threads, FILE *fp);
 
-static inline int thread_map__nr(struct perf_thread_map *threads)
-{
-	return threads ? threads->nr : 1;
-}
-
-static inline pid_t thread_map__pid(struct perf_thread_map *map, int thread)
-{
-	return map->map[thread].pid;
-}
-
 void thread_map__read_comms(struct perf_thread_map *threads);
 bool thread_map__has(struct perf_thread_map *threads, pid_t pid);
 int thread_map__remove(struct perf_thread_map *threads, int idx);
Signature · 1 line
2.21.0
author maintainer
#24 lore raw

PATCH 24/25 perf c2c: Fix report with offline cpus

In reply to Arnaldo Carvalho de Melo

From: Ravi Bangoria <[email protected]>

If c2c is recorded on a machine where any cpus are offline, 'perf c2c report' throws an error "node/cpu topology bugFailed setup nodes".

It fails because while preparing node-cpu mapping we don't consider offline cpus.

---
 tools/perf/builtin-c2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-c2c.c +1 -1
index 01629f5b6d1f..211143720078 100644
@@ -2027,7 +2027,7 @@ static int setup_nodes(struct perf_session *session)
 		c2c.node_info = 2;
 
 	c2c.nodes_cnt = session->header.env.nr_numa_nodes;
-	c2c.cpus_cnt  = session->header.env.nr_cpus_online;
+	c2c.cpus_cnt  = session->header.env.nr_cpus_avail;
 
 	n = session->header.env.numa_nodes;
 	if (!n)
Signature · 1 line
2.21.0
author maintainer
#25 lore raw

PATCH 25/25 libperf: Fix alignment trap with xyarray contents in 'perf stat'

In reply to Arnaldo Carvalho de Melo

From: Gerald BAEZA <[email protected]>

Following the patch 'perf stat: Fix --no-scale', an alignment trap happens in process_counter_values() on ARMv7 platforms due to the attempt to copy non 64 bits aligned double words (pointed by 'count') via a NEON vectored instruction ('vld1' with 64 bits alignment constraint).

This patch sets a 64 bits alignment constraint on 'contents[]' field in 'struct xyarray' since the 'count' pointer used above points to such a structure.

---
 tools/perf/lib/include/internal/xyarray.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/lib/include/internal/xyarray.h +2 -1
index 3bf70e4d474c..51e35d6c8ec4 100644
@@ -2,6 +2,7 @@
 #ifndef __LIBPERF_INTERNAL_XYARRAY_H
 #define __LIBPERF_INTERNAL_XYARRAY_H
 
+#include <linux/compiler.h>
 #include <sys/types.h>
 
 struct xyarray {
@@ -10,7 +11,7 @@ struct xyarray {
 	size_t entries;
 	size_t max_x;
 	size_t max_y;
-	char contents[];
+	char contents[] __aligned(8);
 };
 
 struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size);
Signature · 1 line
2.21.0
#26 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 127 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 4e92b18e5b0b61211f4511cdbc5803300eeead40:

Merge tag 'perf-core-for-mingo-5.4-20190820' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2019-08-20 21:38:22 +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-20190822

for you to fetch changes up to d9c5c083416500e95da098c01be092b937def7fa:

libperf: Fix alignment trap with xyarray contents in 'perf stat' (2019-08-22 17:16:57 -0300)

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

perf c2c:

Ravi Bangoria:

- Fix report with offline cpus.

libperf:

Gerald BAEZA:

- Fix alignment trap with xyarray contents in 'perf stat', noticed on ARMv7.

Jiri Olsa:

- Move some more cpu_map and thread_map methods from tools/perf/util/ to libperf.

headers:

Arnaldo Carvalho de Melo:

- Do some house cleaning on the headers, removing needless includes in some places, providing forward declarations when those are the only thing needed, and fixing up the fallout from that for cases where we were using stuff and not adding the necessary headers. Should speed up the build and avoid needless rebuilds when something unrelated gets touched.

----------------------------------------------------------------
Arnaldo Carvalho de Melo (18):
perf arm64: Add missing debug.h header
perf kvm s390: Add missing string.h header
perf metricgroup: Remove needless includes from metricgroup.h perf evsel: Move xyarray.h from evsel.c to evsel.h to reduce include dep tree perf counts: Add missing headers needed for types used
perf bpf: Add missing xyarray.h header
perf evlist: Add missing xyarray.h header
perf script: Add missing counts.h
perf tests: Add missing counts.h
perf stat: Add missing counts.h
perf scripting python: Add missing counts.h header
perf evsel: Add missing perf/evsel.h header in util/evsel.h
perf evsel: Remove needless counts.h header from util/evsel.h perf evsel: Remove needless stddef.h from util/evsel.h
perf evsel: util/evsel.h needs stdio.h as it uses FILE
perf x86 kvm-stat: Add missing string.h header
perf evsel: Switch to libperf's cpumap.h
perf cpumap: Remove needless includes from cpumap.h

Gerald BAEZA (1):
libperf: Fix alignment trap with xyarray contents in 'perf stat'

Jiri Olsa (5):
tools headers: Add missing perf_event.h include
perf tools: Use perf_cpu_map__nr instead of cpu_map__nr
libperf: Move perf's cpu_map__empty() to perf_cpu_map__empty()
libperf: Move perf's cpu_map__idx() to perf_cpu_map__idx()
libperf: Add perf_thread_map__nr/perf_thread_map__pid functions

Ravi Bangoria (1):
perf c2c: Fix report with offline cpus

 tools/include/linux/ring_buffer.h                  |  1 +
 tools/perf/arch/arm/util/cs-etm.c                  | 12 ++++----
 tools/perf/arch/arm64/util/header.c                |  1 +
 tools/perf/arch/s390/util/kvm-stat.c               |  1 +
 tools/perf/arch/x86/util/header.c                  |  1 +
 tools/perf/arch/x86/util/intel-bts.c               |  4 +--
 tools/perf/arch/x86/util/intel-pt.c                | 10 +++----
 tools/perf/arch/x86/util/kvm-stat.c                |  1 +
 tools/perf/builtin-c2c.c                           |  4 +--
 tools/perf/builtin-ftrace.c                        |  2 +-
 tools/perf/builtin-script.c                        |  5 ++--
 tools/perf/builtin-stat.c                          |  8 +++---
 tools/perf/builtin-trace.c                         |  4 +--
 tools/perf/lib/cpumap.c                            | 17 ++++++++++++
 tools/perf/lib/include/internal/cpumap.h           |  2 ++
 tools/perf/lib/include/internal/xyarray.h          |  3 +-
 tools/perf/lib/include/perf/cpumap.h               |  2 ++
 tools/perf/lib/include/perf/threadmap.h            |  2 ++
 tools/perf/lib/libperf.map                         |  3 ++
 tools/perf/lib/threadmap.c                         | 10 +++++++
 tools/perf/tests/mem2node.c                        |  1 +
 tools/perf/tests/openat-syscall-all-cpus.c         |  1 +
 tools/perf/tests/openat-syscall.c                  |  1 +
 tools/perf/tests/thread-map.c                      |  6 ++--
 tools/perf/util/auxtrace.c                         |  4 +--
 tools/perf/util/bpf-loader.c                       |  2 ++
 tools/perf/util/counts.h                           |  4 +++
 tools/perf/util/cpumap.c                           | 22 ++++-----------
 tools/perf/util/cpumap.h                           | 17 ++----------
 tools/perf/util/cputopo.c                          |  2 ++
 tools/perf/util/env.c                              |  1 +
 tools/perf/util/event.c                            | 10 +++----
 tools/perf/util/evlist.c                           | 32 ++++++++++++----------
 tools/perf/util/evsel.c                            |  6 ++--
 tools/perf/util/evsel.h                            | 12 +++++---
 tools/perf/util/mem2node.c                         |  1 +
 tools/perf/util/metricgroup.c                      |  3 +-
 tools/perf/util/metricgroup.h                      | 13 +++++----
 tools/perf/util/mmap.c                             |  2 +-
 tools/perf/util/pmu.c                              |  1 +
Quoted 8 lines
 tools/perf/util/record.c                           |  2 +-
 .../util/scripting-engines/trace-event-python.c    |  3 +-
 tools/perf/util/stat-display.c                     |  7 +++--
 tools/perf/util/stat.c                             |  7 +++--
 tools/perf/util/svghelper.c                        |  1 +
 tools/perf/util/thread_map.c                       |  4 +--
 tools/perf/util/thread_map.h                       | 10 -------
 47 files changed, 155 insertions(+), 113 deletions(-)

Pulled, thanks a lot Arnaldo!

Ingo