Skip to content
Snippets Groups Projects
  1. Sep 10, 2024
    • James Clark's avatar
      perf build: Remove unused feature test target · 332f60ac
      James Clark authored
      
      llvm-version was removed in commit 56b11a21 ("perf bpf: Remove
      support for embedding clang for compiling BPF events (-e foo.c)") but
      some parts were left in the Makefile so finish removing them.
      
      Signed-off-by: default avatarJames Clark <james.clark@linaro.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Bill Wendling <morbo@google.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Daniel Wagner <dwagner@suse.de>
      Cc: Guilherme Amadio <amadio@gentoo.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Justin Stitt <justinstitt@google.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@arm.com>
      Cc: Manu Bretelle <chantr4@gmail.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <qmo@kernel.org>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Link: https://lore.kernel.org/r/20240910140405.568791-2-james.clark@linaro.org
      
      
      [ Removed one leftover, 'llvm-version' from FEATURE_TESTS_EXTRA ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      332f60ac
    • James Clark's avatar
      perf build: Autodetect minimum required llvm-dev version · 206dcfca
      James Clark authored
      
      The new LLVM addr2line feature requires a minimum version of 13 to
      compile. Add a feature check for the version so that NO_LLVM=1 doesn't
      need to be explicitly added. Leave the existing llvm feature check
      intact because it's used by tools other than Perf.
      
      This fixes the following compilation error when the llvm-dev version
      doesn't match:
      
        util/llvm-c-helpers.cpp: In function 'char* llvm_name_for_code(dso*, const char*, u64)':
        util/llvm-c-helpers.cpp:178:21: error: 'std::remove_reference_t<llvm::DILineInfo>' {aka 'struct llvm::DILineInfo'} has no member named 'StartAddress'
          178 |   addr, res_or_err->StartAddress ? *res_or_err->StartAddress : 0);
      
      Fixes: c3f8644c ("perf report: Support LLVM for addr2line()")
      Signed-off-by: default avatarJames Clark <james.clark@linaro.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Bill Wendling <morbo@google.com>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Guilherme Amadio <amadio@gentoo.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Justin Stitt <justinstitt@google.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@arm.com>
      Cc: Manu Bretelle <chantr4@gmail.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <qmo@kernel.org>
      Cc: Steinar H. Gunderson <sesse@google.com>
      Link: https://lore.kernel.org/r/20240910140405.568791-1-james.clark@linaro.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      206dcfca
  2. Sep 03, 2024
    • Steinar H. Gunderson's avatar
      perf report: Support LLVM for addr2line() · c3f8644c
      Steinar H. Gunderson authored
      
      In addition to the existing support for libbfd and calling out to
      an external addr2line command, add support for using libllvm directly.
      
      This is both faster than libbfd, and can be enabled in distro builds
      (the LLVM license has an explicit provision for GPLv2 compatibility).
      
      Thus, it is set as the primary choice if available.
      
      As an example, running 'perf report' on a medium-size profile with
      DWARF-based backtraces took 58 seconds with LLVM, 78 seconds with
      libbfd, 153 seconds with external llvm-addr2line, and I got tired and
      aborted the test after waiting for 55 minutes with external bfd
      addr2line (which is the default for perf as compiled by distributions
      today).
      
      Evidently, for this case, the bfd addr2line process needs 18 seconds (on
      a 5.2 GHz Zen 3) to load the .debug ELF in question, hits the 1-second
      timeout and gets killed during initialization, getting restarted anew
      every time. Having an in-process addr2line makes this much more robust.
      
      As future extensions, libllvm can be used in many other places where
      we currently use libbfd or other libraries:
      
       - Symbol enumeration (in particular, for PE binaries).
       - Demangling (including non-Itanium demangling, e.g. Microsoft
         or Rust).
       - Disassembling (perf annotate).
      
      However, these are much less pressing; most people don't profile PE
      binaries, and perf has non-bfd paths for ELF. The same with demangling;
      the default _cxa_demangle path works fine for most users, and while bfd
      objdump can be slow on large binaries, it is possible to use
      --objdump=llvm-objdump to get the speed benefits.  (It appears
      LLVM-based demangling is very simple, should we want that.)
      
      Tested with LLVM 14, 15, 16, 18 and 19. For some reason, LLVM 12 was not
      correctly detected using feature_check, and thus was not tested.
      
      Committer notes:
      
       Added the name and a __maybe_unused to address:
      
         1    13.50 almalinux:8                   : FAIL gcc version 8.5.0 20210514 (Red Hat 8.5.0-22) (GCC)
          util/srcline.c: In function 'dso__free_a2l':
          util/srcline.c:184:20: error: parameter name omitted
           void dso__free_a2l(struct dso *)
                              ^~~~~~~~~~~~
          make[3]: *** [/git/perf-6.11.0-rc3/tools/build/Makefile.build:158: util] Error 2
      
      Signed-off-by: default avatarSteinar H. Gunderson <sesse@google.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Ian Rogers <irogers@google.com>
      Link: https://lore.kernel.org/r/20240803152008.2818485-1-sesse@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c3f8644c
  3. Aug 29, 2024
    • Arnaldo Carvalho de Melo's avatar
      Revert "tools build: Remove leftover libcap tests that prevents fast path... · 0fd77ae4
      Arnaldo Carvalho de Melo authored
      Revert "tools build: Remove leftover libcap tests that prevents fast path feature detection from working"
      
      Ian pointed out that the libcap feature test is also used by bpftool, so
      we can't remove it just because perf stopped using it, revert the
      removal of the feature test.
      
      Since both perf and libcap uses the fast path feature detection
      (tools/build/feature/test-all.c), probably the best thing is to keep
      libcap-devel when building perf even it not being used there.
      
      This reverts commit 47b3b643.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0fd77ae4
  4. Aug 28, 2024
  5. Aug 15, 2024
  6. Aug 14, 2024
    • Arnaldo Carvalho de Melo's avatar
      perf build: Fix up broken capstone feature detection fast path · 4c55560f
      Arnaldo Carvalho de Melo authored
      The capstone devel headers define 'struct bpf_insn' in a way that clashes with
      what is in the libbpf devel headers, so we so far need to avoid including both.
      
      This is happening on the tools/build/feature/test-all.c file, where we try
      building all the expected set of libraries to be normally available on a
      system:
      
        ⬢[acme@toolbox perf-tools-next]$ cat /tmp/build/perf-tools-next/feature/test-all.make.output
        In file included from test-bpf.c:3,
                         from test-all.c:150:
        /home/acme/git/perf-tools-next/tools/include/uapi/linux/bpf.h:77:8: error: ‘bpf_insn’ defined as wrong kind of tag
           77 | struct bpf_insn {
              |        ^~~~~~~~
        ⬢[acme@toolbox perf-tools-next]$ cat /tmp/build/perf-tools-next/feature/test-all.make.output
      
      When doing so there is a trick where we define main to be
      main_test_libcapstone, then include the individual
      tools/build/feture/test-libcapstone.c capability query test, and then we undef
      'main' because we'll do it all over again with the next expected library to
      be tested (at this time 'lzma').
      
      To complete this mechanism we need to, in test-all.c 'main' routine, to
      call main_test_libcapstone(), which isn't being done, so the effect of
      adding references to capstone in test-all.c are not achieved.
      
      The only thing that is happening is that test-all.c is failing to build and thus
      all the tests will have to be done individually, which nullifies the test-all.c
      single build speedup.
      
      So lets remove references to capstone from test-all.c to see if this makes it
      build again so that we get faster builds or go on fixing up whatever is
      preventing us to get that benefit.
      
      Nothing: after this fix we get a clean test-all.c build and get the build speedup back:
      
        ⬢[acme@toolbox perf-tools-next]$ cat /tmp/build/perf-tools-next/feature/test-all.make.output
        ⬢[acme@toolbox perf-tools-next]$ cat /tmp/build/perf-tools-next/feature/test-all.
        test-all.bin          test-all.d            test-all.make.output
        ⬢[acme@toolbox perf-tools-next]$ cat /tmp/build/perf-tools-next/feature/test-all.make.output
        ⬢[acme@toolbox perf-tools-next]$ ldd /tmp/build/perf-tools-next/feature/test-all.bin
        	linux-vdso.so.1 (0x00007f13277a1000)
        	libpython3.12.so.1.0 => /lib64/libpython3.12.so.1.0 (0x00007f1326e00000)
        	libm.so.6 => /lib64/libm.so.6 (0x00007f13274be000)
        	libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1327496000)
        	libtracefs.so.1 => /lib64/libtracefs.so.1 (0x00007f132746f000)
        	libcrypto.so.3 => /lib64/libcrypto.so.3 (0x00007f1326800000)
        	libunwind-x86_64.so.8 => /lib64/libunwind-x86_64.so.8 (0x00007f1327452000)
        	libunwind.so.8 => /lib64/libunwind.so.8 (0x00007f1327436000)
        	liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f1327403000)
        	libdw.so.1 => /lib64/libdw.so.1 (0x00007f1326d6f000)
        	libz.so.1 => /lib64/libz.so.1 (0x00007f13273e2000)
        	libelf.so.1 => /lib64/libelf.so.1 (0x00007f1326d53000)
        	libnuma.so.1 => /lib64/libnuma.so.1 (0x00007f13273d4000)
        	libslang.so.2 => /lib64/libslang.so.2 (0x00007f1326400000)
        	libperl.so.5.38 => /lib64/libperl.so.5.38 (0x00007f1326000000)
        	libc.so.6 => /lib64/libc.so.6 (0x00007f1325e0f000)
        	libzstd.so.1 => /lib64/libzstd.so.1 (0x00007f1326741000)
        	/lib64/ld-linux-x86-64.so.2 (0x00007f13277a3000)
        	libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f1326d3f000)
        	libcrypt.so.2 => /lib64/libcrypt.so.2 (0x00007f1326d07000)
        ⬢[acme@toolbox perf-tools-next]$
      
      And when having capstone-devel installed we get it detected and linked with
      perf, allowing us to benefit from the features that it enables:
      
        ⬢[acme@toolbox perf-tools-next]$ rpm -q capstone-devel
        capstone-devel-5.0.1-3.fc40.x86_64
        ⬢[acme@toolbox perf-tools-next]$ ldd /tmp/build/perf-tools-next/perf | grep capstone
        	libcapstone.so.5 => /lib64/libcapstone.so.5 (0x00007fe6a5c00000)
        ⬢[acme@toolbox perf-tools-next]$ /tmp/build/perf-tools-next/perf -vv | grep cap
                   libcapstone: [ on  ]  # HAVE_LIBCAPSTONE_SUPPORT
        ⬢[acme@toolbox perf-tools-next]$
      
      Fixes: 8b767db3 ("perf: build: introduce the libcapstone")
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: Changbin Du <changbin.du@huawei.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/Zry0sepD5Ppa5YKP@x1
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4c55560f
  7. Aug 05, 2024
    • Brian Norris's avatar
      tools build: Correct bpf fixdep dependencies · dbb2a7a9
      Brian Norris authored
      The dependencies in tools/lib/bpf/Makefile are incorrect. Before we
      recurse to build $(BPF_IN_STATIC), we need to build its 'fixdep'
      executable.
      
      I can't use the usual shortcut from Makefile.include:
      
        <target>: <sources> fixdep
      
      because its 'fixdep' target relies on $(OUTPUT), and $(OUTPUT) differs
      in the parent 'make' versus the child 'make' -- so I imitate it via
      open-coding.
      
      I tweak a few $(MAKE) invocations while I'm at it, because
      1. I'm adding a new recursive make; and
      2. these recursive 'make's print spurious lines about files that are "up
         to date" (which isn't normally a feature in Kbuild subtargets) or
         "jobserver not available" (see [1])
      
      I also need to tweak the assignment of the OUTPUT variable, so that
      relative path builds work. For example, for 'make tools/lib/bpf', OUTPUT
      is unset, and is usually treated as "cwd" -- but recursive make will
      change cwd and so OUTPUT has a new meaning. For consistency, I ensure
      OUTPUT is always an absolute path.
      
      And $(Q) gets a backup definition in tools/build/Makefile.include,
      because Makefile.include is sometimes included without
      tools/build/Makefile, so the "quiet command" stuff doesn't actually work
      consistently without it.
      
      After this change, top-level builds result in an empty grep result from:
      
        $ grep 'cannot find fixdep' $(find tools/ -name '*.cmd')
      
      [1] https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html
      
      
      If we're not using $(MAKE) directly, then we need to use more '+'.
      
      Signed-off-by: default avatarBrian Norris <briannorris@chromium.org>
      Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Link: https://lore.kernel.org/r/20240715203325.3832977-4-briannorris@chromium.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      dbb2a7a9
    • Brian Norris's avatar
      tools build: Avoid circular .fixdep-in.o.cmd issues · ea974028
      Brian Norris authored
      
      The 'fixdep' tool is used to post-process dependency files for various
      reasons, and it runs after every object file generation command. This
      even includes 'fixdep' itself.
      
      In Kbuild, this isn't actually a problem, because it uses a single
      command to generate fixdep (a compile-and-link command on fixdep.c), and
      afterward runs the fixdep command on the accompanying .fixdep.cmd file.
      
      In tools/ builds (which notably is maintained separately from Kbuild),
      fixdep is generated in several phases:
      
       1. fixdep.c -> fixdep-in.o
       2. fixdep-in.o -> fixdep
      
      Thus, fixdep is not available in the post-processing for step 1, and
      instead, we generate .cmd files that look like:
      
        ## from tools/objtool/libsubcmd/.fixdep.o.cmd
        # cannot find fixdep (/path/to/linux/tools/objtool/libsubcmd//fixdep)
        [...]
      
      These invalid .cmd files are benign in some respects, but cause problems
      in others (such as the linked reports).
      
      Because the tools/ build system is rather complicated in its own right
      (and pointedly different than Kbuild), I choose to simply open-code the
      rule for building fixdep, and avoid the recursive-make indirection that
      produces the problem in the first place.
      
      Signed-off-by: default avatarBrian Norris <briannorris@chromium.org>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Link: https://lore.kernel.org/all/Zk-C5Eg84yt6_nml@google.com/
      Link: https://lore.kernel.org/r/20240715203325.3832977-3-briannorris@chromium.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ea974028
  8. Jul 26, 2024
  9. Jul 17, 2024
  10. Jun 21, 2024
  11. Feb 21, 2024
  12. Nov 27, 2023
  13. Nov 10, 2023
  14. Oct 20, 2023
    • Arnaldo Carvalho de Melo's avatar
      tools build: Fix llvm feature detection, still used by bpftool · 4fa008a2
      Arnaldo Carvalho de Melo authored
      
      When removing the BPF event for perf a feature test that checks if the
      llvm devel files are availabe was removed but that is also used by
      bpftool.
      
      bpftool uses it to decide what kind of disassembly it will use: llvm or
      binutils based.
      
      Removing the tools/build/feature/test-llvm.cpp file made bpftool to
      always fallback to binutils disassembly, even with the llvm devel files
      installed, fix it by restoring just that small test-llvm.cpp test file.
      
      Fixes: 56b11a21 ("perf bpf: Remove support for embedding clang for compiling BPF events (-e foo.c)")
      Reported-by: default avatarManu Bretelle <chantr4@gmail.com>
      Reviewed-by: default avatarIan Rogers <irogers@google.com>
      Reviewed-by: default avatarManu Bretelle <chantr4@gmail.com>
      Acked-by: default avatarQuentin Monnet <quentin@isovalent.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Carsten Haitzler <carsten.haitzler@arm.com>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Wang ShaoBo <bobo.shaobowang@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Link: https://lore.kernel.org/lkml/ZTGa0Ukt7QyxWcVy@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4fa008a2
  15. Oct 18, 2023
    • Jiri Olsa's avatar
      tools/build: Fix -s detection code in tools/build/Makefile.build · d9997f7f
      Jiri Olsa authored
      
      As Dmitry described in [1] changelog the current way of detecting
      -s option is broken for new make.
      
      Changing the tools/build -s option detection the same way as it was
      fixed for root Makefile in [1].
      
      [1] 4bf73588 ("kbuild: Port silent mode detection to future gnu make.")
      
      Cc: Dmitry Goncharov <dgoncharov@users.sf.net>
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: KP Singh <kpsingh@chromium.org>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: Hao Luo <haoluo@google.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Stanislav Fomichev <sdf@google.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: bpf@vger.kernel.org
      Cc: linux-perf-users@vger.kernel.org
      Link: https://lore.kernel.org/r/20231008212251.236023-2-jolsa@kernel.org
      
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      d9997f7f
  16. Aug 15, 2023
    • Ian Rogers's avatar
      perf bpf: Remove support for embedding clang for compiling BPF events (-e foo.c) · 56b11a21
      Ian Rogers authored
      
      This never was in the default build for perf, is difficult to maintain
      as it uses clang/llvm internals so ditch it, keeping, for now, the
      external compilation of .c BPF into .o bytecode and its subsequent
      loading, that is also going to be removed, do it separately to help
      bisection and to properly document what is being removed and why.
      
      Committer notes:
      
      Extracted from a larger patch and removed some leftovers, namely
      deleting these now unused feature tests:
      
          tools/build/feature/test-clang.cpp
          tools/build/feature/test-cxx.cpp
          tools/build/feature/test-llvm-version.cpp
          tools/build/feature/test-llvm.cpp
      
      Testing the use of BPF events after applying this patch:
      
      To use the external clang/llvm toolchain to compile a .c event and then
      use libbpf to load it, to get the syscalls:sys_enter_open* tracepoints
      and read the filename pointer, putting it into the ring buffer right
      after the usual tracepoint payload for 'perf trace' to then print it:
      
        [root@quaco ~]# perf trace -e /home/acme/git/perf-tools-next/tools/perf/examples/bpf/augmented_raw_syscalls.c,open* --max-events=10
           0.000 systemd-oomd/959 openat(dfd: CWD, filename: "/proc/meminfo", flags: RDONLY|CLOEXEC) = 12
           0.083 abrt-dump-jour/1453 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4
           0.063 abrt-dump-jour/1454 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4
           0.082 abrt-dump-jour/1455 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4
         250.124 systemd-oomd/959 openat(dfd: CWD, filename: "/proc/meminfo", flags: RDONLY|CLOEXEC) = 12
         250.521 systemd-oomd/959 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/app.slice/memory.pressure", flags: RDONLY|CLOEXEC) = 12
         251.047 systemd-oomd/959 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/app.slice/memory.current", flags: RDONLY|CLOEXEC) = 12
         251.162 systemd-oomd/959 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/app.slice/memory.min", flags: RDONLY|CLOEXEC) = 12
         251.242 systemd-oomd/959 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/app.slice/memory.low", flags: RDONLY|CLOEXEC) = 12
         251.353 systemd-oomd/959 openat(dfd: CWD, filename: "/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/app.slice/memory.swap.current", flags: RDONLY|CLOEXEC) = 12
        [root@quaco ~]#
      
      Same thing, but with a prebuilt .o BPF bytecode:
      
        [root@quaco ~]# perf trace -e /home/acme/git/perf-tools-next/tools/perf/examples/bpf/augmented_raw_syscalls.o,open* --max-events=10
           0.000 systemd-oomd/959 openat(dfd: CWD, filename: "/proc/meminfo", flags: RDONLY|CLOEXEC) = 12
           0.083 abrt-dump-jour/1453 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4
           0.083 abrt-dump-jour/1455 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4
           0.062 abrt-dump-jour/1454 openat(dfd: CWD, filename: "/var/log/journal/d6a97235307247e09f13f326fb607e3c/system.journal", flags: RDONLY|CLOEXEC|NONBLOCK) = 4
         249.985 systemd-oomd/959 openat(dfd: CWD, filename: "/proc/meminfo", flags: RDONLY|CLOEXEC) = 12
         466.763 thermald/1234 openat(dfd: CWD, filename: "/sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:2/energy_uj") = 13
         467.145 thermald/1234 openat(dfd: CWD, filename: "/sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj") = 13
         467.311 thermald/1234 openat(dfd: CWD, filename: "/sys/class/thermal/thermal_zone2/temp") = 13
         500.040 cgroupify/24006 openat(dfd: 4, filename: ".", flags: RDONLY|CLOEXEC|DIRECTORY|NONBLOCK) = 5
         500.295 cgroupify/24006 openat(dfd: 4, filename: "24616/cgroup.procs") = 5
        [root@quaco ~]#
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Carsten Haitzler <carsten.haitzler@arm.com>
      Cc: Eduard Zingerman <eddyz87@gmail.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Wang ShaoBo <bobo.shaobowang@huawei.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: YueHaibing <yuehaibing@huawei.com>
      Link: https://lore.kernel.org/lkml/ZNZWsAXg2px1sm2h@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      56b11a21
  17. Aug 03, 2023
    • Thomas Richter's avatar
      perf build: Update feature check for clang and llvm · 4e95ed4f
      Thomas Richter authored
      Perf build auto-detects features and packages already installed for its
      build. This is done in directory tools/build/feature. This directory
      contains small sample programs. When they successfully compile the
      necessary prereqs in form of libraries and header files are present.
      
      Such a check is also done for llvm and clang. And the checks fail.
      
      Fix this and update to the latest C++ standard and use the new library
      provided by clang (which contains new packaging) s/ee this link for
      reference:
      
       https://fedoraproject.org/wiki/Changes/Stop-Shipping-Individual-Component-Libraries-In-clang-lib-Package
      
      
      
      Output before:
       # rm -f ./test-clang.bin; make test-clang.bin; ./test-clang.bin; \
      	ll test-clang.make.output
       g++  -MD -Wall -Werror -o test-clang.bin test-clang.cpp \
      	 	> test-clang.make.output 2>&1 -std=gnu++14 \
      	-I/usr/include 		\
      	-L/usr/lib64		\
      	-Wl,--start-group -lclangBasic -lclangDriver	\
      	  -lclangFrontend -lclangEdit -lclangLex	\
      	  -lclangAST -Wl,--end-group 			\
      	-lLLVM-16	\
      			\
      	> test-clang.make.output 2>&1
       make: *** [Makefile:356: test-clang.bin] Error 1
       -bash: ./test-clang.bin: No such file or directory
       -rw-r--r--. 1 root root 252041 Jul 12 09:56 test-clang.make.output
       #
      
      File test-clang.make.output contains many lines of unreferenced
      symbols.
      
      Output after:
       # rm -f ./test-clang.bin; make test-clang.bin; ./test-clang.bin; \
      	cat test-clang.make.output
       g++  -MD -Wall -Werror -o test-clang.bin test-clang.cpp \
      	 > test-clang.make.output 2>&1 -std=gnu++17	\
      	-I/usr/include 		\
      	-L/usr/lib64		\
      	-Wl,--start-group -lclang-cpp -Wl,--end-group	\
      	-lLLVM-16	\
      			\
      	> test-clang.make.output 2>&1
       #
      
      Committer notes:
      
      Test it in the tools/build/feature directory, and have clang-devel and
      llvm-devel installed.
      
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lore.kernel.org/r/20230725150347.3479291-1-tmricht@linux.ibm.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4e95ed4f
    • Namhyung Kim's avatar
      perf build: Update build rule for generated files · 7822a891
      Namhyung Kim authored
      
      The bison and flex generate C files from the source (.y and .l)
      files.  When O= option is used, they are saved in a separate directory
      but the default build rule assumes the .C files are in the source
      directory.  So it might read invalid file if there are generated files
      from an old version.  The same is true for the pmu-events files.
      
      For example, the following command would cause a build failure:
      
        $ git checkout v6.3
        $ make -C tools/perf  # build in the same directory
      
        $ git checkout v6.5-rc2
        $ mkdir build  # create a build directory
        $ make -C tools/perf O=build  # build in a different directory but it
                                      # refers files in the source directory
      
      Let's update the build rule to specify those cases explicitly to depend
      on the files in the output directory.
      
      Note that it's not a complete fix and it needs the next patch for the
      include path too.
      
      Fixes: 80eeb67f ("perf jevents: Program to convert JSON file")
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Anup Sharma <anupnewsmail@gmail.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20230728022447.1323563-1-namhyung@kernel.org
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7822a891
  18. Jul 11, 2023
    • Thomas Richter's avatar
      perf build: Fix broken feature check for libtracefs due to external lib changes · a87834d1
      Thomas Richter authored
      The perf build process auto-detects features and packages already
      installed for its build. This is done in directory tools/build/feature.
      This directory contains small sample programs. When they successfully
      compile the necessary prereqs in form of libraries and header files are
      present.
      
      Such a check is also done for libtracefs. And this check fails:
      
      Output before:
       # rm -f test-libtracefs.bin; make test-libtracefs.bin
       gcc  -MD -Wall -Werror -o test-libtracefs.bin test-libtracefs.c \
      	 > test-libtracefs.make.output 2>&1 -ltracefs
       make: *** [Makefile:211: test-libtracefs.bin] Error 1
       # cat test-libtracefs.make.output
       In file included from test-libtracefs.c:2:
       /usr/include/tracefs/tracefs.h:11:10: fatal error: \
      	 event-parse.h: No such file or directory
         11 | #include <event-parse.h>
            |          ^~~~~~~~~~~~~~~
       compilation terminated.
       #
      
      The root cause of this compile error is commit 880885d9c22e
      ("libtracefs: Remove "traceevent/" from referencing libtraceevent
      headers") in the libtracefs project hosted here:
      https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/
      
      
      
      That mentioned patch removes the traceevent/ directory name from
      the include statement, causing the file not to be included even
      when the libtraceevent-devel package is installed. This package contains
      the file referred to in tracefs/tracefs.h:
      
       # rpm -ql libtraceevent-devel
       /usr/include/traceevent
       /usr/include/traceevent/event-parse.h  <----- here
       /usr/include/traceevent/event-utils.h
       /usr/include/traceevent/kbuffer.h
       /usr/include/traceevent/trace-seq.h
       /usr/lib64/libtraceevent.so
       /usr/lib64/pkgconfig/libtraceevent.pc
       #
      
      With this patch the compile succeeds.
      
      Output after:
       # rm -f test-libtracefs.bin; make test-libtracefs.bin
       gcc  -MD -Wall -Werror -o test-libtracefs.bin test-libtracefs.c \
      	 > test-libtracefs.make.output 2>&1 -I/usr/include/traceevent -ltracefs
       #
      
      Committer testing:
      
        $ make -k BUILD_BPF_SKEL=1 CORESIGHT=1 O=/tmp/build/perf-tools -C tools/perf install-bin
      
      Before:
      
        $ cat /tmp/build/perf-tools/feature/test-libtracefs.make.output
        In file included from test-libtracefs.c:2:
        /usr/include/tracefs/tracefs.h:11:10: fatal error: event-parse.h: No such file or directory
           11 | #include <event-parse.h>
              |          ^~~~~~~~~~~~~~~
        compilation terminated.
        $
        $ grep -i tracefs /tmp/build/perf-tools/FEATURE-DUMP
        feature-libtracefs=0
        $
      
      After:
      
        $ cat /tmp/build/perf-tools/feature/test-libtracefs.make.output
        $
        $ grep -i tracefs /tmp/build/perf-tools/FEATURE-DUMP
        feature-libtracefs=1
        $
      
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Link: https://lore.kernel.org/r/20230711135338.397473-1-tmricht@linux.ibm.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a87834d1
  19. Jun 29, 2023
  20. Apr 04, 2023
  21. Mar 14, 2023
    • Ian Rogers's avatar
      tools build: Add feature test for abi::__cxa_demangle · 4c72e2b3
      Ian Rogers authored
      
      cxxabi.h is part of libsdtc++ and LLVM's libcxx, providing
      abi::__cxa_demangle a portable C++ demangler. Add a feature test to
      detect that the function is available.
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pavithra Gurushankar <gpavithrasha@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230311065753.3012826-2-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4c72e2b3
    • Ian Rogers's avatar
      perf build: Remove libbpf pre-1.0 feature tests · 76a97cf2
      Ian Rogers authored
      
      The feature tests were necessary for libbpf pre-1.0, but as the libbpf
      implies at least 1.0 we can remove these now.
      
      Committer notes:
      
      Modified tools/perf/Makefile.config to better reflect the reason for
      failure when the libbpf present is < 1.0 and LIBBPF_DYNAMIC=1 was asked
      for.
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Tested-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Christy Lee <christylee@fb.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230116010115.490713-2-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      76a97cf2
    • Ian Rogers's avatar
      tools build: Pass libbpf feature only if libbpf 1.0+ · 56d52294
      Ian Rogers authored
      
      libbpf 1.0 represented a cleanup and stabilization of APIs. Simplify
      development by only passing the feature test if libbpf 1.0 is installed.
      
      Committer notes:
      
      Change 'make -C tools/perf build-test' so that the LIBBPF_DYNAMIC=1 test
      runs only if libbpf is >= 1.0.
      
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Christy Lee <christylee@fb.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Roberto Sassu <roberto.sassu@huawei.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230116010115.490713-2-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      56d52294
  22. Feb 03, 2023
    • Ian Rogers's avatar
      tools build: Add test echo-cmd · e30f3405
      Ian Rogers authored
      
      Add quiet_cmd_test so that:
      $(Q)$(call echo-cmd,test)
      
      will print:
      TEST   <path>
      
      This is useful for executing compile-time tests similar to what
      happens for fortify tests in the kernel's lib directory.
      
      Reviewed-by: default avatarKajol Jain <kjain@linux.ibm.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Caleb Biggers <caleb.biggers@intel.com>
      Cc: Florian Fischer <florian.fischer@muhq.space>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jing Zhang <renyu.zj@linux.alibaba.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.g.garry@oracle.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Kang Minchul <tegongkang@gmail.com>
      Cc: Kim Phillips <kim.phillips@amd.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mike Leach <mike.leach@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Perry Taylor <perry.taylor@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Sandipan Das <sandipan.das@amd.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Link: https://lore.kernel.org/r/20230126233645.200509-15-irogers@google.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e30f3405
  23. Oct 25, 2022
    • Arnaldo Carvalho de Melo's avatar
      perf bpf: Fix build with libbpf 0.7.0 by checking if bpf_program__set_insns() is available · f1bdebbb
      Arnaldo Carvalho de Melo authored
      
      During the transition to libbpf 1.0 some functions that perf used were
      deprecated and finally removed from libbpf, so bpf_program__set_insns()
      was introduced for perf to continue to use its bpf loader.
      
      But when build with LIBBPF_DYNAMIC=1 we now need to check if that
      function is available so that perf can build with older libbpf versions,
      even if the end result is emitting a warning to the user that the use
      of the perf BPF loader requires a newer libbpf, since bpf_program__set_insns()
      touches libbpf objects internal state.
      
      This affects only 'perf trace' when using bpf C code or pre-compiled
      bytecode as an event.
      
      Noticed on RHEL9, that has libbpf 0.7.0, where bpf_program__set_insns()
      isn't available.
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f1bdebbb
  24. Oct 04, 2022
    • Roberto Sassu's avatar
      tools build: Display logical OR of a feature flavors · 74ef1cc9
      Roberto Sassu authored
      
      Sometimes, features are simply different flavors of another feature, to
      properly detect the exact dependencies needed by different Linux
      distributions.
      
      For example, libbfd has three flavors: libbfd if the distro does not
      require any additional dependency; libbfd-liberty if it requires libiberty;
      libbfd-liberty-z if it requires libiberty and libz.
      
      It might not be clear to the user whether a feature has been successfully
      detected or not, given that some of its flavors will be set to OFF, others
      to ON.
      
      Instead, display only the feature main flavor if not in verbose mode
      (VF != 1), and set it to ON if at least one of its flavors has been
      successfully detected (logical OR), OFF otherwise. Omit the other flavors.
      
      Accomplish that by declaring a FEATURE_GROUP_MEMBERS-<feature main flavor>
      variable, with the list of the other flavors as variable value. For now, do
      it just for libbfd.
      
      In verbose mode, of if no group is defined for a feature, show the feature
      detection result as before.
      
      Committer testing:
      
      Collecting the output from:
      
        $ make -C tools/bpf/bpftool/ clean
        $ make -C tools/bpf/bpftool/ |& grep "Auto-detecting system features" -A10
      
        $ diff -u before after
        --- before	2022-08-18 10:06:40.422086966 -0300
        +++ after	2022-08-18 10:07:59.202138282 -0300
        @@ -1,6 +1,4 @@
         Auto-detecting system features:
         ...                                  libbfd: [ on  ]
        -...                          libbfd-liberty: [ on  ]
        -...                        libbfd-liberty-z: [ on  ]
         ...                                  libcap: [ on  ]
         ...                         clang-bpf-co-re: [ on  ]
        $
      
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20220818120957.319995-3-roberto.sassu@huaweicloud.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      74ef1cc9
    • Roberto Sassu's avatar
      tools build: Increment room for feature name in feature detection output · 74da7697
      Roberto Sassu authored
      
      Since now there are features with a long name, increase the room for them,
      so that fields are correctly aligned.
      
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20220818120957.319995-2-roberto.sassu@huaweicloud.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      74da7697
    • Roberto Sassu's avatar
      tools build: Fix feature detection output due to eval expansion · 709533e5
      Roberto Sassu authored
      
      As the first eval expansion is used only to generate Makefile statements,
      messages should not be displayed at this stage, as for example conditional
      expressions are not evaluated.
      
      It can be seen for example in the output of feature detection for bpftool,
      where the number of detected features does not change, despite turning on
      the verbose mode (VF = 1) and there are additional features to display.
      
      Fix this issue by escaping the $ before $(info) statements, to ensure that
      messages are printed only when the function containing them is actually
      executed, and not when it is expanded.
      
      In addition, move the $(info) statement out of feature_print_status, due to
      the fact that is called both inside and outside an eval context, and place
      it to the caller so that the $ can be escaped when necessary. For symmetry,
      move the $(info) statement also out of feature_print_text, and place it to
      the caller.
      
      Force the TMP variable evaluation in verbose mode, to display the features
      in FEATURE_TESTS that are not in FEATURE_DISPLAY.
      
      Reorder perf feature detection messages (first non-verbose, then verbose
      ones) by moving the call to feature_display_entries earlier, before the VF
      environment variable check.
      
      Also, remove the newline from that function, as perf might display
      additional messages. Move the newline to perf Makefile, and display another
      one if displaying the detection result is not deferred as in the case of
      bpftool.
      
      Committer testing:
      
        Collecting the output from:
      
        $ make VF=1 -C tools/bpf/bpftool/ |& grep "Auto-detecting system features" -A20
      
        $ diff -u before after
        --- before	2022-08-18 09:59:55.460529231 -0300
        +++ after	2022-08-18 10:01:11.182517282 -0300
        @@ -4,3 +4,5 @@
         ...              libbfd-liberty-z: [ on  ]
         ...                        libcap: [ on  ]
         ...               clang-bpf-co-re: [ on  ]
        +...        disassembler-four-args: [ on  ]
        +...      disassembler-init-styled: [ OFF ]
        $
      
      Fixes: 0afc5cad ("perf build: Separate feature make support into config/Makefile.feature")
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: bpf@vger.kernel.org
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Link: https://lore.kernel.org/r/20220818120957.319995-1-roberto.sassu@huaweicloud.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      709533e5
  25. Aug 10, 2022
    • Roberto Sassu's avatar
      tools build: Switch to new openssl API for test-libcrypto · 5b245985
      Roberto Sassu authored
      
      Switch to new EVP API for detecting libcrypto, as Fedora 36 returns an
      error when it encounters the deprecated function MD5_Init() and the others.
      
      The error would be interpreted as missing libcrypto, while in reality it is
      not.
      
      Fixes: 6e8ccb4f ("tools/bpf: properly account for libbfd variations")
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: bpf@vger.kernel.org
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: llvm@lists.linux.dev
      Cc: Martin KaFai Lau <martin.lau@linux.dev>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Song Liu <song@kernel.org>
      Cc: Stanislav Fomichev <sdf@google.com>
      Link: https://lore.kernel.org/r/20220719170555.2576993-4-roberto.sassu@huawei.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5b245985
    • Arnaldo Carvalho de Melo's avatar
      Revert "perf build: Suppress openssl v3 deprecation warnings in libcrypto feature test" · 73f8ec59
      Arnaldo Carvalho de Melo authored
      
      This reverts commit 10fef869.
      
      Because a proper fix was submitted.
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      73f8ec59
    • Roberto Sassu's avatar
      tools, build: Retry detection of bfd-related features · 629b98e2
      Roberto Sassu authored
      
      While separate features have been defined to determine which linking flags
      are required to use libbfd depending on the distribution (libbfd,
      libbfd-liberty and libbfd-liberty-z), the same has not been done for other
      features requiring linking to libbfd.
      
      For example, disassembler-four-args requires linking to libbfd too, but it
      should use the right linking flags. If not all the required ones are
      specified, e.g. -liberty, detection will always fail even if the feature is
      available.
      
      Instead of creating new features, similarly to libbfd, simply retry
      detection with the different set of flags until detection succeeds (or
      fails, if the libraries are missing). In this way, feature detection is
      transparent for the users of this building mechanism (e.g. perf), and those
      users don't have for example to set an appropriate value for the
      FEATURE_CHECK_LDFLAGS-disassembler-four-args variable.
      
      The number of retries and features for which the retry mechanism is
      implemented is low enough to make the increase in the complexity of
      Makefile negligible.
      
      Tested with perf and bpftool on Ubuntu 20.04.4 LTS, Fedora 36 and openSUSE
      Tumbleweed.
      
      Committer notes:
      
      Do the retry for disassembler-init-styled as well.
      
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andres Freund <andres@anarazel.de>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: Martin KaFai Lau <martin.lau@linux.dev>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Quentin Monnet <quentin@isovalent.com>
      Cc: Song Liu <song@kernel.org>
      Cc: Stanislav Fomichev <sdf@google.com>
      Cc: bpf@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20220719170555.2576993-1-roberto.sassu@huawei.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      629b98e2
  26. Aug 02, 2022
    • Zixuan Tan's avatar
      perf build: Suppress openssl v3 deprecation warnings in libcrypto feature test · 10fef869
      Zixuan Tan authored
      
      With OpenSSL v3 installed, the libcrypto feature check fails as it use the
      deprecated MD5_* API (and is compiled with -Werror). The error message is
      as follows.
      
      $ make tools/perf
      ```
      Makefile.config:778: No libcrypto.h found, disables jitted code injection,
      please install openssl-devel or libssl-dev
      
      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: [ OFF ]
      ...                     libunwind: [ on  ]
      ...            libdw-dwarf-unwind: [ on  ]
      ...                          zlib: [ on  ]
      ...                          lzma: [ on  ]
      ...                     get_cpuid: [ on  ]
      ...                           bpf: [ on  ]
      ...                        libaio: [ on  ]
      ...                       libzstd: [ on  ]
      ...        disassembler-four-args: [ on  ]
      ```
      
      This is very confusing because the suggested library (on my Ubuntu 20.04
      it is libssl-dev) is already installed. As the test only checks for the
      presence of libcrypto, this commit suppresses the deprecation warning to
      allow the test to pass.
      
      Signed-off-by: default avatarZixuan Tan <tanzixuan.me@gmail.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Nick Terrell <terrelln@fb.com>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Link: https://lore.kernel.org/r/20220625153439.513559-1-tanzixuan.me@gmail.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      10fef869
  27. Aug 01, 2022
Loading