Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools x86: Use generic syscall scripts

Use the generic scripts to generate headers from the syscall table for
both 32- and 64-bit x86.

Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Guo Ren <guoren@kernel.org>
Cc: Günther Noack <gnoack@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mickaël Salaün <mic@digikod.net>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20250108-perf_syscalltbl-v6-8-7543b5293098@rivosinc.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Charlie Jenkins and committed by
Arnaldo Carvalho de Melo
a874d1f6 24f122dc

+20 -80
+1 -2
tools/perf/Makefile.config
··· 31 31 ifneq ($(NO_SYSCALL_TABLE),1) 32 32 NO_SYSCALL_TABLE := 1 33 33 34 - ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 powerpc arm64 s390 mips loongarch riscv)) 34 + ifeq ($(SRCARCH),$(filter $(SRCARCH),powerpc arm64 s390 mips loongarch)) 35 35 NO_SYSCALL_TABLE := 0 36 36 endif 37 37 ··· 58 58 # Additional ARCH settings for x86 59 59 ifeq ($(SRCARCH),x86) 60 60 $(call detected,CONFIG_X86) 61 - CFLAGS += -I$(OUTPUT)arch/x86/include/generated 62 61 ifeq (${IS_64_BIT}, 1) 63 62 CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT 64 63 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S
+1 -1
tools/perf/Makefile.perf
··· 311 311 endif 312 312 endif 313 313 # architectures that use the generic syscall table 314 - generic_syscall_table_archs := riscv arc csky arm sh sparc xtensa 314 + generic_syscall_table_archs := riscv arc csky arm sh sparc xtensa x86 315 315 ifneq ($(filter $(SRCARCH), $(generic_syscall_table_archs)),) 316 316 include $(srctree)/tools/perf/scripts/Makefile.syscalls 317 317 endif
-1
tools/perf/arch/x86/Build
··· 2 2 perf-test-y += tests/ 3 3 4 4 ifdef SHELLCHECK 5 - SHELL_TESTS := entry/syscalls/syscalltbl.sh 6 5 TEST_LOGS := $(SHELL_TESTS:%=%.shellcheck_log) 7 6 else 8 7 SHELL_TESTS :=
-25
tools/perf/arch/x86/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 HAVE_KVM_STAT_SUPPORT := 1 3 3 PERF_HAVE_JITDUMP := 1 4 - 5 - ### 6 - # Syscall table generation 7 - # 8 - 9 - generated := $(OUTPUT)arch/x86/include/generated 10 - out := $(generated)/asm 11 - header := $(out)/syscalls_64.c 12 - header_32 := $(out)/syscalls_32.c 13 - sys := $(srctree)/tools/perf/arch/x86/entry/syscalls 14 - systbl := $(sys)/syscalltbl.sh 15 - 16 - # Create output directory if not already present 17 - $(shell [ -d '$(out)' ] || mkdir -p '$(out)') 18 - 19 - $(header): $(sys)/syscall_64.tbl $(systbl) 20 - $(Q)$(SHELL) '$(systbl)' $(sys)/syscall_64.tbl 'x86_64' > $@ 21 - 22 - $(header_32): $(sys)/syscall_32.tbl $(systbl) 23 - $(Q)$(SHELL) '$(systbl)' $(sys)/syscall_32.tbl 'x86' > $@ 24 - 25 - clean:: 26 - $(call QUIET_CLEAN, x86) $(RM) -r $(header) $(generated) 27 - 28 - archheaders: $(header) $(header_32)
+3
tools/perf/arch/x86/entry/syscalls/Kbuild
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + syscall-y += syscalls_32.h 3 + syscall-y += syscalls_64.h
+6
tools/perf/arch/x86/entry/syscalls/Makefile.syscalls
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + 3 + syscall_abis_32 += i386 4 + syscall_abis_64 += 5 + 6 + syscalltbl = $(srctree)/tools/perf/arch/x86/entry/syscalls/syscall_%.tbl
-42
tools/perf/arch/x86/entry/syscalls/syscalltbl.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0 3 - 4 - in="$1" 5 - arch="$2" 6 - 7 - syscall_macro() { 8 - nr="$1" 9 - name="$2" 10 - 11 - echo " [$nr] = \"$name\"," 12 - } 13 - 14 - emit() { 15 - nr="$1" 16 - entry="$2" 17 - 18 - syscall_macro "$nr" "$entry" 19 - } 20 - 21 - echo "static const char *const syscalltbl_${arch}[] = {" 22 - 23 - sorted_table=$(mktemp /tmp/syscalltbl.XXXXXX) 24 - grep '^[0-9]' "$in" | sort -n > $sorted_table 25 - 26 - max_nr=0 27 - # the params are: nr abi name entry compat 28 - # use _ for intentionally unused variables according to SC2034 29 - while read nr _ name _ _; do 30 - if [ $nr -ge 512 ] ; then # discard compat sycalls 31 - break 32 - fi 33 - 34 - emit "$nr" "$name" 35 - max_nr=$nr 36 - done < $sorted_table 37 - 38 - rm -f $sorted_table 39 - 40 - echo "};" 41 - 42 - echo "#define SYSCALLTBL_${arch}_MAX_ID ${max_nr}"
+8
tools/perf/arch/x86/include/syscall_table.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #include <asm/bitsperlong.h> 3 + 4 + #if __BITS_PER_LONG == 64 5 + #include <asm/syscalls_64.h> 6 + #else 7 + #include <asm/syscalls_32.h> 8 + #endif
+1 -9
tools/perf/util/syscalltbl.c
··· 14 14 #include <string.h> 15 15 #include "string2.h" 16 16 17 - #if defined(__x86_64__) 18 - #include <asm/syscalls_64.c> 19 - const int syscalltbl_native_max_id = SYSCALLTBL_x86_64_MAX_ID; 20 - static const char *const *syscalltbl_native = syscalltbl_x86_64; 21 - #elif defined(__i386__) 22 - #include <asm/syscalls_32.c> 23 - const int syscalltbl_native_max_id = SYSCALLTBL_x86_MAX_ID; 24 - static const char *const *syscalltbl_native = syscalltbl_x86; 25 - #elif defined(__s390x__) 17 + #if defined(__s390x__) 26 18 #include <asm/syscalls_64.c> 27 19 const int syscalltbl_native_max_id = SYSCALLTBL_S390_64_MAX_ID; 28 20 static const char *const *syscalltbl_native = syscalltbl_s390_64;