Skip to contentSkip to conversation

perf arm64: Generate system call table from asm/unistd.h

PATCH In review Kim Phillips 3 participants 9 messages Jul 6, 2018 – Sep 6, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 2/3 perf arm64: Generate system call table from asm/unistd.h

This should speed up accessing new system calls introduced with the kernel rather than waiting for libaudit updates to include them.

Using the existing other arch scripts resulted in this error:

tools/perf/arch/arm64/entry/syscalls//mksyscalltbl: 25: printf: __NR3264_ftruncate: expected numeric value

because, unlike other arches, asm-generic's unistd.h does things like:

#define __NR_ftruncate __NR3264_ftruncate

Turning the scripts printf's %d into a %s resulted in this in the generated syscalls.c file:

    static const char *syscalltbl_arm64[] = {
            [__NR3264_ftruncate] = "ftruncate",

So we use the host C compiler to fold the macros, and print them out from within a temporary C program, in order to get the correct output:

    static const char *syscalltbl_arm64[] = {
            [46] = "ftruncate",
Cc Ravi Bangoria <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Thomas Richter <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>

---
Changes in V3:
- use cat <<-_EoHEADER (with a dash), in order to be able to appropriately indent the code (Hendrik Brueckner)
- added Hendrik Brueckner's Reviewed-by.

Changes in V2:
- added the "sc" and "nr" local variables, for the sake of completion (Hendrik Brueckner)
- Removed the unsafe -u from mktemp, added more X's, and now pipe the C code to the $hostcc command, so we now only require a single temp file that is written by gcc. (Hendrik Brueckner)
- used cat << EoHEADER instead of echos for the c file header, to make it more readable (Hendrik Brueckner)
- $RM -> rm, to be able to run standalone (Hendrik Brueckner)
- moved the rm into the function that makes the file
- converted other echos to printf "%s\n" for more portable printing of backslash characters (bash and dash built-in echo commands differ in how many escape backslashes are needed). The initial "%s\n" is needed in order to keep the external printf command from interpreting the %ds.

 tools/perf/arch/arm64/Makefile                | 21 +++++++
 .../arch/arm64/entry/syscalls/mksyscalltbl    | 61 +++++++++++++++++++
 2 files changed, 82 insertions(+)
 create mode 100755 tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
tools/perf/arch/arm64/Makefile +21 -0
index 91de4860faad..85fdf4949db3 100644
@@ -4,3 +4,24 @@ PERF_HAVE_DWARF_REGS := 1
 endif
 PERF_HAVE_JITDUMP := 1
 PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
+
+#
+# Syscall table generation for perf
+#
+
+out    := $(OUTPUT)arch/arm64/include/generated/asm
+header := $(out)/syscalls.c
+sysdef := $(srctree)/tools/arch/arm64/include/uapi/asm/unistd.h
+sysprf := $(srctree)/tools/perf/arch/arm64/entry/syscalls/
+systbl := $(sysprf)/mksyscalltbl
+
+# Create output directory if not already present
+_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
+
+$(header): $(sysdef) $(systbl)
+	$(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(sysdef) > $@
+
+clean::
+	$(call QUIET_CLEAN, arm64) $(RM) $(header)
+
+archheaders: $(header)
tools/perf/arch/arm64/entry/syscalls/mksyscalltbl new file +61 -0

61 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw

Em Fri, Jul 06, 2018 at 04:34:43PM -0500, Kim Phillips escreveu:

Quoted 14 lines

This should speed up accessing new system calls introduced with the kernel rather than waiting for libaudit updates to include them.

Using the existing other arch scripts resulted in this error:

tools/perf/arch/arm64/entry/syscalls//mksyscalltbl: 25: printf: __NR3264_ftruncate: expected numeric value

because, unlike other arches, asm-generic's unistd.h does things like:

#define __NR_ftruncate __NR3264_ftruncate

Turning the scripts printf's %d into a %s resulted in this in the generated syscalls.c file:

Quoted 9 lines
    static const char *syscalltbl_arm64[] = {
            [__NR3264_ftruncate] = "ftruncate",

So we use the host C compiler to fold the macros, and print them out from within a temporary C program, in order to get the correct output:

    static const char *syscalltbl_arm64[] = {
            [46] = "ftruncate",

One of my containers, ubuntu:14.04.4-x-linaro-arm64, that build perf in a cross-build env, failed to build, please take a look if what is in the output below is enough for you to find the problem, perhaps you forgot to add the new files grabbed from the kernel sources to the tools/perf/MANIFEST file that is used to create the tarball that is then used to test build it? I'll check that later, in a hurry right now.

Thanks,

- Arnaldo

ubuntu:14.04.4-x-linaro-arm64
Downloading http://192.168.86.4/perf/perf-4.18.0-rc4.tar.xz...

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0100 1338k 100 1338k 0 0 73.8M 0 --:--:-- --:--:-- --:--:-- 87.1M
608df4c7ac9a7bde0129d08d7a16a0ea76e0dd23
Using built-in specs.
COLLECT_GCC=/gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/5.5.0/lto-wrapper
Target: aarch64-linux-gnu
Configured with: '/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/snapshots/gcc.git~linaro-5.5-2017.10/configure' SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libmudflap --enable-lto --enable-shared --without-included-gettext --enable-nls --disable-sjlj-exceptions --enable-gnu-unique-object --enable-linker-build-id --disable-libstdcxx-pch --enable-c99 --enable-clocale=gnu --enable-libstdcxx-debug --enable-long-long --with-cloog=no --with-ppl=no --with-isl=no --disable-multilib --enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419 --with-arch=armv8-a --enable-threads=posix --enable-multiarch --enable-libstdcxx-time=yes --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/sysroots/aarch64-linux-gnu --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu/aarch64-linux-gnu/libc --enable-checking=release --disable-bootstrap --enable-languages=c,c++,fortran,lto --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=aarch64-linux-gnu --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu Thread model: posix
gcc version 5.5.0 (Linaro GCC 5.5-2017.10)
make: Entering directory `/git/linux/tools/perf'

  BUILD:   Doing 'make -j4' parallel build
  HOSTCC   /tmp/build/perf/fixdep.o
  HOSTLD   /tmp/build/perf/fixdep-in.o
  LINK     /tmp/build/perf/fixdep

sh: 1: command: Illegal option -c

Auto-detecting system features:

...                         dwarf: [ on  ]
...            dwarf_getlocations: [ on  ]
...                         glibc: [ on  ]

... gtk2: [ OFF ]
... libaudit: [ OFF ]
... libbfd: [ OFF ]
... libelf: [ on ]
... libnuma: [ OFF ]
... numa_num_possible_cpus: [ OFF ]
... libperl: [ OFF ]
... libpython: [ OFF ]
... libslang: [ OFF ]
... libcrypto: [ OFF ]
... libunwind: [ OFF ]
... libdw-dwarf-unwind: [ on ]
... zlib: [ on ]
... lzma: [ OFF ]
... get_cpuid: [ OFF ]
... bpf: [ on ]

Makefile.config:445: No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev
Makefile.config:491: No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR
Makefile.config:583: No libcrypto.h found, disables jitted code injection, please install libssl-devel or libssl-dev
Makefile.config:598: slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev
Makefile.config:612: GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev
Makefile.config:639: Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev Makefile.config:666: No python interpreter was found: disables Python support - please install python-devel/python-dev
Makefile.config:721: No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling Makefile.config:750: No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev
Makefile.config:763: No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev Makefile.config:814: No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev Makefile.config:840: No alternatives command found, you need to set JDIR= to point to the root of your Java directory
GEN /tmp/build/perf/common-cmds.h
PERF_VERSION = 4.18.rc4.g608df4c7
<stdin>: In function 'main':
<stdin>:257:38: error: '__NR_getrandom' undeclared (first use in this function)
<stdin>:257:38: note: each undeclared identifier is reported only once for each function it appears in
<stdin>:258:41: error: '__NR_memfd_create' undeclared (first use in this function)
<stdin>:259:32: error: '__NR_bpf' undeclared (first use in this function)
<stdin>:260:37: error: '__NR_execveat' undeclared (first use in this function)
/git/linux/tools/perf/arch/arm64/entry/syscalls//mksyscalltbl: 46: /git/linux/tools/perf/arch/arm64/entry/syscalls//mksyscalltbl: /tmp/create-table-iJLXMb: Permission denied

  CC       /tmp/build/perf/event-parse.o
  MKDIR    /tmp/build/perf/fd/
  CC       /tmp/build/perf/fd/array.o
  MKDIR    /tmp/build/perf/fs/
  CC       /tmp/build/perf/fs/fs.o
  MKDIR    /tmp/build/perf/fd/
  LD       /tmp/build/perf/fd/libapi-in.o
  MKDIR    /tmp/build/perf/fs/
  CC       /tmp/build/perf/fs/tracing_path.o
  CC       /tmp/build/perf/event-plugin.o
  MKDIR    /tmp/build/perf/fs/
  LD       /tmp/build/perf/fs/libapi-in.o
  CC       /tmp/build/perf/cpu.o
  CC       /tmp/build/perf/trace-seq.o
  CC       /tmp/build/perf/debug.o
  CC       /tmp/build/perf/str_error_r.o
  CC       /tmp/build/perf/parse-filter.o
  LD       /tmp/build/perf/libapi-in.o
  AR       /tmp/build/perf/libapi.a
  CC       /tmp/build/perf/parse-utils.o
  CC       /tmp/build/perf/exec-cmd.o
  MKDIR    /tmp/build/perf/pmu-events/
  HOSTCC   /tmp/build/perf/pmu-events/json.o
  CC       /tmp/build/perf/libbpf.o
  CC       /tmp/build/perf/kbuffer-parse.o
  MKDIR    /tmp/build/perf/pmu-events/
  CC       /tmp/build/perf/help.o
  HOSTCC   /tmp/build/perf/pmu-events/jsmn.o
  LD       /tmp/build/perf/libtraceevent-in.o
  LINK     /tmp/build/perf/libtraceevent.a
  MKDIR    /tmp/build/perf/pmu-events/
  HOSTCC   /tmp/build/perf/pmu-events/jevents.o
  CC       /tmp/build/perf/bpf.o
  CC       /tmp/build/perf/nlattr.o
  MKDIR    /tmp/build/perf/pmu-events/
  HOSTLD   /tmp/build/perf/pmu-events/jevents-in.o
  CC       /tmp/build/perf/pager.o
  CC       /tmp/build/perf/plugin_jbd2.o
  CC       /tmp/build/perf/plugin_hrtimer.o
  CC       /tmp/build/perf/btf.o
  LD       /tmp/build/perf/plugin_jbd2-in.o
  LD       /tmp/build/perf/plugin_hrtimer-in.o
  CC       /tmp/build/perf/parse-options.o
  CC       /tmp/build/perf/plugin_kmem.o
  GEN      perf-archive
  CC       /tmp/build/perf/plugin_kvm.o
  LD       /tmp/build/perf/libbpf-in.o
  LINK     /tmp/build/perf/libbpf.a
  LD       /tmp/build/perf/plugin_kmem-in.o
  CC       /tmp/build/perf/plugin_mac80211.o
  CC       /tmp/build/perf/plugin_sched_switch.o
  LD       /tmp/build/perf/plugin_kvm-in.o
  CC       /tmp/build/perf/plugin_function.o
  LD       /tmp/build/perf/plugin_mac80211-in.o
  LD       /tmp/build/perf/plugin_sched_switch-in.o
  CC       /tmp/build/perf/plugin_xen.o
  CC       /tmp/build/perf/plugin_scsi.o
  LD       /tmp/build/perf/plugin_function-in.o
  CC       /tmp/build/perf/plugin_cfg80211.o
  LD       /tmp/build/perf/plugin_xen-in.o
  GEN      perf-with-kcore
  CC       /tmp/build/perf/run-command.o
  LD       /tmp/build/perf/plugin_scsi-in.o
  LD       /tmp/build/perf/plugin_cfg80211-in.o
  CC       /tmp/build/perf/sigchain.o
  LINK     /tmp/build/perf/plugin_jbd2.so
  LINK     /tmp/build/perf/plugin_hrtimer.so
  LINK     /tmp/build/perf/plugin_kmem.so
  LINK     /tmp/build/perf/plugin_kvm.so
  LINK     /tmp/build/perf/plugin_mac80211.so
  LINK     /tmp/build/perf/plugin_sched_switch.so
  CC       /tmp/build/perf/subcmd-config.o
  LINK     /tmp/build/perf/plugin_function.so
  LINK     /tmp/build/perf/plugin_xen.so
  LINK     /tmp/build/perf/plugin_scsi.so
  LINK     /tmp/build/perf/plugin_cfg80211.so
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/annotate.o
  CC       /tmp/build/perf/arch/common.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/block-range.o
  LD       /tmp/build/perf/libsubcmd-in.o
  AR       /tmp/build/perf/libsubcmd.a
  MKDIR    /tmp/build/perf/arch/arm64/util/
  CC       /tmp/build/perf/arch/arm64/util/header.o
  MKDIR    /tmp/build/perf/arch/arm64/tests/
  CC       /tmp/build/perf/arch/arm64/tests/regs_load.o
  MKDIR    /tmp/build/perf/arch/arm64/tests/
  CC       /tmp/build/perf/arch/arm64/tests/dwarf-unwind.o
  MKDIR    /tmp/build/perf/arch/arm64/util/
  CC       /tmp/build/perf/arch/arm64/util/sym-handling.o
  MKDIR    /tmp/build/perf/arch/arm64/util/
  CC       /tmp/build/perf/arch/arm64/util/dwarf-regs.o
  MKDIR    /tmp/build/perf/arch/arm64/tests/
  CC       /tmp/build/perf/arch/arm64/tests/arch-tests.o
  MKDIR    /tmp/build/perf/util/
  MKDIR    /tmp/build/perf/arch/arm64/util/
  CC       /tmp/build/perf/arch/arm64/util/unwind-libdw.o
  CC       /tmp/build/perf/util/build-id.o
  MKDIR    /tmp/build/perf/arch/arm64/tests/
  LD       /tmp/build/perf/arch/arm64/tests/libperf-in.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/config.o
  MKDIR    /tmp/build/perf/arch/arm64/util/../../arm/util/
  CC       /tmp/build/perf/arch/arm64/util/../../arm/util/pmu.o
  MKDIR    /tmp/build/perf/arch/arm64/util/../../arm/util/
  CC       /tmp/build/perf/arch/arm64/util/../../arm/util/auxtrace.o
  MKDIR    /tmp/build/perf/arch/arm64/util/../../arm/util/
  CC       /tmp/build/perf/arch/arm64/util/../../arm/util/cs-etm.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/ctype.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/db-export.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/env.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/event.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/evlist.o
  MKDIR    /tmp/build/perf/arch/arm64/util/
  CC       /tmp/build/perf/arch/arm64/util/arm-spe.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/evsel.o
  MKDIR    /tmp/build/perf/arch/arm64/util/
  LD       /tmp/build/perf/arch/arm64/util/libperf-in.o
  LD       /tmp/build/perf/arch/arm64/libperf-in.o
  LD       /tmp/build/perf/arch/libperf-in.o
  MKDIR    /tmp/build/perf/ui/
  CC       /tmp/build/perf/ui/setup.o
  MKDIR    /tmp/build/perf/ui/
  CC       /tmp/build/perf/ui/helpline.o
  MKDIR    /tmp/build/perf/ui/
  CC       /tmp/build/perf/ui/progress.o
  MKDIR    /tmp/build/perf/ui/
  CC       /tmp/build/perf/ui/util.o
  MKDIR    /tmp/build/perf/ui/
  CC       /tmp/build/perf/ui/hist.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/evsel_fprintf.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/find_bit.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/kallsyms.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/levenshtein.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/llvm-utils.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/mmap.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/memswap.o
  CC       /tmp/build/perf/builtin-bench.o
  LINK     /tmp/build/perf/pmu-events/jevents
  MKDIR    /tmp/build/perf/scripts/
  LD       /tmp/build/perf/scripts/libperf-in.o
  CC       /tmp/build/perf/trace/beauty/clone.o
  CC       /tmp/build/perf/builtin-annotate.o
  CC       /tmp/build/perf/trace/beauty/fcntl.o
  CC       /tmp/build/perf/trace/beauty/flock.o
  CC       /tmp/build/perf/trace/beauty/kcmp.o
  MKDIR    /tmp/build/perf/util/
  BISON    /tmp/build/perf/util/parse-events-bison.c
  CC       /tmp/build/perf/trace/beauty/pkey_alloc.o
  CC       /tmp/build/perf/builtin-config.o
  CC       /tmp/build/perf/trace/beauty/prctl.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/perf_regs.o
  MKDIR    /tmp/build/perf/ui/stdio/
  CC       /tmp/build/perf/ui/stdio/hist.o
  CC       /tmp/build/perf/trace/beauty/statx.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/path.o
  CC       /tmp/build/perf/builtin-diff.o
  LD       /tmp/build/perf/trace/beauty/libperf-in.o
  GEN      /tmp/build/perf/libtraceevent-dynamic-list
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/print_binary.o
  GEN      /tmp/build/perf/pmu-events/pmu-events.c
  CC       /tmp/build/perf/pmu-events/pmu-events.o
  LD       /tmp/build/perf/pmu-events/pmu-events-in.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/rbtree.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/libstring.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/bitmap.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/hweight.o
  MKDIR    /tmp/build/perf/util/
  MKDIR    /tmp/build/perf/ui/
  CC       /tmp/build/perf/builtin-evlist.o
  CC       /tmp/build/perf/util/smt.o
  LD       /tmp/build/perf/ui/libperf-in.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/strbuf.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/string.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/strlist.o
  CC       /tmp/build/perf/builtin-ftrace.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/strfilter.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/top.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/usage.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/dso.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/symbol.o
  CC       /tmp/build/perf/builtin-help.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/symbol_fprintf.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/color.o
  CC       /tmp/build/perf/builtin-sched.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/metricgroup.o
  CC       /tmp/build/perf/builtin-buildid-list.o
  CC       /tmp/build/perf/builtin-buildid-cache.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/header.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/callchain.o
  CC       /tmp/build/perf/builtin-kallsyms.o
  CC       /tmp/build/perf/builtin-list.o
  CC       /tmp/build/perf/builtin-record.o
  CC       /tmp/build/perf/builtin-report.o
  CC       /tmp/build/perf/builtin-stat.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/values.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/debug.o
  CC       /tmp/build/perf/builtin-timechart.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/machine.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/map.o
  CC       /tmp/build/perf/builtin-top.o
  CC       /tmp/build/perf/builtin-script.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/pstack.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/session.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/syscalltbl.o

util/syscalltbl.c:43:38:SYSCALLTBL_ARM64_MAX_ID' undeclared here (not in a function)
const int syscalltbl_native_max_id = SYSCALLTBL_ARM64_MAX_ID;
mv: cannot stat '/tmp/build/perf/util/.syscalltbl.o.tmp': No such file or directory make[4]: *** [/tmp/build/perf/util/syscalltbl.o] Error 1
make[4]: *** Waiting for unfinished jobs....

  CC       /tmp/build/perf/builtin-kmem.o
  CC       /tmp/build/perf/builtin-lock.o
  CC       /tmp/build/perf/builtin-kvm.o
make[3]: *** [util] Error 2
make[2]: *** [/tmp/build/perf/libperf-in.o] Error 2
make[2]: *** Waiting for unfinished jobs....
  CC       /tmp/build/perf/builtin-inject.o
  CC       /tmp/build/perf/builtin-mem.o
  CC       /tmp/build/perf/builtin-data.o
  CC       /tmp/build/perf/builtin-version.o
  CC       /tmp/build/perf/builtin-c2c.o
  CC       /tmp/build/perf/builtin-trace.o
  CC       /tmp/build/perf/builtin-probe.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/sched-messaging.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/builtin-test.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/sched-pipe.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/parse-events.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/mem-functions.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/futex-hash.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/futex-wake.o
  CC       /tmp/build/perf/perf.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/futex-wake-parallel.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/futex-requeue.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/futex-lock-pi.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/dso-data.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/attr.o
  MKDIR    /tmp/build/perf/bench/
  LD       /tmp/build/perf/bench/perf-in.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/vmlinux-kallsyms.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/openat-syscall.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/openat-syscall-all-cpus.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/openat-syscall-tp-fields.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/mmap-basic.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/perf-record.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/evsel-roundtrip-name.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/evsel-tp-sched.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/fdarray.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/pmu.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/hists_common.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/hists_link.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/hists_filter.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/hists_output.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/hists_cumulate.o
  MKDIR    /tmp/build/perf/tests/
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/bp_signal.o
  CC       /tmp/build/perf/tests/python-use.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/bp_signal_overflow.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/bp_account.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/task-exit.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/sw-clock.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/mmap-thread-lookup.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/thread-mg-share.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/switch-tracking.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/keep-tracking.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/code-reading.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/sample-parsing.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/parse-no-sample-id-all.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/kmod-path.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/thread-map.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/llvm.o
  MKDIR    /tmp/build/perf/tests/
  MKDIR    /tmp/build/perf/tests/
  MKDIR    /tmp/build/perf/tests/
  MKDIR    /tmp/build/perf/tests/
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/bpf.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/topology.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/mem.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/cpumap.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/stat.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/event_update.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/event-times.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/expr.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/backward-ring-buffer.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/sdt.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/is_printable_array.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/bitmap.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/perf-hooks.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/clang.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/unit_number__scnprintf.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/mem2node.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/dwarf-unwind.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/llvm-src-base.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/llvm-src-kbuild.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/llvm-src-prologue.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/llvm-src-relocation.o
  MKDIR    /tmp/build/perf/tests/
  LD       /tmp/build/perf/tests/perf-in.o
  LD       /tmp/build/perf/perf-in.o

make[1]: *** [sub-make] Error 2
make: *** [all] Error 2
make: Leaving directory `/git/linux/tools/perf'

#2 lore raw

Em Wed, Jul 18, 2018 at 12:57:52PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 25 lines

Em Fri, Jul 06, 2018 at 04:34:43PM -0500, Kim Phillips escreveu:

Quoted 14 lines

This should speed up accessing new system calls introduced with the kernel rather than waiting for libaudit updates to include them.

Using the existing other arch scripts resulted in this error:

tools/perf/arch/arm64/entry/syscalls//mksyscalltbl: 25: printf: __NR3264_ftruncate: expected numeric value

because, unlike other arches, asm-generic's unistd.h does things like:

#define __NR_ftruncate __NR3264_ftruncate

Turning the scripts printf's %d into a %s resulted in this in the generated syscalls.c file:

Quoted 9 lines
    static const char *syscalltbl_arm64[] = {
            [__NR3264_ftruncate] = "ftruncate",

So we use the host C compiler to fold the macros, and print them out from within a temporary C program, in order to get the correct output:

    static const char *syscalltbl_arm64[] = {
            [46] = "ftruncate",
Quoted 6 lines

One of my containers, ubuntu:14.04.4-x-linaro-arm64, that build perf in a cross-build env, failed to build, please take a look if what is in the output below is enough for you to find the problem, perhaps you forgot to add the new files grabbed from the kernel sources to the tools/perf/MANIFEST file that is used to create the tarball that is then used to test build it? I'll check that later, in a hurry right now.

Shouldn't be the MANIFEST file, as it gets the whole trees of directories containing the files you added in this series, possibly something related to cross building or a header file with that same name taking precedence, still have to verify, have you had the chance to look at this?

- Arnaldo

Quoted 471 lines

Thanks,

- Arnaldo

ubuntu:14.04.4-x-linaro-arm64
Downloading http://192.168.86.4/perf/perf-4.18.0-rc4.tar.xz...

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0100 1338k 100 1338k 0 0 73.8M 0 --:--:-- --:--:-- --:--:-- 87.1M
608df4c7ac9a7bde0129d08d7a16a0ea76e0dd23
Using built-in specs.
COLLECT_GCC=/gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/gcc-linaro-5.5.0-2017.10-x86_64_aarch64-linux-gnu/bin/../libexec/gcc/aarch64-linux-gnu/5.5.0/lto-wrapper
Target: aarch64-linux-gnu
Configured with: '/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/snapshots/gcc.git~linaro-5.5-2017.10/configure' SHELL=/bin/bash --with-mpc=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-mpfr=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gmp=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu --with-gnu-as --with-gnu-ld --disable-libmudflap --enable-lto --enable-shared --without-included-gettext --enable-nls --disable-sjlj-exceptions --enable-gnu-unique-object --enable-linker-build-id --disable-libstdcxx-pch --enable-c99 --enable-clocale=gnu --enable-libstdcxx-debug --enable-long-long --with-cloog=no --with-ppl=no --with-isl=no --disable-multilib --enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419 --with-arch=armv8-a --enable-threads=posix --enable-multiarch --enable-libstdcxx-time=yes --with-build-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/sysroots/aarch64-linux-gnu --with-sysroot=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu/aarch64-linux-gnu/libc --enable-checking=release --disable-bootstrap --enable-languages=c,c++,fortran,lto --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=aarch64-linux-gnu --prefix=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu Thread model: posix
gcc version 5.5.0 (Linaro GCC 5.5-2017.10)
make: Entering directory `/git/linux/tools/perf'

  BUILD:   Doing 'make -j4' parallel build
  HOSTCC   /tmp/build/perf/fixdep.o
  HOSTLD   /tmp/build/perf/fixdep-in.o
  LINK     /tmp/build/perf/fixdep

sh: 1: command: Illegal option -c

Auto-detecting system features:

...                         dwarf: [ on  ]
...            dwarf_getlocations: [ on  ]
...                         glibc: [ on  ]

... gtk2: [ OFF ]
... libaudit: [ OFF ]
... libbfd: [ OFF ]
... libelf: [ on ]
... libnuma: [ OFF ]
... numa_num_possible_cpus: [ OFF ]
... libperl: [ OFF ]
... libpython: [ OFF ]
... libslang: [ OFF ]
... libcrypto: [ OFF ]
... libunwind: [ OFF ]
... libdw-dwarf-unwind: [ on ]
... zlib: [ on ]
... lzma: [ OFF ]
... get_cpuid: [ OFF ]
... bpf: [ on ]

Makefile.config:445: No sys/sdt.h found, no SDT events are defined, please install systemtap-sdt-devel or systemtap-sdt-dev
Makefile.config:491: No libunwind found. Please install libunwind-dev[el] >= 1.1 and/or set LIBUNWIND_DIR
Makefile.config:583: No libcrypto.h found, disables jitted code injection, please install libssl-devel or libssl-dev
Makefile.config:598: slang not found, disables TUI support. Please install slang-devel, libslang-dev or libslang2-dev
Makefile.config:612: GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev
Makefile.config:639: Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev Makefile.config:666: No python interpreter was found: disables Python support - please install python-devel/python-dev
Makefile.config:721: No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling Makefile.config:750: No liblzma found, disables xz kernel module decompression, please install xz-devel/liblzma-dev
Makefile.config:763: No numa.h found, disables 'perf bench numa mem' benchmark, please install numactl-devel/libnuma-devel/libnuma-dev Makefile.config:814: No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev Makefile.config:840: No alternatives command found, you need to set JDIR= to point to the root of your Java directory
GEN /tmp/build/perf/common-cmds.h
PERF_VERSION = 4.18.rc4.g608df4c7
<stdin>: In function 'main':
<stdin>:257:38: error: '__NR_getrandom' undeclared (first use in this function)
<stdin>:257:38: note: each undeclared identifier is reported only once for each function it appears in
<stdin>:258:41: error: '__NR_memfd_create' undeclared (first use in this function)
<stdin>:259:32: error: '__NR_bpf' undeclared (first use in this function)
<stdin>:260:37: error: '__NR_execveat' undeclared (first use in this function)
/git/linux/tools/perf/arch/arm64/entry/syscalls//mksyscalltbl: 46: /git/linux/tools/perf/arch/arm64/entry/syscalls//mksyscalltbl: /tmp/create-table-iJLXMb: Permission denied

  CC       /tmp/build/perf/event-parse.o
  MKDIR    /tmp/build/perf/fd/
  CC       /tmp/build/perf/fd/array.o
  MKDIR    /tmp/build/perf/fs/
  CC       /tmp/build/perf/fs/fs.o
  MKDIR    /tmp/build/perf/fd/
  LD       /tmp/build/perf/fd/libapi-in.o
  MKDIR    /tmp/build/perf/fs/
  CC       /tmp/build/perf/fs/tracing_path.o
  CC       /tmp/build/perf/event-plugin.o
  MKDIR    /tmp/build/perf/fs/
  LD       /tmp/build/perf/fs/libapi-in.o
  CC       /tmp/build/perf/cpu.o
  CC       /tmp/build/perf/trace-seq.o
  CC       /tmp/build/perf/debug.o
  CC       /tmp/build/perf/str_error_r.o
  CC       /tmp/build/perf/parse-filter.o
  LD       /tmp/build/perf/libapi-in.o
  AR       /tmp/build/perf/libapi.a
  CC       /tmp/build/perf/parse-utils.o
  CC       /tmp/build/perf/exec-cmd.o
  MKDIR    /tmp/build/perf/pmu-events/
  HOSTCC   /tmp/build/perf/pmu-events/json.o
  CC       /tmp/build/perf/libbpf.o
  CC       /tmp/build/perf/kbuffer-parse.o
  MKDIR    /tmp/build/perf/pmu-events/
  CC       /tmp/build/perf/help.o
  HOSTCC   /tmp/build/perf/pmu-events/jsmn.o
  LD       /tmp/build/perf/libtraceevent-in.o
  LINK     /tmp/build/perf/libtraceevent.a
  MKDIR    /tmp/build/perf/pmu-events/
  HOSTCC   /tmp/build/perf/pmu-events/jevents.o
  CC       /tmp/build/perf/bpf.o
  CC       /tmp/build/perf/nlattr.o
  MKDIR    /tmp/build/perf/pmu-events/
  HOSTLD   /tmp/build/perf/pmu-events/jevents-in.o
  CC       /tmp/build/perf/pager.o
  CC       /tmp/build/perf/plugin_jbd2.o
  CC       /tmp/build/perf/plugin_hrtimer.o
  CC       /tmp/build/perf/btf.o
  LD       /tmp/build/perf/plugin_jbd2-in.o
  LD       /tmp/build/perf/plugin_hrtimer-in.o
  CC       /tmp/build/perf/parse-options.o
  CC       /tmp/build/perf/plugin_kmem.o
  GEN      perf-archive
  CC       /tmp/build/perf/plugin_kvm.o
  LD       /tmp/build/perf/libbpf-in.o
  LINK     /tmp/build/perf/libbpf.a
  LD       /tmp/build/perf/plugin_kmem-in.o
  CC       /tmp/build/perf/plugin_mac80211.o
  CC       /tmp/build/perf/plugin_sched_switch.o
  LD       /tmp/build/perf/plugin_kvm-in.o
  CC       /tmp/build/perf/plugin_function.o
  LD       /tmp/build/perf/plugin_mac80211-in.o
  LD       /tmp/build/perf/plugin_sched_switch-in.o
  CC       /tmp/build/perf/plugin_xen.o
  CC       /tmp/build/perf/plugin_scsi.o
  LD       /tmp/build/perf/plugin_function-in.o
  CC       /tmp/build/perf/plugin_cfg80211.o
  LD       /tmp/build/perf/plugin_xen-in.o
  GEN      perf-with-kcore
  CC       /tmp/build/perf/run-command.o
  LD       /tmp/build/perf/plugin_scsi-in.o
  LD       /tmp/build/perf/plugin_cfg80211-in.o
  CC       /tmp/build/perf/sigchain.o
  LINK     /tmp/build/perf/plugin_jbd2.so
  LINK     /tmp/build/perf/plugin_hrtimer.so
  LINK     /tmp/build/perf/plugin_kmem.so
  LINK     /tmp/build/perf/plugin_kvm.so
  LINK     /tmp/build/perf/plugin_mac80211.so
  LINK     /tmp/build/perf/plugin_sched_switch.so
  CC       /tmp/build/perf/subcmd-config.o
  LINK     /tmp/build/perf/plugin_function.so
  LINK     /tmp/build/perf/plugin_xen.so
  LINK     /tmp/build/perf/plugin_scsi.so
  LINK     /tmp/build/perf/plugin_cfg80211.so
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/annotate.o
  CC       /tmp/build/perf/arch/common.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/block-range.o
  LD       /tmp/build/perf/libsubcmd-in.o
  AR       /tmp/build/perf/libsubcmd.a
  MKDIR    /tmp/build/perf/arch/arm64/util/
  CC       /tmp/build/perf/arch/arm64/util/header.o
  MKDIR    /tmp/build/perf/arch/arm64/tests/
  CC       /tmp/build/perf/arch/arm64/tests/regs_load.o
  MKDIR    /tmp/build/perf/arch/arm64/tests/
  CC       /tmp/build/perf/arch/arm64/tests/dwarf-unwind.o
  MKDIR    /tmp/build/perf/arch/arm64/util/
  CC       /tmp/build/perf/arch/arm64/util/sym-handling.o
  MKDIR    /tmp/build/perf/arch/arm64/util/
  CC       /tmp/build/perf/arch/arm64/util/dwarf-regs.o
  MKDIR    /tmp/build/perf/arch/arm64/tests/
  CC       /tmp/build/perf/arch/arm64/tests/arch-tests.o
  MKDIR    /tmp/build/perf/util/
  MKDIR    /tmp/build/perf/arch/arm64/util/
  CC       /tmp/build/perf/arch/arm64/util/unwind-libdw.o
  CC       /tmp/build/perf/util/build-id.o
  MKDIR    /tmp/build/perf/arch/arm64/tests/
  LD       /tmp/build/perf/arch/arm64/tests/libperf-in.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/config.o
  MKDIR    /tmp/build/perf/arch/arm64/util/../../arm/util/
  CC       /tmp/build/perf/arch/arm64/util/../../arm/util/pmu.o
  MKDIR    /tmp/build/perf/arch/arm64/util/../../arm/util/
  CC       /tmp/build/perf/arch/arm64/util/../../arm/util/auxtrace.o
  MKDIR    /tmp/build/perf/arch/arm64/util/../../arm/util/
  CC       /tmp/build/perf/arch/arm64/util/../../arm/util/cs-etm.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/ctype.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/db-export.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/env.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/event.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/evlist.o
  MKDIR    /tmp/build/perf/arch/arm64/util/
  CC       /tmp/build/perf/arch/arm64/util/arm-spe.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/evsel.o
  MKDIR    /tmp/build/perf/arch/arm64/util/
  LD       /tmp/build/perf/arch/arm64/util/libperf-in.o
  LD       /tmp/build/perf/arch/arm64/libperf-in.o
  LD       /tmp/build/perf/arch/libperf-in.o
  MKDIR    /tmp/build/perf/ui/
  CC       /tmp/build/perf/ui/setup.o
  MKDIR    /tmp/build/perf/ui/
  CC       /tmp/build/perf/ui/helpline.o
  MKDIR    /tmp/build/perf/ui/
  CC       /tmp/build/perf/ui/progress.o
  MKDIR    /tmp/build/perf/ui/
  CC       /tmp/build/perf/ui/util.o
  MKDIR    /tmp/build/perf/ui/
  CC       /tmp/build/perf/ui/hist.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/evsel_fprintf.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/find_bit.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/kallsyms.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/levenshtein.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/llvm-utils.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/mmap.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/memswap.o
  CC       /tmp/build/perf/builtin-bench.o
  LINK     /tmp/build/perf/pmu-events/jevents
  MKDIR    /tmp/build/perf/scripts/
  LD       /tmp/build/perf/scripts/libperf-in.o
  CC       /tmp/build/perf/trace/beauty/clone.o
  CC       /tmp/build/perf/builtin-annotate.o
  CC       /tmp/build/perf/trace/beauty/fcntl.o
  CC       /tmp/build/perf/trace/beauty/flock.o
  CC       /tmp/build/perf/trace/beauty/kcmp.o
  MKDIR    /tmp/build/perf/util/
  BISON    /tmp/build/perf/util/parse-events-bison.c
  CC       /tmp/build/perf/trace/beauty/pkey_alloc.o
  CC       /tmp/build/perf/builtin-config.o
  CC       /tmp/build/perf/trace/beauty/prctl.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/perf_regs.o
  MKDIR    /tmp/build/perf/ui/stdio/
  CC       /tmp/build/perf/ui/stdio/hist.o
  CC       /tmp/build/perf/trace/beauty/statx.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/path.o
  CC       /tmp/build/perf/builtin-diff.o
  LD       /tmp/build/perf/trace/beauty/libperf-in.o
  GEN      /tmp/build/perf/libtraceevent-dynamic-list
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/print_binary.o
  GEN      /tmp/build/perf/pmu-events/pmu-events.c
  CC       /tmp/build/perf/pmu-events/pmu-events.o
  LD       /tmp/build/perf/pmu-events/pmu-events-in.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/rbtree.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/libstring.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/bitmap.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/hweight.o
  MKDIR    /tmp/build/perf/util/
  MKDIR    /tmp/build/perf/ui/
  CC       /tmp/build/perf/builtin-evlist.o
  CC       /tmp/build/perf/util/smt.o
  LD       /tmp/build/perf/ui/libperf-in.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/strbuf.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/string.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/strlist.o
  CC       /tmp/build/perf/builtin-ftrace.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/strfilter.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/top.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/usage.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/dso.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/symbol.o
  CC       /tmp/build/perf/builtin-help.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/symbol_fprintf.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/color.o
  CC       /tmp/build/perf/builtin-sched.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/metricgroup.o
  CC       /tmp/build/perf/builtin-buildid-list.o
  CC       /tmp/build/perf/builtin-buildid-cache.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/header.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/callchain.o
  CC       /tmp/build/perf/builtin-kallsyms.o
  CC       /tmp/build/perf/builtin-list.o
  CC       /tmp/build/perf/builtin-record.o
  CC       /tmp/build/perf/builtin-report.o
  CC       /tmp/build/perf/builtin-stat.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/values.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/debug.o
  CC       /tmp/build/perf/builtin-timechart.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/machine.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/map.o
  CC       /tmp/build/perf/builtin-top.o
  CC       /tmp/build/perf/builtin-script.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/pstack.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/session.o
  MKDIR    /tmp/build/perf/util/
  CC       /tmp/build/perf/util/syscalltbl.o

util/syscalltbl.c:43:38:SYSCALLTBL_ARM64_MAX_ID' undeclared here (not in a function)
const int syscalltbl_native_max_id = SYSCALLTBL_ARM64_MAX_ID;
mv: cannot stat '/tmp/build/perf/util/.syscalltbl.o.tmp': No such file or directory make[4]: *** [/tmp/build/perf/util/syscalltbl.o] Error 1
make[4]: *** Waiting for unfinished jobs....

  CC       /tmp/build/perf/builtin-kmem.o
  CC       /tmp/build/perf/builtin-lock.o
  CC       /tmp/build/perf/builtin-kvm.o
make[3]: *** [util] Error 2
make[2]: *** [/tmp/build/perf/libperf-in.o] Error 2
make[2]: *** Waiting for unfinished jobs....
  CC       /tmp/build/perf/builtin-inject.o
  CC       /tmp/build/perf/builtin-mem.o
  CC       /tmp/build/perf/builtin-data.o
  CC       /tmp/build/perf/builtin-version.o
  CC       /tmp/build/perf/builtin-c2c.o
  CC       /tmp/build/perf/builtin-trace.o
  CC       /tmp/build/perf/builtin-probe.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/sched-messaging.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/builtin-test.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/sched-pipe.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/parse-events.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/mem-functions.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/futex-hash.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/futex-wake.o
  CC       /tmp/build/perf/perf.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/futex-wake-parallel.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/futex-requeue.o
  MKDIR    /tmp/build/perf/bench/
  CC       /tmp/build/perf/bench/futex-lock-pi.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/dso-data.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/attr.o
  MKDIR    /tmp/build/perf/bench/
  LD       /tmp/build/perf/bench/perf-in.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/vmlinux-kallsyms.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/openat-syscall.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/openat-syscall-all-cpus.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/openat-syscall-tp-fields.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/mmap-basic.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/perf-record.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/evsel-roundtrip-name.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/evsel-tp-sched.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/fdarray.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/pmu.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/hists_common.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/hists_link.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/hists_filter.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/hists_output.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/hists_cumulate.o
  MKDIR    /tmp/build/perf/tests/
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/bp_signal.o
  CC       /tmp/build/perf/tests/python-use.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/bp_signal_overflow.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/bp_account.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/task-exit.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/sw-clock.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/mmap-thread-lookup.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/thread-mg-share.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/switch-tracking.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/keep-tracking.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/code-reading.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/sample-parsing.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/parse-no-sample-id-all.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/kmod-path.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/thread-map.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/llvm.o
  MKDIR    /tmp/build/perf/tests/
  MKDIR    /tmp/build/perf/tests/
  MKDIR    /tmp/build/perf/tests/
  MKDIR    /tmp/build/perf/tests/
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/bpf.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/topology.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/mem.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/cpumap.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/stat.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/event_update.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/event-times.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/expr.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/backward-ring-buffer.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/sdt.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/is_printable_array.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/bitmap.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/perf-hooks.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/clang.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/unit_number__scnprintf.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/mem2node.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/dwarf-unwind.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/llvm-src-base.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/llvm-src-kbuild.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/llvm-src-prologue.o
  MKDIR    /tmp/build/perf/tests/
  CC       /tmp/build/perf/tests/llvm-src-relocation.o
  MKDIR    /tmp/build/perf/tests/
  LD       /tmp/build/perf/tests/perf-in.o
  LD       /tmp/build/perf/perf-in.o

make[1]: *** [sub-make] Error 2
make: *** [all] Error 2
make: Leaving directory `/git/linux/tools/perf'

#3 lore raw

Em Fri, Jul 20, 2018 at 12:06:53PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 33 lines

Em Wed, Jul 18, 2018 at 12:57:52PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 31 lines

Em Fri, Jul 06, 2018 at 04:34:43PM -0500, Kim Phillips escreveu:

Quoted 14 lines

This should speed up accessing new system calls introduced with the kernel rather than waiting for libaudit updates to include them.

Using the existing other arch scripts resulted in this error:

tools/perf/arch/arm64/entry/syscalls//mksyscalltbl: 25: printf: __NR3264_ftruncate: expected numeric value

because, unlike other arches, asm-generic's unistd.h does things like:

#define __NR_ftruncate __NR3264_ftruncate

Turning the scripts printf's %d into a %s resulted in this in the generated syscalls.c file:

Quoted 9 lines
    static const char *syscalltbl_arm64[] = {
            [__NR3264_ftruncate] = "ftruncate",

So we use the host C compiler to fold the macros, and print them out from within a temporary C program, in order to get the correct output:

    static const char *syscalltbl_arm64[] = {
            [46] = "ftruncate",

One of my containers, ubuntu:14.04.4-x-linaro-arm64, that build perf in a cross-build env, failed to build, please take a look if what is in the output below is enough for you to find the problem, perhaps you forgot to add the new files grabbed from the kernel sources to the tools/perf/MANIFEST file that is used to create the tarball that is then used to test build it? I'll check that later, in a hurry right now.

So it fails with:

perfbuilder@7dbfe2fe9bef:/git/perf$ tools/perf/arch/arm64/entry/syscalls/mksyscalltbl /gcc-linaro-5.4.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc gcc tools/arch/arm64/include/uapi/asm/unistd.h
static const char *syscalltbl_arm64[] = {
<stdin>: In function 'main':
<stdin>:257:38: error: '__NR_getrandom' undeclared (first use in this function)
<stdin>:257:38: note: each undeclared identifier is reported only once for each function it appears in
<stdin>:258:41: error: '__NR_memfd_create' undeclared (first use in this function)
<stdin>:259:32: error: '__NR_bpf' undeclared (first use in this function)
<stdin>:260:37: error: '__NR_execveat' undeclared (first use in this function)
tools/perf/arch/arm64/entry/syscalls/mksyscalltbl: 47: tools/perf/arch/arm64/entry/syscalls/mksyscalltbl: /tmp/create-table-60liya: Permission denied

Because it uses as input this file tools/arch/arm64/include/uapi/asm/unistd.h, that basically just does:

perfbuilder@1015f8b85ded:/git/perf$ cat tools/arch/arm64/include/uapi/asm/unistd.h
#define __ARCH_WANT_RENAMEAT

#include <asm-generic/unistd.h>
perfbuilder@1015f8b85ded:/git/perf$

And this ends up getting the system's asm-generic/unistd.h file, not the one shipped in tools/, so:

perfbuilder@1015f8b85ded:/git/perf$ grep bpf /usr/include/asm-generic/unistd.h 
perfbuilder@1015f8b85ded:/git/perf$ grep _NR_ /usr/include/asm-generic/unistd.h  | tail -4
#define __NR_mmap2 __NR3264_mmap
#define __NR_fadvise64_64 __NR3264_fadvise64
#define __NR_stat64 __NR3264_stat
#define __NR_lstat64 __NR3264_lstat
perfbuilder@1015f8b85ded:/git/perf$ 

A quick hack is to do this instead:

tools/perf/arch/arm64/Makefile +1 -1
index 85fdf4949db3..f013b115dc86 100644
@@ -11,7 +11,7 @@ PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
 
 out    := $(OUTPUT)arch/arm64/include/generated/asm
 header := $(out)/syscalls.c
-sysdef := $(srctree)/tools/arch/arm64/include/uapi/asm/unistd.h
+sysdef := $(srctree)/tools/include/uapi/asm-generic/unistd.h
 sysprf := $(srctree)/tools/perf/arch/arm64/entry/syscalls/
 systbl := $(sysprf)/mksyscalltbl
 
tools/perf/arch/arm64/entry/syscalls/mksyscalltbl +1 -0
index c21023509960..52e197317d3e 100755
@@ -28,6 +28,7 @@ create_table_from_c()
 
 	cat <<-_EoHEADER
 		#include <stdio.h>
+		#define __ARCH_WANT_RENAMEAT
 		#include "$input"
 		int main(int argc, char *argv[])
 		{
#4 lore raw

Em Mon, Jul 23, 2018 at 03:59:05PM -0300, Arnaldo Carvalho de Melo escreveu:

Quoted 1 line

A quick hack is to do this instead:

I'm going with this quick hack applied so that I can pass all tests, feel free to provide an alternative patch that makes tools/include/uapi/asm-generic/unistd.h be used when included by tools/arch/arm64/include/uapi/asm/unistd.h, that I haven't tried to do and looks the right fix.

- Arnaldo

Quoted 25 lines
tools/perf/arch/arm64/Makefile +1 -1
index 85fdf4949db3..f013b115dc86 100644
@@ -11,7 +11,7 @@ PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
 
 out    := $(OUTPUT)arch/arm64/include/generated/asm
 header := $(out)/syscalls.c
-sysdef := $(srctree)/tools/arch/arm64/include/uapi/asm/unistd.h
+sysdef := $(srctree)/tools/include/uapi/asm-generic/unistd.h
 sysprf := $(srctree)/tools/perf/arch/arm64/entry/syscalls/
 systbl := $(sysprf)/mksyscalltbl
 
tools/perf/arch/arm64/entry/syscalls/mksyscalltbl +1 -0
index c21023509960..52e197317d3e 100755
@@ -28,6 +28,7 @@ create_table_from_c()
 
 	cat <<-_EoHEADER
 		#include <stdio.h>
+		#define __ARCH_WANT_RENAMEAT
 		#include "$input"
 		int main(int argc, char *argv[])
 		{
#5 lore raw

PATCH 1/1 perf arm64: Fix include path for asm-generic/unistd.h

The new syscall table support for arm64 mistakenly used the system's asm-generic/unistd.h file when processing the tools/arch/arm64/include/uapi/asm/unistd.h file's include directive:

	#include <asm-generic/unistd.h>

See "Committer notes" section of commit 2b5882435606 "perf arm64:
Generate system call table from asm/unistd.h" for more details.

This patch removes the committer's temporary workaround, and instructs the host compiler to search the build tree's include path for the right copy of the unistd.h file, instead of the one on the system's /usr/include path.

It thus fixes the committer's test that cross-builds an arm64 perf on an x86 platform running Ubuntu 14.04.5 LTS with an old toolchain:

$ tools/perf/arch/arm64/entry/syscalls/mksyscalltbl /gcc-linaro-5.4.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc gcc `pwd`/tools tools/arch/arm64/include/uapi/asm/unistd.h | grep bpf
	[280] = "bpf",
Cc Hendrik Brueckner <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ravi Bangoria <[email protected]>
Cc Thomas Richter <[email protected]>
Fixes 2b5882435606 ("perf arm64: Generate system call table from asm/unistd.h")

---
Hi, sorry for late response - was on vacation. I was able to reproduce and fix by adding this -I to the $hostcc line. Please test, and let me know if this is an acceptable fix.

 tools/perf/arch/arm64/Makefile                    | 5 +++--
 tools/perf/arch/arm64/entry/syscalls/mksyscalltbl | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)
tools/perf/arch/arm64/Makefile +3 -2
index f013b115dc86..dbef716a1913 100644
@@ -11,7 +11,8 @@ PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
 
 out    := $(OUTPUT)arch/arm64/include/generated/asm
 header := $(out)/syscalls.c
-sysdef := $(srctree)/tools/include/uapi/asm-generic/unistd.h
+incpath := $(srctree)/tools
+sysdef := $(srctree)/tools/arch/arm64/include/uapi/asm/unistd.h
 sysprf := $(srctree)/tools/perf/arch/arm64/entry/syscalls/
 systbl := $(sysprf)/mksyscalltbl
 
@@ -19,7 +20,7 @@ systbl := $(sysprf)/mksyscalltbl
 _dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
 
 $(header): $(sysdef) $(systbl)
-	$(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(sysdef) > $@
+	$(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(incpath) $(sysdef) > $@
 
 clean::
 	$(call QUIET_CLEAN, arm64) $(RM) $(header)
tools/perf/arch/arm64/entry/syscalls/mksyscalltbl +3 -3
index 52e197317d3e..2dbb8cade048 100755
@@ -11,7 +11,8 @@
 
 gcc=$1
 hostcc=$2
-input=$3
+incpath=$3
+input=$4
 
 if ! test -r $input; then
 	echo "Could not read input file" >&2
@@ -28,7 +29,6 @@ create_table_from_c()
 
 	cat <<-_EoHEADER
 		#include <stdio.h>
-		#define __ARCH_WANT_RENAMEAT
 		#include "$input"
 		int main(int argc, char *argv[])
 		{
@@ -42,7 +42,7 @@ create_table_from_c()
 	printf "%s\n" "	printf(\"#define SYSCALLTBL_ARM64_MAX_ID %d\\n\", __NR_$last_sc);"
 	printf "}\n"
 
-	} | $hostcc -o $create_table_exe -x c -
+	} | $hostcc -I $incpath/include/uapi -o $create_table_exe -x c -
 
 	$create_table_exe
 
Signature · 1 line
2.17.1
#6 lore raw

Re: [PATCH] perf arm64: Fix include path for asm-generic/unistd.h

Em Mon, Aug 06, 2018 at 05:28:00PM -0500, Kim Phillips escreveu:

Quoted 31 lines

The new syscall table support for arm64 mistakenly used the system's asm-generic/unistd.h file when processing the tools/arch/arm64/include/uapi/asm/unistd.h file's include directive:

	#include <asm-generic/unistd.h>

See "Committer notes" section of commit 2b5882435606 "perf arm64:
Generate system call table from asm/unistd.h" for more details.

This patch removes the committer's temporary workaround, and instructs the host compiler to search the build tree's include path for the right copy of the unistd.h file, instead of the one on the system's /usr/include path.

It thus fixes the committer's test that cross-builds an arm64 perf on an x86 platform running Ubuntu 14.04.5 LTS with an old toolchain:

$ tools/perf/arch/arm64/entry/syscalls/mksyscalltbl /gcc-linaro-5.4.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc gcc `pwd`/tools tools/arch/arm64/include/uapi/asm/unistd.h | grep bpf
	[280] = "bpf",
Cc Hendrik Brueckner <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Alexander Shishkin <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ravi Bangoria <[email protected]>
Cc Thomas Richter <[email protected]>
Fixes 2b5882435606 ("perf arm64: Generate system call table from asm/unistd.h")
Quoted 4 lines

---
Hi, sorry for late response - was on vacation. I was able to reproduce and fix by adding this -I to the $hostcc line. Please test, and let me know if this is an acceptable fix.

Looks better than what I did, that indeed was a stopgap solution till something better came along.

There are newer toolchains in my container collection to cross build arm64/arm:

  17 debian:experimental-x-arm64   : Ok   aarch64-linux-gnu-gcc (Debian 7.3.0-15) 7.3.0
  46 ubuntu:16.04-x-arm            : Ok   arm-linux-gnueabihf-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
  47 ubuntu:16.04-x-arm64          : Ok   aarch64-linux-gnu-gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609

I think its time to add ubuntu:18.04-x- variants, to get a more recent toolchain on ubuntu, will do.

Anyway, I'll repeat the tests after applying your patch,

- Arnaldo

Quoted 60 lines
 tools/perf/arch/arm64/Makefile                    | 5 +++--
 tools/perf/arch/arm64/entry/syscalls/mksyscalltbl | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)
tools/perf/arch/arm64/Makefile +3 -2
index f013b115dc86..dbef716a1913 100644
@@ -11,7 +11,8 @@ PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
 
 out    := $(OUTPUT)arch/arm64/include/generated/asm
 header := $(out)/syscalls.c
-sysdef := $(srctree)/tools/include/uapi/asm-generic/unistd.h
+incpath := $(srctree)/tools
+sysdef := $(srctree)/tools/arch/arm64/include/uapi/asm/unistd.h
 sysprf := $(srctree)/tools/perf/arch/arm64/entry/syscalls/
 systbl := $(sysprf)/mksyscalltbl
 
@@ -19,7 +20,7 @@ systbl := $(sysprf)/mksyscalltbl
 _dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
 
 $(header): $(sysdef) $(systbl)
-	$(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(sysdef) > $@
+	$(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(incpath) $(sysdef) > $@
 
 clean::
 	$(call QUIET_CLEAN, arm64) $(RM) $(header)
tools/perf/arch/arm64/entry/syscalls/mksyscalltbl +3 -3
index 52e197317d3e..2dbb8cade048 100755
@@ -11,7 +11,8 @@
 
 gcc=$1
 hostcc=$2
-input=$3
+incpath=$3
+input=$4
 
 if ! test -r $input; then
 	echo "Could not read input file" >&2
@@ -28,7 +29,6 @@ create_table_from_c()
 
 	cat <<-_EoHEADER
 		#include <stdio.h>
-		#define __ARCH_WANT_RENAMEAT
 		#include "$input"
 		int main(int argc, char *argv[])
 		{
@@ -42,7 +42,7 @@ create_table_from_c()
 	printf "%s\n" "	printf(\"#define SYSCALLTBL_ARM64_MAX_ID %d\\n\", __NR_$last_sc);"
 	printf "}\n"
 
-	} | $hostcc -o $create_table_exe -x c -
+	} | $hostcc -I $incpath/include/uapi -o $create_table_exe -x c -
 
 	$create_table_exe
 
Signature · 1 line
2.17.1
#7 lore raw

[tip:perf/core] perf arm64: Fix include path for asm-generic/unistd.h

In reply to Kim Phillips
perf arm64: Fix include path for asm-generic/unistd.h
Commit-ID:  5ab1de932e2923f490645ad017a689c5b58dc433
Gitweb:     https://git.kernel.org/tip/5ab1de932e2923f490645ad017a689c5b58dc433
Author:     Kim Phillips <[email protected]>
AuthorDate: Mon, 6 Aug 2018 17:28:00 -0500
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 30 Aug 2018 14:49:24 -0300

perf arm64: Fix include path for asm-generic/unistd.h

The new syscall table support for arm64 mistakenly used the system's asm-generic/unistd.h file when processing the tools/arch/arm64/include/uapi/asm/unistd.h file's include directive:

	#include <asm-generic/unistd.h>

See "Committer notes" section of commit 2b5882435606 "perf arm64:
Generate system call table from asm/unistd.h" for more details.

This patch removes the committer's temporary workaround, and instructs the host compiler to search the build tree's include path for the right copy of the unistd.h file, instead of the one on the system's /usr/include path.

It thus fixes the committer's test that cross-builds an arm64 perf on an x86 platform running Ubuntu 14.04.5 LTS with an old toolchain:

$ tools/perf/arch/arm64/entry/syscalls/mksyscalltbl /gcc-linaro-5.4.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc gcc `pwd`/tools tools/arch/arm64/include/uapi/asm/unistd.h | grep bpf
	[280] = "bpf",
Cc Alexander Shishkin <[email protected]>
Cc Hendrik Brueckner <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Ravi Bangoria <[email protected]>
Cc Thomas Richter <[email protected]>
Fixes 2b5882435606 ("perf arm64: Generate system call table from asm/unistd.h")
---
 tools/perf/arch/arm64/Makefile                    | 5 +++--
 tools/perf/arch/arm64/entry/syscalls/mksyscalltbl | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)
tools/perf/arch/arm64/Makefile +3 -2
index f013b115dc86..dbef716a1913 100644
@@ -11,7 +11,8 @@ PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
 
 out    := $(OUTPUT)arch/arm64/include/generated/asm
 header := $(out)/syscalls.c
-sysdef := $(srctree)/tools/include/uapi/asm-generic/unistd.h
+incpath := $(srctree)/tools
+sysdef := $(srctree)/tools/arch/arm64/include/uapi/asm/unistd.h
 sysprf := $(srctree)/tools/perf/arch/arm64/entry/syscalls/
 systbl := $(sysprf)/mksyscalltbl
 
@@ -19,7 +20,7 @@ systbl := $(sysprf)/mksyscalltbl
 _dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
 
 $(header): $(sysdef) $(systbl)
-	$(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(sysdef) > $@
+	$(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(incpath) $(sysdef) > $@
 
 clean::
 	$(call QUIET_CLEAN, arm64) $(RM) $(header)
tools/perf/arch/arm64/entry/syscalls/mksyscalltbl +3 -3
index 52e197317d3e..2dbb8cade048 100755
@@ -11,7 +11,8 @@
 
 gcc=$1
 hostcc=$2
-input=$3
+incpath=$3
+input=$4
 
 if ! test -r $input; then
 	echo "Could not read input file" >&2
@@ -28,7 +29,6 @@ create_table_from_c()
 
 	cat <<-_EoHEADER
 		#include <stdio.h>
-		#define __ARCH_WANT_RENAMEAT
 		#include "$input"
 		int main(int argc, char *argv[])
 		{
@@ -42,7 +42,7 @@ create_table_from_c()
 	printf "%s\n" "	printf(\"#define SYSCALLTBL_ARM64_MAX_ID %d\\n\", __NR_$last_sc);"
 	printf "}\n"
 
-	} | $hostcc -o $create_table_exe -x c -
+	} | $hostcc -I $incpath/include/uapi -o $create_table_exe -x c -
 
 	$create_table_exe
 
#8 lore raw
In reply to Kim Phillips
perf arm64: Generate system call table from asm/unistd.h
Commit-ID:  2b5882435606c209ebc052230f03505ea477a252
Gitweb:     https://git.kernel.org/tip/2b5882435606c209ebc052230f03505ea477a252
Author:     Kim Phillips <[email protected]>
AuthorDate: Fri, 6 Jul 2018 16:34:43 -0500
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 24 Jul 2018 14:52:48 -0300

perf arm64: Generate system call table from asm/unistd.h

This should speed up accessing new system calls introduced with the kernel rather than waiting for libaudit updates to include them.

Using the existing other arch scripts resulted in this error:

tools/perf/arch/arm64/entry/syscalls//mksyscalltbl: 25: printf: __NR3264_ftruncate: expected numeric value

because, unlike other arches, asm-generic's unistd.h does things like:

  #define __NR_ftruncate __NR3264_ftruncate

Turning the scripts printf's %d into a %s resulted in this in the generated syscalls.c file:

    static const char *syscalltbl_arm64[] = {
            [__NR3264_ftruncate] = "ftruncate",

So we use the host C compiler to fold the macros, and print them out from within a temporary C program, in order to get the correct output:

    static const char *syscalltbl_arm64[] = {
            [46] = "ftruncate",

Committer notes:

Testing this with a container with an old toolchain breaks because it ends up using the system's /usr/include/asm-generic/unistd.h, included from tools/arch/arm64/include/uapi/asm/unistd.h when what is desired is for it to include tools/include/uapi/asm-generic/unistd.h.

Since all that tools/arch/arm64/include/uapi/asm/unistd.h is to set a define and then include asm-generic/unistd.h, do that directly and use tools/include/uapi/asm-generic/unistd.h as the file to get the syscall definitions to expand.

Testing it:

tools/perf/arch/arm64/entry/syscalls/mksyscalltbl /gcc-linaro-5.4.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc gcc tools/include/uapi/asm-generic/unistd.h

Now works and generates in the syscall string table.

Before it ended up as:

  $ tools/perf/arch/arm64/entry/syscalls/mksyscalltbl /gcc-linaro-5.4.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc gcc tools/arch/arm64/include/uapi/asm/unistd.h
  static const char *syscalltbl_arm64[] = {
  <stdin>: In function 'main':
  <stdin>:257:38: error: '__NR_getrandom' undeclared (first use in this function)
  <stdin>:257:38: note: each undeclared identifier is reported only once for each function it appears in
  <stdin>:258:41: error: '__NR_memfd_create' undeclared (first use in this function)
  <stdin>:259:32: error: '__NR_bpf' undeclared (first use in this function)
  <stdin>:260:37: error: '__NR_execveat' undeclared (first use in this function)
  tools/perf/arch/arm64/entry/syscalls/mksyscalltbl: 47: tools/perf/arch/arm64/entry/syscalls/mksyscalltbl: /tmp/create-table-60liya: Permission denied
  };
  $
---
 tools/perf/arch/arm64/Makefile                    | 21 ++++++++
 tools/perf/arch/arm64/entry/syscalls/mksyscalltbl | 62 +++++++++++++++++++++++
 2 files changed, 83 insertions(+)
tools/perf/arch/arm64/Makefile +21 -0
index 91de4860faad..f013b115dc86 100644
@@ -4,3 +4,24 @@ PERF_HAVE_DWARF_REGS := 1
 endif
 PERF_HAVE_JITDUMP := 1
 PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
+
+#
+# Syscall table generation for perf
+#
+
+out    := $(OUTPUT)arch/arm64/include/generated/asm
+header := $(out)/syscalls.c
+sysdef := $(srctree)/tools/include/uapi/asm-generic/unistd.h
+sysprf := $(srctree)/tools/perf/arch/arm64/entry/syscalls/
+systbl := $(sysprf)/mksyscalltbl
+
+# Create output directory if not already present
+_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
+
+$(header): $(sysdef) $(systbl)
+	$(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(sysdef) > $@
+
+clean::
+	$(call QUIET_CLEAN, arm64) $(RM) $(header)
+
+archheaders: $(header)
tools/perf/arch/arm64/entry/syscalls/mksyscalltbl new file +62 -0

62 lines not on this page · raw message