Re: [PATCH] perf arm64: Fix mksyscalltbl when system kernel headers are ahead of the kernel

Arnaldo Carvalho de Melo
2019-05-21T18:04:00Z

Em Tue, May 21, 2019 at 12:19:18PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Tue, May 21, 2019 at 04:34:47PM +0200, Michael Petlan escreveu:
> > On Tue, 21 May 2019, Arnaldo Carvalho de Melo wrote:
> > > Em Tue, May 21, 2019 at 06:02:03AM +0300, Vitaly Chikunov escreveu:
> > > > When a host system has kernel headers that are newer than a compiling
> > > > kernel, mksyscalltbl fails with errors such as:

> > > > <stdin>: In function 'main':
> > > > <stdin>:271:44: error: '__NR_kexec_file_load' undeclared (first use in this function)
> > > > <stdin>:271:44: note: each undeclared identifier is reported only once for each function it appears in
> > > > <stdin>:272:46: error: '__NR_pidfd_send_signal' undeclared (first use in this function)
> > > > <stdin>:273:43: error: '__NR_io_uring_setup' undeclared (first use in this function)
> > > > <stdin>:274:43: error: '__NR_io_uring_enter' undeclared (first use in this function)
> > > > <stdin>:275:46: error: '__NR_io_uring_register' undeclared (first use in this function)
> > > > tools/perf/arch/arm64/entry/syscalls//mksyscalltbl: line 48: /tmp/create-table-xvUQdD: Permission denied

> > > > mksyscalltbl is compiled with default host includes, but run with

> > > It shouldn't :-\ So with this you're making it use the ones shipped in
> > > tools/include? Good, I'll test it, thanks!

> > I've hit the issue too, this patch fixes it for me.
> > Tested.

> Thanks, I'll add your Tested-by, appreciated.

Was this in a cross-build environment? Native? I'm asking because I test
this on several cross build environments, like on ubuntu 19.04 cross
building to aarch64:

perfbuilder@15e0b7c211c2:/git/perf$ grep PRETTY_NAME /etc/os-release
PRETTY_NAME="Ubuntu 19.04"
perfbuilder@15e0b7c211c2:/git/perf$ aarch64-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=aarch64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/aarch64-linux-gnu/8/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 8.3.0-6ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --disable-libphobos --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=aarch64-linux-gnu --program-prefix=aarch64-linux-gnu- --includedir=/usr/aarch64-linux-gnu/include
Thread model: posix
gcc version 8.3.0 (Ubuntu/Linaro 8.3.0-6ubuntu1)
perfbuilder@15e0b7c211c2:/git/perf$

I'm building it as:

$ make CORESIGHT=1 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- EXTRA_CFLAGS= -C /git/perf/tools/perf O=/tmp/build/perf

The end result is:

$ file /tmp/build/perf/perf
/tmp/build/perf/perf: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, BuildID[sha1]=5b4fd9f0f92cc331e43e6e4da9791c473524383d, for GNU/Linux 3.7.0, with debug_info, not stripped

I.e. it didn't fail the build, but in the end these new syscalls are not
there, while with your patch, they are:

perfbuilder@6e20056ed532:/git/perf$ tail /tmp/build/perf/arch/arm64/include/generated/asm/syscalls.c
[292] = "io_pgetevents",
[293] = "rseq",
[294] = "kexec_file_load",
[424] = "pidfd_send_signal",
[425] = "io_uring_setup",
[426] = "io_uring_enter",
[427] = "io_uring_register",
[428] = "syscalls",
#define SYSCALLTBL_ARM64_MAX_ID 428
};
perfbuilder@6e20056ed532:/git/perf$

perfbuilder@6e20056ed532:/git/perf$ strings /tmp/build/perf/perf | egrep '^(io_uring_|pidfd_|kexec_file)'
kexec_file_load
pidfd_send_signal
io_uring_setup
io_uring_enter
io_uring_register
perfbuilder@6e20056ed532:/git/perf$

Thanks, applied.

- Arnaldo