30 Dec, 2020

1 commit

  • [ Upstream commit 09d59c2f3465fb01e65a0c96698697b026ea8e79 ]

    We're missing -lcap in test-all.bin target, so in case it's the only
    library missing (if more are missing test-all.bin fails anyway), we will
    falsely claim that we detected it and fail build, like:

    $ make
    ...
    Auto-detecting system features:
    ... dwarf: [ on ]
    ... dwarf_getlocations: [ on ]
    ... glibc: [ on ]
    ... libbfd: [ on ]
    ... libbfd-buildid: [ on ]
    ... libcap: [ on ]
    ... libelf: [ on ]
    ... libnuma: [ on ]
    ... numa_num_possible_cpus: [ on ]
    ... libperl: [ on ]
    ... libpython: [ on ]
    ... libcrypto: [ on ]
    ... libunwind: [ on ]
    ... libdw-dwarf-unwind: [ on ]
    ... zlib: [ on ]
    ... lzma: [ on ]
    ... get_cpuid: [ on ]
    ... bpf: [ on ]
    ... libaio: [ on ]
    ... libzstd: [ on ]
    ... disassembler-four-args: [ on ]

    ...

    CC builtin-ftrace.o

    In file included from builtin-ftrace.c:29:
    util/cap.h:11:10: fatal error: sys/capability.h: No such file or directory
    11 | #include
    | ^~~~~~~~~~~~~~~~~~
    compilation terminated.

    Fixes: 74d5f3d06f707eb5 ("tools build: Add capability-related feature detection")
    Signed-off-by: Jiri Olsa
    Cc: Alexander Shishkin
    Cc: Ian Rogers
    Cc: Igor Lubashev
    Cc: Mark Rutland
    Cc: Michael Petlan
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Link: http://lore.kernel.org/lkml/20201203230836.3751981-1-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Jiri Olsa
     

03 Nov, 2020

1 commit

  • 22dd1ac91a776752 ("tools: Remove feature-libelf-mmap feature detection")
    correctly simplified the this feature detection, but forgot to remove
    the call to the removed function in the main() function for the
    test-all.c fast path feature detection, making it fail and thus do all
    the feature detection individually, fix it.

    $ cat /tmp/build/perf/feature/test-all.make.output
    test-all.c: In function ‘main’:
    test-all.c:188:2: error: implicit declaration of function ‘main_test_libelf_mmap’; did you mean ‘main_test_libelf’? [-Werror=implicit-function-declaration]
    188 | main_test_libelf_mmap();
    | ^~~~~~~~~~~~~~~~~~~~~
    | main_test_libelf
    cc1: all warnings being treated as errors
    $ vim tools/build/feature/test-all.c
    $ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf ;make V=1 -k O=/tmp/build/perf -C tools/perf install-bin ; perf test python

    $ cat /tmp/build/perf/feature/test-all.make.output
    $

    Fixes: 22dd1ac91a776752 ("tools: Remove feature-libelf-mmap feature detection")
    Cc: Alexei Starovoitov
    Cc: Andrii Nakryiko
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

18 Oct, 2020

1 commit

  • …x/kernel/git/acme/linux

    Pull perf tools updates from Arnaldo Carvalho de Melo:

    - cgroup improvements for 'perf stat', allowing for compact
    specification of events and cgroups in the command line.

    - Support per thread topdown metrics in 'perf stat'.

    - Support sample-read topdown metric group in 'perf record'

    - Show start of latency in addition to its start in 'perf sched
    latency'.

    - Add min, max to 'perf script' futex-contention output, in addition to
    avg.

    - Allow usage of 'perf_event_attr->exclusive' attribute via the new
    ':e' event modifier.

    - Add 'snapshot' command to 'perf record --control', using it with
    Intel PT.

    - Support FIFO file names as alternative options to 'perf record
    --control'.

    - Introduce branch history "streams", to compare 'perf record' runs
    with 'perf diff' based on branch records and report hot streams.

    - Support PE executable symbol tables using libbfd, to profile, for
    instance, wine binaries.

    - Add filter support for option 'perf ftrace -F/--funcs'.

    - Allow configuring the 'disassembler_style' 'perf annotate' knob via
    'perf config'

    - Update CascadelakeX and SkylakeX JSON vendor events files.

    - Add support for parsing perchip/percore JSON vendor events.

    - Add power9 hv_24x7 core level metric events.

    - Add L2 prefetch, ITLB instruction fetch hits JSON events for AMD
    zen1.

    - Enable Family 19h users by matching Zen2 AMD vendor events.

    - Use debuginfod in 'perf probe' when required debug files not found
    locally.

    - Display negative tid in non-sample events in 'perf script'.

    - Make GTK2 support opt-in

    - Add build test with GTK+

    - Add missing -lzstd to the fast path feature detection

    - Add scripts to auto generate 'mmap', 'mremap' string<->id tables for
    use in 'perf trace'.

    - Show python test script in verbose mode.

    - Fix uncore metric expressions

    - Msan uninitialized use fixes.

    - Use condition variables in 'perf bench numa'

    - Autodetect python3 binary in systems without python2.

    - Support md5 build ids in addition to sha1.

    - Add build id 'perf test' regression test.

    - Fix printable strings in python3 scripts.

    - Fix off by ones in 'perf trace' in arches using libaudit.

    - Fix JSON event code for events referencing std arch events.

    - Introduce 'perf test' shell script for Arm CoreSight testing.

    - Add rdtsc() for Arm64 for used in the PERF_RECORD_TIME_CONV metadata
    event and in 'perf test tsc'.

    - 'perf c2c' improvements: Add "RMT Load Hit" metric, "Total Stores",
    fixes and documentation update.

    - Fix usage of reloc_sym in 'perf probe' when using both kallsyms and
    debuginfo files.

    - Do not print 'Metric Groups:' unnecessarily in 'perf list'

    - Refcounting fixes in the event parsing code.

    - Add expand cgroup event 'perf test' entry.

    - Fix out of bounds CPU map access when handling armv8_pmu events in
    'perf stat'.

    - Add build-id injection 'perf bench' benchmark.

    - Enter namespace when reading build-id in 'perf inject'.

    - Do not load map/dso when injecting build-id speeding up the 'perf
    inject' process.

    - Add --buildid-all option to avoid processing all samples, just the
    mmap metadata events.

    - Add feature test to check if libbfd has buildid support

    - Add 'perf test' entry for PE binary format support.

    - Fix typos in power8 PMU vendor events JSON files.

    - Hide libtraceevent non API functions.

    * tag 'perf-tools-for-v5.10-2020-10-15' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: (113 commits)
    perf c2c: Update documentation for metrics reorganization
    perf c2c: Add metrics "RMT Load Hit"
    perf c2c: Correct LLC load hit metrics
    perf c2c: Change header for LLC local hit
    perf c2c: Use more explicit headers for HITM
    perf c2c: Change header from "LLC Load Hitm" to "Load Hitm"
    perf c2c: Organize metrics based on memory hierarchy
    perf c2c: Display "Total Stores" as a standalone metrics
    perf c2c: Display the total numbers continuously
    perf bench: Use condition variables in numa.
    perf jevents: Fix event code for events referencing std arch events
    perf diff: Support hot streams comparison
    perf streams: Report hot streams
    perf streams: Calculate the sum of total streams hits
    perf streams: Link stream pair
    perf streams: Compare two streams
    perf streams: Get the evsel_streams by evsel_idx
    perf streams: Introduce branch history "streams"
    perf intel-pt: Improve PT documentation slightly
    perf tools: Add support for exclusive groups/events
    ...

    Linus Torvalds
     

09 Sep, 2020

1 commit

  • We were failing that due to GTK2+ and then for the ZSTD test, which made
    test-all.c, the fast path feature detection file to fail and thus
    trigger building all of the feature tests, slowing down the test.

    Eventually the ZSTD test would be built and would succeed, since it had
    the needed -lzstd, avoiding:

    $ cat /tmp/build/perf/feature/test-all.make.output
    /usr/bin/ld: /tmp/ccRRJQ4u.o: in function `main_test_libzstd':
    /home/acme/git/perf/tools/build/feature/test-libzstd.c:8: undefined reference to `ZSTD_createCStream'
    /usr/bin/ld: /home/acme/git/perf/tools/build/feature/test-libzstd.c:9: undefined reference to `ZSTD_freeCStream'
    collect2: error: ld returned 1 exit status
    $

    Fix it by adding -lzstd to the test-all target.

    Now I need an entry to 'perf test' to make sure that
    /tmp/build/perf/feature/test-all.make.output is empty...

    Fixes: 3b1c5d9659718263 ("tools build: Implement libzstd feature check, LIBZSTD_DIR and NO_LIBZSTD defines")
    Reviewed-by: Alexei Budankov
    Acked-by: Namhyung Kim
    Cc: Adrian Hunter
    Cc: Ian Rogers
    Cc: Jiri Olsa
    Link: http://lore.kernel.org/lkml/20200904202611.GJ3753976@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

05 Sep, 2020

2 commits


28 Aug, 2020

1 commit

  • The system for "Auto-detecting system features" located under
    tools/build/ are (currently) used by perf, libbpf and bpftool. It can
    contain stalled feature detection files, which are not cleaned up by
    libbpf and bpftool on make clean (side-note: perf tool is correct).

    Fix this by making the users invoke the make clean target.

    Some details about the changes. The libbpf Makefile already had a
    clean-config target (which seems to be copy-pasted from perf), but this
    target was not "connected" (a make dependency) to clean target. Choose
    not to rename target as someone might be using it. Did change the output
    from "CLEAN config" to "CLEAN feature-detect", to make it more clear
    what happens.

    This is related to the complaint and troubleshooting in the following
    link: https://lore.kernel.org/lkml/20200818122007.2d1cfe2d@carbon/

    Signed-off-by: Jesper Dangaard Brouer
    Signed-off-by: Daniel Borkmann
    Acked-by: Jiri Olsa
    Link: https://lore.kernel.org/lkml/20200818122007.2d1cfe2d@carbon/
    Link: https://lore.kernel.org/bpf/159851841661.1072907.13770213104521805592.stgit@firesoul

    Jesper Dangaard Brouer
     

19 Aug, 2020

1 commit

  • It's trivial to handle missing ELF_C_MMAP_READ support in libelf the way that
    objtool has solved it in
    ("774bec3fddcc objtool: Add fallback from ELF_C_READ_MMAP to ELF_C_READ").

    So instead of having an entire feature detector for that, just do what objtool
    does for perf and libbpf. And keep their Makefiles a bit simpler.

    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20200819013607.3607269-5-andriin@fb.com

    Andrii Nakryiko
     

14 Aug, 2020

1 commit

  • During a perf-record, use the -ldebuginfod API to query a debuginfod
    server, should the debug data not be found in the usual system
    locations. If successful, the usual $HOME/.debug dir is populated.

    Tested with:

    $ find .
    .
    ./ctags-debuginfo-5.8-26.fc31.x86_64.rpm
    ./usr
    ./usr/lib
    ./usr/lib/debug
    ./usr/lib/debug/.build-id
    ./usr/lib/debug/.build-id/ca
    ./usr/lib/debug/.build-id/ca/46f6ae6a0cee57d85abc1d461c49074248908d
    ./usr/lib/debug/.build-id/ca/46f6ae6a0cee57d85abc1d461c49074248908d.debug
    ./usr/lib/debug/usr
    ./usr/lib/debug/usr/bin
    ./usr/lib/debug/usr/bin/ctags-5.8-26.fc31.x86_64.debug

    $ debuginfod -F .
    ...

    $ rm -rf ~/.debug/ ; mkdir ~/.debug

    $ perf record make tags
    BUILD: Doing 'make -j8' parallel build
    GEN tags
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.107 MB perf.data (1483 samples) ]

    $ find ~/.debug | grep ctags
    /home/jolsa/.debug/usr/bin/ctags
    /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d
    /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d/elf
    /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d/probes

    $ rm -rf ~/.debug/ ; mkdir ~/.debug

    $ DEBUGINFOD_URLS=http://localhost:8002 perf record make tags
    BUILD: Doing 'make -j8' parallel build
    GEN tags
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.108 MB perf.data (1531 samples) ]

    $ find ~/.debug | grep ctag
    /home/jolsa/.debug/usr/bin/ctags
    /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d
    /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d/debug
    /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d/elf
    /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d/probes

    Note the 'debug' file is created in the last run.

    Note that currently the debuginfo data are downloaded only on record path,
    we still need add this support to perf build-id/report.. and test ;-)

    Tested-by: Jiri Olsa
    Signed-off-by: Jiri Olsa
    Signed-off-by: Frank Ch. Eigler
    Signed-off-by: Arnaldo Carvalho de Melo

    Frank Ch. Eigler
     

13 Aug, 2020

1 commit

  • When using a cross-compilation environment, such as OpenEmbedded,
    the CC an CXX variables are set to something more than just a
    command: there are arguments (such as --sysroot) that need to be
    passed on to the compiler so that the right set of headers and
    libraries are used.

    For the particular case that our systems detected, CC is set to
    the following:

    export CC="aarch64-linaro-linux-gcc --sysroot=/oe/build/tmp/work/machine/perf/1.0-r9/recipe-sysroot"

    Without quotes, detection is as follows:

    Auto-detecting system features:
    ... dwarf: [ OFF ]
    ... dwarf_getlocations: [ OFF ]
    ... glibc: [ OFF ]
    ... gtk2: [ OFF ]
    ... libbfd: [ OFF ]
    ... libcap: [ OFF ]
    ... libelf: [ OFF ]
    ... libnuma: [ OFF ]
    ... numa_num_possible_cpus: [ OFF ]
    ... libperl: [ OFF ]
    ... libpython: [ OFF ]
    ... libcrypto: [ OFF ]
    ... libunwind: [ OFF ]
    ... libdw-dwarf-unwind: [ OFF ]
    ... zlib: [ OFF ]
    ... lzma: [ OFF ]
    ... get_cpuid: [ OFF ]
    ... bpf: [ OFF ]
    ... libaio: [ OFF ]
    ... libzstd: [ OFF ]
    ... disassembler-four-args: [ OFF ]

    Makefile.config:414: *** No gnu/libc-version.h found, please install glibc-dev[el]. Stop.
    Makefile.perf:230: recipe for target 'sub-make' failed
    make[1]: *** [sub-make] Error 2
    Makefile:69: recipe for target 'all' failed
    make: *** [all] Error 2

    With CC and CXX quoted, some of those features are now detected.

    Fixes: e3232c2f39ac ("tools build feature: Use CC and CXX from parent")
    Signed-off-by: Daniel Díaz
    Reviewed-by: Thomas Hebb
    Cc: Alexei Starovoitov
    Cc: Andrii Nakryiko
    Cc: Daniel Borkmann
    Cc: Jiri Olsa
    Cc: John Fastabend
    Cc: KP Singh
    Cc: Martin KaFai Lau
    Cc: Namhyung Kim
    Cc: Song Liu
    Cc: Stephane Eranian
    Cc: Yonghong Song
    Link: http://lore.kernel.org/lkml/20200812221518.2869003-1-daniel.diaz@linaro.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Daniel Díaz
     

06 Aug, 2020

1 commit

  • To sync headers, for instance, in this case tools/perf was ahead of
    upstream till Linus merged tip/perf/core to get the
    PERF_RECORD_TEXT_POKE changes:

    Warning: Kernel ABI header at 'tools/include/uapi/linux/perf_event.h' differs from latest version at 'include/uapi/linux/perf_event.h'
    diff -u tools/include/uapi/linux/perf_event.h include/uapi/linux/perf_event.h

    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

03 Aug, 2020

1 commit

  • The '&&' command seems to have a bad effect when $(cmd_$(1)) exits with
    non-zero effect: the command failure is masked (despite `set -e`) and all but
    the first command of $(dep-cmd) is executed (successfully, as they are mostly
    printfs), thus overall returning 0 in the end.

    This means in practice that despite compilation errors, tools's build Makefile
    will return success. We see this very reliably with libbpf's Makefile, which
    doesn't get compilation error propagated properly. This in turns causes issues
    with selftests build, as well as bpftool and other projects that rely on
    building libbpf.

    The fix is simple: don't use &&. Given `set -e`, we don't need to chain
    commands with &&. The shell will exit on first failure, giving desired
    behavior and propagating error properly.

    Fixes: 275e2d95591e ("tools build: Move dependency copy into function")
    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Daniel Borkmann
    Acked-by: Jiri Olsa
    Link: https://lore.kernel.org/bpf/20200731024244.872574-1-andriin@fb.com

    Andrii Nakryiko
     

31 Jul, 2020

1 commit

  • commit c8c188679ccf ("tools build: Use the same CC for feature detection
    and actual build") changed these assignments from unconditional (:=) to
    conditional (?=) so that they wouldn't clobber values from the
    environment. However, conditional assignment does not work properly for
    variables that Make implicitly sets, among which are CC and CXX. To
    quote tools/scripts/Makefile.include, which handles this properly:

    # Makefiles suck: This macro sets a default value of $(2) for the
    # variable named by $(1), unless the variable has been set by
    # environment or command line. This is necessary for CC and AR
    # because make sets default values, so the simpler ?= approach
    # won't work as expected.

    In other words, the conditional assignments will not run even if the
    variables are not overridden in the environment; Make will set CC to
    "cc" and CXX to "g++" when it starts[1], meaning the variables are not
    empty by the time the conditional assignments are evaluated. This breaks
    cross-compilation when CROSS_COMPILE is set but CC isn't, since "cc"
    gets used for feature detection instead of the cross compiler (and
    likewise for CXX).

    To fix the issue, just pass down the values of CC and CXX computed by
    the parent Makefile, which gets included by the Makefile that actually
    builds whatever we're detecting features for and so is guaranteed to
    have good values. This is a better solution anyway, since it means we
    aren't trying to replicate the logic of the parent build system and so
    don't risk it getting out of sync.

    Leave PKG_CONFIG alone, since 1) there's no common logic to compute it
    in Makefile.include, and 2) it's not an implicit variable, so
    conditional assignment works properly.

    [1] https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html

    Fixes: c8c188679ccf ("tools build: Use the same CC for feature detection and actual build")
    Signed-off-by: Thomas Hebb
    Acked-by: Jiri Olsa
    Cc: David Carrillo-Cisneros
    Cc: Ian Rogers
    Cc: Igor Lubashev
    Cc: Namhyung Kim
    Cc: Quentin Monnet
    Cc: Song Liu
    Cc: Stephane Eranian
    Cc: thomas hebb
    Link: http://lore.kernel.org/lkml/0a6e69d1736b0fa231a648f50b0cce5d8a6734ef.1595822871.git.tommyhebb@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Thomas Hebb
     

23 Jun, 2020

1 commit

  • Adapt Makefile to support BPF skeleton generation beyond single profiler.bpf.c
    case. Also add vmlinux.h generation and switch profiler.bpf.c to use it.

    clang-bpf-global-var feature is extended and renamed to clang-bpf-co-re to
    check for support of preserve_access_index attribute, which, together with BTF
    for global variables, is the minimum requirement for modern BPF programs.

    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Alexei Starovoitov
    Reviewed-by: Quentin Monnet
    Link: https://lore.kernel.org/bpf/20200619231703.738941-7-andriin@fb.com

    Andrii Nakryiko
     

30 May, 2020

1 commit

  • Ingo reported that the libaudit was always appearing as OFF:

    Auto-detecting system features:
    ... dwarf: [ on ]
    ... dwarf_getlocations: [ on ]
    ... glibc: [ on ]
    ... gtk2: [ on ]
    ... libaudit: [ OFF ]

    And everything seemed to work, i.e. we were checking for a feature that
    we don't use, causing confusion for people building perf, so work to
    remove that nuisance while making sure that it works when an arch
    doesn't provide the alternative method to generate the syscall id/name
    conversion tables.

    Longer explanation of the new modus operandi:

    $ make -C tools/perf O=/tmp/build/perf NO_SYSCALL_TABLE=1

    Auto-detecting system features:
    ... dwarf: [ on ]
    ... dwarf_getlocations: [ on ]
    ... glibc: [ on ]
    ... gtk2: [ on ]
    ... libbfd: [ on ]
    ... libcap: [ on ]
    ... libelf: [ on ]
    ... libnuma: [ on ]
    ... numa_num_possible_cpus: [ on ]
    ... libperl: [ on ]
    ... libpython: [ on ]
    ... libcrypto: [ on ]
    ... libunwind: [ on ]
    ... libdw-dwarf-unwind: [ on ]
    ... zlib: [ on ]
    ... lzma: [ on ]
    ... get_cpuid: [ on ]
    ... bpf: [ on ]
    ... libaio: [ on ]
    ... libzstd: [ on ]
    ... disassembler-four-args: [ on ]

    Makefile.config:665: No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev
    GEN /tmp/build/perf/common-cmds.h
    MKDIR /tmp/build/perf/fd/
    MKDIR /tmp/build/perf/fs/

    $

    The libaudit test is forced and it fails when audit-libs-devel isn't available:

    $ cat /tmp/build/perf/feature/test-libaudit.make.output
    test-libaudit.c:2:10: fatal error: libaudit.h: No such file or directory
    2 | #include
    | ^~~~~~~~~~~~
    compilation terminated.
    $

    If we install audit-libs-devel and rebuild it continues not to be shown as OFF
    in the main auto-detection summary, but again gets tested and this time:

    $ rpm -q audit-libs-devel
    audit-libs-devel-3.0-0.15.20191104git1c2f876.fc31.x86_64
    $

    The make output for the feature detection comes clean:

    $ cat /tmp/build/perf/feature/test-libaudit.make.output

    And the feature detection binary is successfully built and is dynamicly linked
    with libaudit:

    $ ldd /tmp/build/perf/feature/test-libaudit.bin | grep audit
    libaudit.so.1 => /lib64/libaudit.so.1 (0x00007f5bf5177000)
    $

    As well as the resulting perf binary:

    $ ldd /tmp/build/perf/perf | grep audit
    libaudit.so.1 => /lib64/libaudit.so.1 (0x00007fad511c7000)
    $

    And 'perf trace' works using the libaudit method:

    $ sudo /tmp/build/perf/perf trace -e nanosleep sleep 1
    0.000 (1000.067 ms): sleep/281872 nanosleep(rqtp: 0x7ffedbbe69d0) = 0
    $

    If we leave audit-libs-devel installed but don't disable the use of the best
    method, the one using SYSCALL_TABLE, the default for architectures that provide
    the script to build the syscall id/name mapping using the .tbl files copied
    from the kernel sources, we get:

    $ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf
    $ make -C tools/perf O=/tmp/build/perf
    Auto-detecting system features:
    ... dwarf: [ on ]
    ... dwarf_getlocations: [ on ]
    ... glibc: [ on ]
    ... gtk2: [ on ]
    ... libbfd: [ on ]
    ... libcap: [ on ]
    ... libelf: [ on ]
    ... libnuma: [ on ]
    ... numa_num_possible_cpus: [ on ]
    ... libperl: [ on ]
    ... libpython: [ on ]
    ... libcrypto: [ on ]
    ... libunwind: [ on ]
    ... libdw-dwarf-unwind: [ on ]
    ... zlib: [ on ]
    ... lzma: [ on ]
    ... get_cpuid: [ on ]
    ... bpf: [ on ]
    ... libaio: [ on ]
    ... libzstd: [ on ]
    ... disassembler-four-args: [ on ]

    GEN /tmp/build/perf/common-cmds.h

    $

    Again, no mention of libaudit being on or OFF and:

    $ cat /tmp/build/perf/feature/test-libaudit.make.output
    cat: /tmp/build/perf/feature/test-libaudit.make.output: No such file or directory
    $

    We didn't even bother checking for its availability, slightly speeding up the
    build process and:

    $ ldd /tmp/build/perf/perf | grep libaudit
    $

    We don't link with it, also:

    $ sudo /tmp/build/perf/perf trace -e nanosleep sleep 1
    0.000 (1000.053 ms): sleep/299125 nanosleep(rqtp: 0x7ffc24611b50) = 0
    $

    And globs become available:

    $ sudo /tmp/build/perf/perf trace -e *sleep sleep 1
    0.000 (1000.072 ms): sleep/299136 nanosleep(rqtp: 0x7ffe7a3c4ff0) = 0
    $

    Reported-by: Ingo Molnar
    Cc: Adrian Hunter
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

06 May, 2020

2 commits

  • OpenCSD version v0.14.0 adds in a new output element. This is represented
    by a new value in the generic element type enum, which must be added to
    the handling code in perf cs-etm-decoder to prevent build errors due to
    build options on the perf project.

    This element is not currently used by the perf decoder.

    Perf build feature test updated to require a minimum of 0.14.0

    Tested on Linux 5.7-rc3.

    Signed-off-by: Mike Leach
    Reviewed-by: Leo Yan
    Reviewed-by: Mathieu Poirier
    Cc: Peter Zijlstra
    Cc: Suzuki Poulouse
    Cc: coresight@lists.linaro.org
    Cc: linux-arm-kernel@lists.infradead.org
    Link: http://lore.kernel.org/lkml/20200501143615.1180-1-mike.leach@linaro.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Mike Leach
     
  • libpfm4 provides an alternate command line encoding of perf events.

    Signed-off-by: Stephane Eranian
    Reviewed-by: Ian Rogers
    Acked-by: Jiri Olsa
    Cc: Adrian Hunter
    Cc: Alexander Shishkin
    Cc: Alexei Starovoitov
    Cc: Alexey Budankov
    Cc: Andi Kleen
    Cc: Andrii Nakryiko
    Cc: Daniel Borkmann
    Cc: Florian Fainelli
    Cc: Greg Kroah-Hartman
    Cc: Igor Lubashev
    Cc: Jin Yao
    Cc: Jiwei Sun
    Cc: John Garry
    Cc: Kan Liang
    Cc: Leo Yan
    Cc: Mark Rutland
    Cc: Martin KaFai Lau
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: Yonghong Song
    Cc: bpf@vger.kernel.org
    Cc: netdev@vger.kernel.org
    Cc: yuzhoujian
    Link: http://lore.kernel.org/lkml/20200429231443.207201-3-irogers@google.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Stephane Eranian
     

22 Apr, 2020

1 commit

  • Clang has -Wself-assign enabled by default under -Wall, which always
    gets -Werror'ed on this file, causing sync-compare-and-swap to be
    disabled by default.

    The generally-accepted way to spell "this value is intentionally
    unused," is casting it to `void`. This is accepted by both GCC and
    Clang with -Wall enabled: https://godbolt.org/z/qqZ9r3

    Signed-off-by: George Burgess IV
    Signed-off-by: Andrew Morton
    Cc: Nick Desaulniers
    Link: http://lkml.kernel.org/r/20200414195638.156123-1-gbiv@google.com
    Signed-off-by: Linus Torvalds

    George Burgess IV
     

06 Apr, 2020

1 commit

  • Pull more perf updates from Thomas Gleixner:
    "Perf updates all over the place:

    core:

    - Support for cgroup tracking in samples to allow cgroup based
    analysis

    tools:

    - Support for cgroup analysis

    - Commandline option and hotkey for perf top to change the sort order

    - A set of fixes all over the place

    - Various build system related improvements

    - Updates of the X86 pmu event JSON data

    - Documentation updates"

    * tag 'perf-urgent-2020-04-05' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (55 commits)
    perf python: Fix clang detection to strip out options passed in $CC
    perf tools: Support Python 3.8+ in Makefile
    perf script: Fix invalid read of directory entry after closedir()
    perf script report: Fix SEGFAULT when using DWARF mode
    perf script: add -S/--symbols documentation
    perf pmu-events x86: Use CPU_CLK_UNHALTED.THREAD in Kernel_Utilization metric
    perf events parser: Add missing Intel CPU events to parser
    perf script: Allow --symbol to accept hexadecimal addresses
    perf report/top TUI: Fix title line formatting
    perf top: Support hotkey to change sort order
    perf top: Support --group-sort-idx to change the sort order
    perf symbols: Fix arm64 gap between kernel start and module end
    perf build-test: Honour JOBS to override detection of number of cores
    perf script: Add --show-cgroup-events option
    perf top: Add --all-cgroups option
    perf record: Add --all-cgroups option
    perf record: Support synthesizing cgroup events
    perf report: Add 'cgroup' sort key
    perf cgroup: Maintain cgroup hierarchy
    perf tools: Basic support for CGROUP event
    ...

    Linus Torvalds
     

04 Apr, 2020

1 commit

  • Pull SPDX updates from Greg KH:
    "Here are three SPDX patches for 5.7-rc1.

    One fixes up the SPDX tag for a single driver, while the other two go
    through the tree and add SPDX tags for all of the .gitignore files as
    needed.

    Nothing too complex, but you will get a merge conflict with your
    current tree, that should be trivial to handle (one file modified by
    two things, one file deleted.)

    All three of these have been in linux-next for a while, with no
    reported issues other than the merge conflict"

    * tag 'spdx-5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/spdx:
    ASoC: MT6660: make spdxcheck.py happy
    .gitignore: add SPDX License Identifier
    .gitignore: remove too obvious comments

    Linus Torvalds
     

03 Apr, 2020

1 commit

  • The file handle (FHANDLE) support is configurable so some systems might not
    have it. So add a config feature item to check it on build time so that we
    don't add the cgroup tracking feature based on that.

    Committer notes:

    Had to make the test use the same construct as its later use in
    synthetic-events.c, in the next patch in this series. i.e. make it be:

    struct {
    struct file_handle fh;
    uint64_t cgroup_id;
    } handle;

    To cope with:

    CC /tmp/build/perf/util/cloexec.o
    util/synthetic-events.c:428:22: error: field 'fh' with CC /tmp/build/perf/util/call-path.o
    variable sized type 'struct file_handle' not at the end of a struct or class is a GNU
    extension [-Werror,-Wgnu-variable-sized-type-not-at-end]
    struct file_handle fh;
    ^
    1 error generated.

    Deal with this at some point, i.e. investigate if the right thing is to
    remove that -Wgnu-variable-sized-type-not-at-end from our CFLAGS, for
    now do the test the same way as it is used looks more sensible.

    Reported-by: Arnaldo Carvalho de Melo
    Signed-off-by: Namhyung Kim
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: Jiri Olsa
    Cc: Mark Rutland
    Cc: Peter Zijlstra
    Link: http://lore.kernel.org/lkml/20200402015249.3800462-1-namhyung@kernel.org
    [ split from a larger patch, removed blank line at EOF ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     

25 Mar, 2020

1 commit


13 Mar, 2020

1 commit

  • bpftool-prog-profile requires clang to generate BTF for global variables.
    When compared with older clang, skip this command. This is achieved by
    adding a new feature, clang-bpf-global-var, to tools/build/feature.

    Signed-off-by: Song Liu
    Signed-off-by: Daniel Borkmann
    Reviewed-by: Quentin Monnet
    Link: https://lore.kernel.org/bpf/20200312182332.3953408-2-songliubraving@fb.com

    Song Liu
     

14 Jan, 2020

2 commits

  • Ravi Bangoria reported an issue when doing the gtk2 feature detection on
    Fedora 31, where some types got deprecated:

    /usr/include/gtk-2.0/gtk/gtktypeutils.h:236:1: error: ‘GTypeDebugFlags’ is deprecated [-Werror=deprecated-declarations]
    236 | void gtk_type_init (GTypeDebugFlags debug_flags);

    Fix this for perf by allowing the compile to pass with deprecated
    symbols via the -Wno-deprecated-declarations compiler directive.

    Reported-by: Ravi Bangoria
    Signed-off-by: Jiri Olsa
    Tested-by: Ravi Bangoria
    Cc: Alexander Shishkin
    Cc: Jelle van der Waa
    Cc: Michael Petlan
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lore.kernel.org/lkml/20200113104358.123511-2-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     
  • LLVM rL344140 (included in Clang 8+) moved VFS from Clang to LLVM, so
    paths to its include files have changed.

    This broke the Clang test in tools/build - let's fix it.

    Signed-off-by: Maciej S. Szmigiero
    Cc: Alexander Shishkin
    Cc: Denis Pronin
    Cc: Dennis Schridde
    Cc: Jiri Olsa
    Cc: Mark Rutland
    Cc: Namhyung Kim
    Cc: Naohiro Aota
    Cc: Peter Zijlstra
    Cc: clang-built-linux@googlegroups.com
    Link: http://lore.kernel.org/lkml/20191228171314.946469-1-mail@maciej.szmigiero.name
    Signed-off-by: Arnaldo Carvalho de Melo

    Maciej S. Szmigiero
     

26 Nov, 2019

1 commit

  • Currently we support only static linking with kernel's libbpf
    (tools/lib/bpf). This patch adds libbpf package detection and support to
    link perf with it dynamically.

    The libbpf package status is displayed with:

    $ make VF=1
    Auto-detecting system features:
    ...
    ... libbpf: [ on ]

    It's not checked by default, because it's quite new. Once it's on most
    distros we can switch it on.

    For the same reason it's not added to the test-all check.

    Perf does not need advanced version of libbpf, so we can check just for
    the base bpf_object__open function.

    Adding new compile variable to detect libbpf package and link bpf
    dynamically:

    $ make LIBBPF_DYNAMIC=1
    ...
    LINK perf
    $ ldd perf | grep bpf
    libbpf.so.0 => /lib64/libbpf.so.0 (0x00007f46818bc000)

    If libbpf is not installed, build stops with:

    Makefile.config:486: *** Error: No libbpf devel library found,\
    please install libbpf-devel. Stop.

    Committer testing:

    $ make LIBBPF_DYNAMIC=1 -C tools/perf O=/tmp/build/perf
    make: Entering directory '/home/acme/git/perf/tools/perf'
    BUILD: Doing 'make -j8' parallel build
    Makefile.config:493: *** Error: No libbpf devel library found, please install libbpf-devel. Stop.
    make[1]: *** [Makefile.perf:225: sub-make] Error 2
    make: *** [Makefile:70: all] Error 2
    make: Leaving directory '/home/acme/git/perf/tools/perf'
    $

    Signed-off-by: Jiri Olsa
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Toke Høiland-Jørgensen
    Cc: Alexander Shishkin
    Cc: Alexei Starovoitov
    Cc: Andrii Nakryiko
    Cc: Daniel Borkmann
    Cc: Jesper Dangaard Brouer
    Cc: Martin KaFai Lau
    Cc: Michael Petlan
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Song Liu
    Cc: Yonghong Song
    Cc: bpf@vger.kernel.org
    Cc: netdev@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20191126121253.28253-1-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Jiri Olsa
     

13 Aug, 2019

1 commit

  • Add utilities to help checking capabilities of the running procss. Make
    perf link with libcap, if it is available. If no libcap-dev[el], assume
    no capabilities.

    Committer testing:

    $ make O=/tmp/build/perf -C tools/perf install-bin
    make: Entering directory '/home/acme/git/perf/tools/perf'
    BUILD: Doing 'make -j8' parallel build

    Auto-detecting system features:

    ... libbfd: [ on ]
    ... libcap: [ OFF ]
    ... libelf: [ on ]

    Makefile.config:833: No libcap found, disables capability support, please install libcap-devel/libcap-dev

    $ grep libcap /tmp/build/perf/FEATURE-DUMP
    feature-libcap=0
    $ cat /tmp/build/perf/feature/test-libcap.make.output
    test-libcap.c:2:10: fatal error: sys/capability.h: No such file or directory
    2 | #include
    | ^~~~~~~~~~~~~~~~~~
    compilation terminated.
    $

    Now install libcap-devel and try again:

    $ make O=/tmp/build/perf -C tools/perf install-bin
    make: Entering directory '/home/acme/git/perf/tools/perf'
    BUILD: Doing 'make -j8' parallel build
    Warning: Kernel ABI header at 'tools/include/linux/bits.h' differs from latest version at 'include/linux/bits.h'
    diff -u tools/include/linux/bits.h include/linux/bits.h
    Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
    diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h

    Auto-detecting system features:

    ... libbfd: [ on ]
    ... libcap: [ on ]
    ... libelf: [ on ]
    >
    CC /tmp/build/perf/jvmti/libjvmti.o
    >
    $ grep libcap /tmp/build/perf/FEATURE-DUMP
    feature-libcap=1
    $ cat /tmp/build/perf/feature/test-libcap.make.output
    $ ldd /tmp/build/perf/feature/test-libcap.make.bin
    ldd: /tmp/build/perf/feature/test-libcap.make.bin: No such file or directory
    $ ldd /tmp/build/perf/feature/test-libcap.bin
    linux-vdso.so.1 (0x00007ffc35bfe000)
    libcap.so.2 => /lib64/libcap.so.2 (0x00007ff9c62ff000)
    libc.so.6 => /lib64/libc.so.6 (0x00007ff9c6139000)
    /lib64/ld-linux-x86-64.so.2 (0x00007ff9c6326000)
    $

    Signed-off-by: Igor Lubashev
    Acked-by: Jiri Olsa
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: Alexey Budankov
    Cc: James Morris
    Cc: Mathieu Poirier
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Suzuki Poulouse
    [ split from a larger patch ]
    Link: http://lkml.kernel.org/r/8a1e76cf5c7c9796d0d4d240fbaa85305298aafa.1565188228.git.ilubashe@akamai.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Igor Lubashev
     

19 Jun, 2019

2 commits

  • We were renanimg 'main' to 'main_zstd' but then using 'main_libzstd();'
    in the main() for test-all.c, causing this:

    $ cat /tmp/build/perf/feature/test-all.make.output
    test-all.c: In function ‘main’:
    test-all.c:236:2: error: implicit declaration of function ‘main_test_libzstd’; did you mean ‘main_test_zstd’? [-Werror=implicit-function-declaration]
    main_test_libzstd();
    ^~~~~~~~~~~~~~~~~
    main_test_zstd
    cc1: all warnings being treated as errors
    $

    I.e. what was supposed to be the fast path feature test was _always_
    failing, duh, fix it.

    Cc: Adrian Hunter
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Alexey Budankov
    Fixes: 3b1c5d965971 ("tools build: Implement libzstd feature check, LIBZSTD_DIR and NO_LIBZSTD defines")
    Link: https://lkml.kernel.org/n/tip-ma4abk0utroiw4mwpmvnjlru@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • A few odd old distros (rhel5, 6, yeah, lots of those out in use, in many
    cases we want to use upstream perf on it) have the slang header files in
    /usr/include/slang/, so add a test that will be performed only when
    test-all.c (the one with the most common sane settings) fails, either
    because we're in one of these odd distros with slang/slang.h or because
    something else failed (say libelf is not present).

    So for the common case nothing changes, no additional test is performed.

    Next step is to check in perf the result of these tests.

    Cc: Adrian Hunter
    Cc: Florian Fainelli
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Fixes: 1955c8cf5e26 ("perf tools: Don't hardcode host include path for libslang")
    Link: https://lkml.kernel.org/n/tip-2sy7hbwkx68jr6n97qxgg0c6@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

18 Jun, 2019

3 commits

  • Hardcoding /usr/include/slang is fundamentally incompatible with cross
    compilation and will lead to the inability for a cross-compiled
    environment to properly detect whether slang is available or not.

    If /usr/include/slang is necessary that is a distribution specific
    knowledge that could be solved with either a standard pkg-config .pc
    file (which slang has) or simply overriding CFLAGS accordingly, but the
    default perf Makefile should be clean of all of that.

    Signed-off-by: Florian Fainelli
    Cc: Alexander Shishkin
    Cc: Alexey Budankov
    Cc: bcm-kernel-feedback-list@broadcom.com
    Cc: Jakub Kicinski
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Quentin Monnet
    Cc: Stanislav Fomichev
    Fixes: ef7b93a11904 ("perf report: Librarize the annotation code and use it in the newt browser")
    Link: http://lkml.kernel.org/r/20190614183949.5588-1-f.fainelli@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Florian Fainelli
     
  • Cc: Adrian Hunter
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Link: https://lkml.kernel.org/n/tip-3h6fa866w6ao0wsbyqz9nrm8@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • Laura reported that the perf build failed in fedora when we got a glibc
    that provides gettid(), which I reproduced using fedora rawhide with the
    glibc-devel-2.29.9000-26.fc31.x86_64 package.

    Add a feature check to avoid providing a gettid() helper in such
    systems.

    On a fedora rawhide system with this patch applied we now get:

    [root@7a5f55352234 perf]# grep gettid /tmp/build/perf/FEATURE-DUMP
    feature-gettid=1
    [root@7a5f55352234 perf]# cat /tmp/build/perf/feature/test-gettid.make.output
    [root@7a5f55352234 perf]# ldd /tmp/build/perf/feature/test-gettid.bin
    linux-vdso.so.1 (0x00007ffc6b1f6000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f04e0a74000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f04e0c47000)
    [root@7a5f55352234 perf]# nm /tmp/build/perf/feature/test-gettid.bin | grep -w gettid
    U gettid@@GLIBC_2.30
    [root@7a5f55352234 perf]#

    While on a fedora:29 system:

    [acme@quaco perf]$ grep gettid /tmp/build/perf/FEATURE-DUMP
    feature-gettid=0
    [acme@quaco perf]$ cat /tmp/build/perf/feature/test-gettid.make.output
    test-gettid.c: In function ‘main’:
    test-gettid.c:8:9: error: implicit declaration of function ‘gettid’; did you mean ‘getgid’? [-Werror=implicit-function-declaration]
    return gettid();
    ^~~~~~
    getgid
    cc1: all warnings being treated as errors
    [acme@quaco perf]$

    Reported-by: Laura Abbott
    Tested-by: Laura Abbott
    Acked-by: Jiri Olsa
    Cc: Adrian Hunter
    Cc: Florian Weimer
    Cc: Namhyung Kim
    Cc: Stephane Eranian
    Link: https://lkml.kernel.org/n/tip-yfy3ch53agmklwu9o7rlgf9c@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

21 May, 2019

1 commit


02 Apr, 2019

1 commit

  • Implement libzstd feature check, NO_LIBZSTD and LIBZSTD_DIR defines to
    override Zstd library sources or disable the feature from the command
    line:

    $ make -C tools/perf LIBZSTD_DIR=/path/to/zstd/sources/ clean all
    $ make -C tools/perf NO_LIBZSTD=1 clean all

    Auto detection feature status is reported just before compilation
    starts. If your system has some version of the zstd library
    preinstalled then the build system finds and uses it during the build.

    If you still prefer to compile with some other version of zstd library
    you have capability to refer the compilation to that version using
    LIBZSTD_DIR define.

    Signed-off-by: Alexey Budankov
    Reviewed-by: Jiri Olsa
    Cc: Alexander Shishkin
    Cc: Andi Kleen
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/9b4cd8b0-10a3-1f1e-8d6b-5922a7ca216b@linux.intel.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Alexey Budankov
     

29 Mar, 2019

1 commit

  • The following error was thrown when compiling `tools/perf` using OpenCSD
    v0.11.1. This patch fixes said error.

    CC util/intel-pt-decoder/intel-pt-log.o
    CC util/cs-etm-decoder/cs-etm-decoder.o
    util/cs-etm-decoder/cs-etm-decoder.c: In function
    ‘cs_etm_decoder__buffer_range’:
    util/cs-etm-decoder/cs-etm-decoder.c:370:2: error: enumeration value
    ‘OCSD_INSTR_WFI_WFE’ not handled in switch [-Werror=switch-enum]
    switch (elem->last_i_type) {
    ^~~~~~
    CC util/intel-pt-decoder/intel-pt-decoder.o
    cc1: all warnings being treated as errors

    Because `OCSD_INSTR_WFI_WFE` case was added only in v0.11.0, the minimum
    required OpenCSD library version for this patch is no longer v0.10.0.

    Signed-off-by: Solomon Tan
    Cc: Alexander Shishkin
    Cc: Jiri Olsa
    Cc: Mathieu Poirier
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Robert Walker
    Cc: Suzuki K Poulouse
    Cc: linux-arm-kernel@lists.infradead.org
    Link: http://lkml.kernel.org/r/20190322052255.GA4809@w-OptiPlex-7050
    Signed-off-by: Arnaldo Carvalho de Melo

    Solomon Tan
     

21 Mar, 2019

1 commit

  • Commit 003ca0fd2286 ("Refactor disassembler selection") in the binutils
    repo, which changed the disassembler() function signature, so we must
    use the feature test introduced in fb982666e380 ("tools/bpftool: fix
    bpftool build with bintutils >= 2.9") to deal with that.

    Committer testing:

    After adding the missing function call to test-all.c, and:

    FEATURE_CHECK_LDFLAGS-disassembler-four-args = -bfd -lopcodes

    And the fallbacks for cases where we need -liberty and sometimes -lz to
    tools/perf/Makefile.config, we get:

    $ make -C tools/perf O=/tmp/build/perf install-bin
    make: Entering directory '/home/acme/git/perf/tools/perf'
    BUILD: Doing 'make -j8' parallel build

    Auto-detecting system features:
    ... dwarf: [ on ]
    ... dwarf_getlocations: [ on ]
    ... glibc: [ on ]
    ... gtk2: [ on ]
    ... libaudit: [ on ]
    ... libbfd: [ on ]
    ... libelf: [ on ]
    ... libnuma: [ on ]
    ... numa_num_possible_cpus: [ on ]
    ... libperl: [ on ]
    ... libpython: [ on ]
    ... libslang: [ on ]
    ... libcrypto: [ on ]
    ... libunwind: [ on ]
    ... libdw-dwarf-unwind: [ on ]
    ... zlib: [ on ]
    ... lzma: [ on ]
    ... get_cpuid: [ on ]
    ... bpf: [ on ]
    ... libaio: [ on ]
    ... disassembler-four-args: [ on ]
    CC /tmp/build/perf/jvmti/libjvmti.o
    CC /tmp/build/perf/builtin-bench.o

    $
    $

    The feature detection test-all.bin gets successfully built and linked:

    $ ls -la /tmp/build/perf/feature/test-all.bin
    -rwxrwxr-x. 1 acme acme 2680352 Mar 19 11:07 /tmp/build/perf/feature/test-all.bin
    $ nm /tmp/build/perf/feature/test-all.bin | grep -w disassembler
    0000000000061f90 T disassembler
    $

    Time to move on to the patches that make use of this disassembler()
    routine in binutils's libopcodes.

    Signed-off-by: Song Liu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Alexei Starovoitov
    Cc: Daniel Borkmann
    Cc: Jakub Kicinski
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Roman Gushchin
    Cc: Stanislav Fomichev
    Link: http://lkml.kernel.org/r/20190312053051.2690567-13-songliubraving@fb.com
    [ split from a larger patch, added missing FEATURE_CHECK_LDFLAGS-disassembler-four-args ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Song Liu
     

15 Feb, 2019

4 commits

  • Since this feature test is included in test-all.c, the feature detection
    fast path compile/link phase, it can't leave any defines behind, as it
    can affect the tests included after it, so remove it.

    Reported-by: Jiri Olsa
    Cc: Adrian Hunter
    Cc: Alexei Starovoitov
    Cc: Andrii Nakryiko
    Cc: Daniel Borkmann
    Cc: Jakub Kicinski
    Cc: Jin Yao
    Cc: Namhyung Kim
    Cc: Song Liu
    Cc: Yonghong Song
    Link: https://lkml.kernel.org/n/tip-lg3kpd9tzypc797vb1f42u6k@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • When a test is in the FEATURE_TESTS_BASIC list in tools/build/Makefile.feature
    must be added to tools/build/feature/test-all.c, because the successfull
    compilation and linking of that test-all.bin file means that all the
    features listed in FEATURE_TESTS_BASIC are present in the system, so we
    don't have to go on feature by feature test building them.

    Since reallocarray() is expected to be present in modern systems, it has
    a place in FEATURE_TESTS_BASIC, so that we speed up the build process
    building just that file.

    For older systems, such as ubuntu:16.04 (build failure reported by Jin
    Yao) debian:8, and for the current flagship RHEL distro, RHEL7, the
    build will fail as test-all.bin (without test-reallocarray.c included)
    passes but reallocarray() isn't present, making the build fail with:

    CC /tmp/build/perf/libbpf.o
    MKDIR /tmp/build/perf/fs/
    CC /tmp/build/perf/fs/tracing_path.o
    LD /tmp/build/perf/fd/libapi-in.o
    CC /tmp/build/perf/bpf.o
    libbpf.c: In function 'bpf_object__add_program':
    libbpf.c:367:10: error: implicit declaration of function 'reallocarray' [-Werror=implicit-function-declaration]
    progs = reallocarray(progs, nr_progs + 1, sizeof(progs[0]));
    ^
    libbpf.c:367:2: error: nested extern declaration of 'reallocarray' [-Werror=nested-externs]
    progs = reallocarray(progs, nr_progs + 1, sizeof(progs[0]));
    ^
    libbpf.c:367:8: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
    progs = reallocarray(progs, nr_progs + 1, sizeof(progs[0]));
    ^
    libbpf.c: In function 'bpf_object__elf_collect':
    libbpf.c:887:10: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
    reloc = reallocarray(reloc, nr_reloc,
    ^
    libbpf.c: In function 'bpf_program__reloc_text':
    libbpf.c:1394:12: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
    new_insn = reallocarray(prog->insns, new_cnt, sizeof(*insn));
    ^
    CC /tmp/build/perf/nlattr.o

    Even with:

    $ grep reallocarray /tmp/build/perf/FEATURE-DUMP
    feature-reallocarray=1
    $

    Which ubuntu:16.04.5 LTS doesn't have:

    perfbuilder@38a153a1bba8:/$ head -2 /etc/os-release
    NAME="Ubuntu"
    VERSION="16.04.5 LTS (Xenial Xerus)"
    perfbuilder@38a153a1bba8:/$ find /usr/include/ -name "*.h" | xargs grep -w reallocarray
    perfbuilder@38a153a1bba8:/$

    Fix it by including it to test-all.c, which ends up forcing the
    individual tests to be triggered and for the build process to notice
    that indeed reallocarray() is not there:

    perfbuilder@38a153a1bba8:/$ cat /tmp/build/perf/feature/test-all.make.output
    In file included from test-all.c:178:0:
    test-reallocarray.c: In function 'main_test_reallocarray':
    test-reallocarray.c:7:11: error: implicit declaration of function 'reallocarray' [-Werror=implicit-function-declaration]
    return !!reallocarray(NULL, 1, 1);
    ^
    cc1: all warnings being treated as errors
    perfbuilder@38a153a1bba8:/$

    That is the only test that is failing on Ubuntu 16.03.5 LTS, so all
    tests are forced:

    perfbuilder@38a153a1bba8:/tmp/build/perf/feature$ ls -lSr *.make.output

    -rw-r--r--. 1 perfbuilder perfbuilder 0 Feb 14 15:00 test-dwarf.make.output
    -rw-r--r--. 1 perfbuilder perfbuilder 0 Feb 14 14:16 test-cplus-demangle.make.output
    -rw-r--r--. 1 perfbuilder perfbuilder 0 Feb 14 15:00 test-bpf.make.output
    -rw-r--r--. 1 perfbuilder perfbuilder 0 Feb 14 15:00 test-backtrace.make.output
    -rw-r--r--. 1 perfbuilder perfbuilder 104 Feb 14 15:00 test-bionic.make.output
    -rw-r--r--. 1 perfbuilder perfbuilder 107 Feb 14 15:00 test-libunwind-x86.make.output
    -rw-r--r--. 1 perfbuilder perfbuilder 115 Feb 14 15:00 test-libunwind-aarch64.make.output
    -rw-r--r--. 1 perfbuilder perfbuilder 122 Feb 14 15:00 test-libbabeltrace.make.output
    -rw-r--r--. 1 perfbuilder perfbuilder 254 Feb 14 15:00 test-reallocarray.make.output
    -rw-r--r--. 1 perfbuilder perfbuilder 312 Feb 14 15:00 test-all.make.output
    perfbuilder@38a153a1bba8:/tmp/build/perf/feature$

    And that reallocarray() one shows:

    perfbuilder@38a153a1bba8:/tmp/build/perf/feature$ cat test-reallocarray.make.output
    test-reallocarray.c: In function 'main':
    test-reallocarray.c:7:11: error: implicit declaration of function 'reallocarray' [-Werror=implicit-function-declaration]
    return !!reallocarray(NULL, 1, 1);
    ^
    cc1: all warnings being treated as errors
    perfbuilder@38a153a1bba8:/tmp/build/perf/feature$

    Which now generates the expected result:

    perfbuilder@38a153a1bba8:~$ grep reallocarray /tmp/build/perf/FEATURE-DUMP
    feature-reallocarray=0
    perfbuilder@38a153a1bba8:~$

    The fallback mechanism kicks in and libbpf and perf are again buildable
    in systems without reallocarray():

    $ cat tools/include/tools/libc_compat.h
    // SPDX-License-Identifier: (LGPL-2.0+ OR BSD-2-Clause)
    /* Copyright (C) 2018 Netronome Systems, Inc. */

    #ifndef __TOOLS_LIBC_COMPAT_H
    #define __TOOLS_LIBC_COMPAT_H

    #include
    #include

    #ifdef COMPAT_NEED_REALLOCARRAY
    static inline void *reallocarray(void *ptr, size_t nmemb, size_t size)
    {
    size_t bytes;

    if (unlikely(check_mul_overflow(nmemb, size, &bytes)))
    return NULL;
    return realloc(ptr, bytes);
    }
    #endif
    #endif
    $

    Reported-by: Jin Yao
    Acked-by: Jiri Olsa
    Cc: Adrian Hunter
    Cc: Alexei Starovoitov
    Cc: Andrii Nakryiko
    Cc: Daniel Borkmann
    Cc: Jakub Kicinski
    Cc: Namhyung Kim
    Cc: Song Liu
    Cc: Yonghong Song
    Fixes: 531b014e7a2f ("tools: bpf: make use of reallocarray")
    Link: https://lkml.kernel.org/n/tip-aonqku8axii8rxki5g11w40b@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • As it is not normally available on x86_64 not being tested on test-all.c
    but being in FEATURE_TESTS_BASIC ends up implying that those features
    are present, which leads to trying to link with those libraries and a
    build failure now that test-all.c is finally again building
    successfully:

    /usr/bin/ld: cannot find -lunwind-x86
    /usr/bin/ld: cannot find -lunwind-aarch64
    collect2: error: ld returned 1 exit status
    make[3]: *** [Makefile:199: /tmp/build/perf/plugin_jbd2.so] Error 1
    make[3]: *** Waiting for unfinished jobs....
    /usr/bin/ld: cannot find -lunwind-x86
    /usr/bin/ld: cannot find -lunwind-aarch64

    So remove those features from there and explicitely test them.

    And then move this patch to just before the last one that allows this to
    be exposed, so that we keep the tree bisectable.

    With all this in place we get, at this point:

    $ ldd /tmp/build/perf/feature/test-libunwind.bin
    linux-vdso.so.1 (0x00007fffa09c6000)
    libunwind-x86_64.so.8 => /lib64/libunwind-x86_64.so.8 (0x00007fbcf4451000)
    libunwind.so.8 => /lib64/libunwind.so.8 (0x00007fbcf4435000)
    liblzma.so.5 => /lib64/liblzma.so.5 (0x00007fbcf440c000)
    libelf.so.1 => /lib64/libelf.so.1 (0x00007fbcf43f2000)
    libc.so.6 => /lib64/libc.so.6 (0x00007fbcf422c000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fbcf4211000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fbcf4491000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fbcf41ed000)
    libz.so.1 => /lib64/libz.so.1 (0x00007fbcf41d3000)
    $ cat /tmp/build/perf/feature/test-libunwind-x86.make.output
    test-libunwind-x86.c:2:10: fatal error: libunwind-x86.h: No such file or directory
    #include
    ^~~~~~~~~~~~~~~~~
    compilation terminated.
    $ cat /tmp/build/perf/feature/test-libunwind-aarch64.make.output
    test-libunwind-aarch64.c:2:10: fatal error: libunwind-aarch64.h: No such file or directory
    #include
    ^~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    $
    $ ldd ~/bin/perf | grep unwind
    libunwind-x86_64.so.8 => /lib64/libunwind-x86_64.so.8 (0x00007f5ceb24b000)
    libunwind.so.8 => /lib64/libunwind.so.8 (0x00007f5ceb22f000)
    $

    Cc: Adrian Hunter
    Cc: He Kuang
    Cc: Jean Pihet
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Cc: Will Deacon
    Link: https://lkml.kernel.org/n/tip-vs6kwqsvwk7oxhs6z9mq87pp@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • Since it is not yet that generally available, avoid testing for the
    presence of libcoresight in the fast path test-all.bin feature test.

    # dnf search opencsd
    No matches found.
    # dnf search OpenCSD
    No matches found.
    # cat /etc/fedora-release
    Fedora release 29 (Twenty Nine)
    #

    I.e. right now, in my system test-all.bin is failing all the time since
    Fedora29 doesn't have libopencsd available:

    $ cat /tmp/build/perf/feature/test-all.make.output
    In file included from test-all.c:174:
    test-libopencsd.c:2:10: fatal error: opencsd/c_api/opencsd_c_api.h: No such file or directory
    #include
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.

    See:

    6ab2b762befd ("perf build: Disable libbabeltrace check by default")

    For the rationale, as soon as libopencsd becomes more generally packaged
    and available, we do the same thing we did with babeltrace, enabling it
    by default, as done in:

    24787afbcd01 ("perf tools: Enable LIBBABELTRACE by default")

    For now, to explicitely ask for opencsd, make sure you have it installed
    and use:

    make -C tools/perf CORESIGHT=1

    The feature test output will be there as an empty file:

    $ ls -la /tmp/build/perf/feature/test-libopencsd.make.output

    Because the binary used for the feature check was successfully built:

    $ ls -la /tmp/build/perf/feature/test-libopencsd.bin
    -rwxrwxr-x. 1 acme acme 18336 Feb 12 14:49 /tmp/build/perf/feature/test-libopencsd.bin
    $ ldd /tmp/build/perf/feature/test-libopencsd.bin
    linux-vdso.so.1 (0x00007fffe18cc000)
    libopencsd_c_api.so.0 => /lib64/libopencsd_c_api.so.0 (0x00007fb8e67f6000)
    libopencsd.so.0 => /lib64/libopencsd.so.0 (0x00007fb8e676f000)
    libc.so.6 => /lib64/libc.so.6 (0x00007fb8e65a9000)
    libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fb8e6411000)
    libm.so.6 => /lib64/libm.so.6 (0x00007fb8e628d000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fb8e6272000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fb8e6828000)
    $

    And the resulting perf binary will be linked with it:

    -rw-rw-r--. 1 acme acme 0 Feb 12 14:49 /tmp/build/perf/feature/test-libopencsd.make.output
    $ ldd ~/bin/perf | grep opencsd
    libopencsd_c_api.so.0 => /lib64/libopencsd_c_api.so.0 (0x00007fd43097f000)
    libopencsd.so.0 => /lib64/libopencsd.so.0 (0x00007fd4308f8000)
    $

    To make sure this gets built before pushing things upstream I have a
    ubuntu:19.04-x-arm64 container that has:

    [root@quaco x-arm64]# grep CORESIGHT Dockerfile
    ENV EXTRA_MAKE_ARGS=CORESIGHT=1
    [root@quaco x-arm64]#

    So that I always build with libopencsd before pushing things upstream.

    Cc: Adrian Hunter
    Cc: Alexander Shishkin
    Cc: Jiri Olsa
    Cc: Kim Phillips
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: Mathieu Poirier
    Cc: Mike Leach
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Suzuki Poulouse
    Link: https://lkml.kernel.org/n/tip-20vyy39jw9jgrijesi30fgox@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo