Skip to content
Branch: master
Find file History
Arnaldo Carvalho de Melo
Arnaldo Carvalho de Melo perf llvm: Fix script used to obtain kernel make directives to work w…
…ith new kbuild

Before this patch:

  # ./perf test 39 41
  39: LLVM search and compile                               :
  39.1: Basic BPF llvm compile                              : Ok
  39.2: kbuild searching                                    : FAILED!
  39.3: Compile source for BPF prologue generation          : Skip
  39.4: Compile source for BPF relocation                   : Skip
  41: BPF filter                                            :
  41.1: Basic BPF filtering                                 : Ok
  41.2: BPF pinning                                         : Ok
  41.3: BPF prologue generation                             : FAILED!
  41.4: BPF relocation checker                              : Skip
  #

Using 'perf test -v' for these tests shows that it is not finding
uapi/linux/fs.h, which ends up being because we don't setup the right header
path. Fix it.

After this patch:

  # perf test 39 41
  39: LLVM search and compile                               :
  39.1: Basic BPF llvm compile                              : Ok
  39.2: kbuild searching                                    : Ok
  39.3: Compile source for BPF prologue generation          : Ok
  39.4: Compile source for BPF relocation                   : Ok
  41: BPF filter                                            :
  41.1: Basic BPF filtering                                 : Ok
  41.2: BPF pinning                                         : Ok
  41.3: BPF prologue generation                             : Ok
  41.4: BPF relocation checker                              : Ok
  #

Longer description:

In llvm-utils.c we use some techniques to obtain the kbuild make
directives and that recently stopped working as now 'ar' gets called and
expects to find the dummy.o used to echo these variables:

  $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)

Add the $(CC) line to satisfy that, making sure this works with all
kernels, i.e. preserving the temp directory and files in it used for
this technique we can see that it works everywhere:

  # make -s -C /lib/modules/5.4.18-100.fc30.x86_64/build M=/tmp/tmp.qgaFHgxjZ4/ clean
  # ls -la /tmp/tmp.qgaFHgxjZ4/
  total 4
  drwx------.  2 root root   80 Feb 14 09:42 .
  drwxrwxrwt. 47 root root 1200 Feb 14 09:42 ..
  -rw-r--r--.  1 root root    0 Feb 13 17:14 dummy.c
  -rw-r--r--.  1 root root  121 Feb 13 17:14 Makefile
  #
  # cat /tmp/tmp.qgaFHgxjZ4/Makefile
  obj-y := dummy.o
  $(obj)/%.o: $(src)/%.c
          @echo -n "$(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS)"
          $(CC) -c -o $@ $<
  #

Then build with an old kernel Makefile:

  # make -s -C /lib/modules/5.4.18-100.fc30.x86_64/build M=/tmp/tmp.qgaFHgxjZ4/ dummy.o
  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/9/include -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h
  #
  # ls -la /tmp/tmp.qgaFHgxjZ4/
  total 8
  drwx------.  2 root root  100 Feb 14 09:43 .
  drwxrwxrwt. 47 root root 1200 Feb 14 09:43 ..
  -rw-r--r--.  1 root root    0 Feb 13 17:14 dummy.c
  -rw-r--r--.  1 root root  936 Feb 14 09:43 dummy.o
  -rw-r--r--.  1 root root  121 Feb 13 17:14 Makefile
  #

And a new one:

  # make -s -C /lib/modules/5.4.18-100.fc30.x86_64/build M=/tmp/tmp.qgaFHgxjZ4/ clean
  # ls -la /tmp/tmp.qgaFHgxjZ4/
  total 4
  drwx------.  2 root root   80 Feb 14 09:43 .
  drwxrwxrwt. 47 root root 1200 Feb 14 09:43 ..
  -rw-r--r--.  1 root root    0 Feb 13 17:14 dummy.c
  -rw-r--r--.  1 root root  121 Feb 13 17:14 Makefile
  # make -s -C /lib/modules/5.6.0-rc1+/build M=/tmp/tmp.qgaFHgxjZ4/ dummy.o
   -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/9/include -I/home/acme/git/linux/arch/x86/include -I./arch/x86/include/generated -I/home/acme/git/linux/include -I./include -I/home/acme/git/linux/arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I/home/acme/git/linux/include/uapi -I./include/generated/uapi -include /home/acme/git/linux/include/linux/kconfig.h
  #
  # ls -la /tmp/tmp.qgaFHgxjZ4/
  total 16
  drwx------.  2 root root  160 Feb 14 09:44 .
  drwxrwxrwt. 47 root root 1200 Feb 14 09:44 ..
  -rw-r--r--.  1 root root  158 Feb 14 09:44 built-in.a
  -rw-r--r--.  1 root root  149 Feb 14 09:44 .built-in.a.cmd
  -rw-r--r--.  1 root root    0 Feb 13 17:14 dummy.c
  -rw-r--r--.  1 root root  936 Feb 14 09:44 dummy.o
  -rw-r--r--.  1 root root  121 Feb 13 17:14 Makefile
  -rw-r--r--.  1 root root    0 Feb 14 09:44 modules.order
  #

Reported-by: Thomas Richter <tmricht@linux.ibm.com>
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: Zefan Li <lizefan@huawei.com>
Link: https://www.spinics.net/lists/linux-perf-users/msg10600.html
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Latest commit 6276594 Feb 14, 2020

Files

Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
Documentation perf tools: Support --prefix/--prefix-strip Jan 14, 2020
arch perf tools: Add arm64 version of get_cpuid() Feb 12, 2020
bench perf env: Remove needless cpumap.h header Sep 20, 2019
examples/bpf Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next Jan 29, 2020
include/bpf perf: Use consistent include paths for libbpf Jan 21, 2020
jvmti perf jvmti: Link against tools/lib/ctype.h to have weak strlcpy() Oct 15, 2019
pmu-events perf vendor events s390: Remove name from L1D_RO_EXCL_WRITES description Dec 16, 2019
python treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 407 Jun 5, 2019
scripts perf scripts python: exported-sql-viewer.py: Fix use of TRUE with SQLite Nov 13, 2019
tests perf test: Fix test case Merge cpu map Jan 30, 2020
trace perf beauty prctl: Export the 'options' strarray Feb 11, 2020
ui perf/ui/gtk: Fix gtk2 build Jan 14, 2020
util perf llvm: Fix script used to obtain kernel make directives to work w… Feb 14, 2020
.gitignore perf: Update .gitignore file Sep 1, 2019
Build perf tools: Rename build libperf to perf Feb 14, 2019
CREDITS perf_counter tools: Add CREDITS file for Git contributors Jun 24, 2009
MANIFEST libperf: Move to tools/lib/perf Jan 6, 2020
Makefile perf tools: Disable parallelism for 'make clean' Aug 20, 2018
Makefile.config libperf: Move to tools/lib/perf Jan 6, 2020
Makefile.perf libperf: Move to tools/lib/perf Jan 6, 2020
builtin-annotate.c perf tools: Support --prefix/--prefix-strip Jan 14, 2020
builtin-bench.c perf tools: Remove perf.h from source files not needing it Aug 29, 2019
builtin-buildid-cache.c perf session: Return error code for perf_session__new() function on f… Sep 20, 2019
builtin-buildid-list.c perf session: Return error code for perf_session__new() function on f… Sep 20, 2019
builtin-c2c.c perf c2c: Fix return type for histogram sorting comparision functions Jan 14, 2020
builtin-config.c perf tools: Remove util.h from where it is not needed Sep 20, 2019
builtin-data.c perf debug: Remove needless include directives from debug.h Aug 31, 2019
builtin-diff.c perf diff: Use llabs() with 64-bit values Nov 28, 2019
builtin-evlist.c perf evsel: Introduce evsel_fprintf.h Sep 25, 2019
builtin-ftrace.c perf auxtrace: Uninline functions that touch perf_session Sep 1, 2019
builtin-help.c perf debug: Remove needless include directives from debug.h Aug 31, 2019
builtin-inject.c perf inject: Fix processing of ID index for injected instruction tracing Dec 4, 2019
builtin-kallsyms.c perf dsos: Move the dsos struct and its methods to separate source files Sep 1, 2019
builtin-kmem.c perf callchain: Use 'struct map_symbol' in 'struct callchain_cursor_n… Nov 12, 2019
builtin-kvm.c perf kvm: Use evlist layer api when possible Nov 6, 2019
builtin-list.c perf list: Hide deprecated events by default Oct 19, 2019
builtin-lock.c perf session: Return error code for perf_session__new() function on f… Sep 20, 2019
builtin-mem.c perf session: Return error code for perf_session__new() function on f… Sep 20, 2019
builtin-probe.c perf probe: No need for symbol.h, symbol_conf is enough Sep 1, 2019
builtin-record.c perf record: Adapt affinity to machines with #CPUs > 1K Jan 6, 2020
builtin-report.c perf report: Fix no libunwind compiled warning break s390 issue Jan 14, 2020
builtin-sched.c perf sched timehist: Add support for filtering on CPU Jan 6, 2020
builtin-script.c perf script: Fix invalid LBR/binary mismatch error Nov 28, 2019
builtin-stat.c perf stat: Use affinity for reading Nov 29, 2019
builtin-timechart.c perf session: Return error code for perf_session__new() function on f… Sep 20, 2019
builtin-top.c perf tools: Support --prefix/--prefix-strip Jan 14, 2020
builtin-trace.c perf trace: Resolve prctl's 'option' arg strings to numbers Feb 11, 2020
builtin-version.c perf symbols: Move mem_info and branch_info out of symbol.h Sep 1, 2019
builtin.h perf tools: Remove needless util.h include from builtin.h Aug 28, 2019
check-headers.sh tools include UAPI: Sync x86's syscalls_64.tbl, generic unistd.h and … Feb 11, 2020
command-list.txt perf help: Add missing subcommand `version` Sep 19, 2018
design.txt perf/doc: Update design.txt for exclude_{host|guest} flags Jan 21, 2019
perf-archive.sh License cleanup: add SPDX GPL-2.0 license identifier to files with no… Nov 2, 2017
perf-completion.sh perf tools: Auto-complete for events with ':' Dec 27, 2017
perf-read-vdso.c perf tools: Make find_vdso_map() more modular Jan 8, 2019
perf-sys.h perf tools: Make usage of test_attr__* optional for perf-sys.h Oct 31, 2019
perf-with-kcore.sh Merge branch 'x86/cpu' into perf/core, to pick up dependent changes Jun 17, 2019
perf.c libperf: Merge libperf_set_print() into libperf_init() Sep 25, 2019
perf.h perf time-utils: Adopt rdclock() from perf.h Aug 29, 2019
You can’t perform that action at this time.