• Kim Phillips's avatar
    perf arm64: Generate system call table from asm/unistd.h · 2b588243
    Kim Phillips authored
    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
      };
      $
    Signed-off-by: default avatarKim Phillips <kim.phillips@arm.com>
    Reviewed-by: default avatarHendrik Brueckner <brueckner@linux.ibm.com>
    Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
    Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
    Link: http://lkml.kernel.org/r/20180706163443.22626f5e9e10e5bab5e5c662@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    2b588243
mksyscalltbl 1.16 KB