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

perf build: Remove Makefile.syscalls

Now a single beauty file is generated and used by all architectures,
remove the per-architecture Makefiles, Kbuild files and previous
generator script.

Note: there was conversation with Charlie Jenkins
<charlie@rivosinc.com> and they'd written an alternate approach to
support multiple architectures:
https://lore.kernel.org/all/20250114-perf_syscall_arch_runtime-v1-1-5b304e408e11@rivosinc.com/
It would have been better to have helped Charlie fix their series (my
apologies) but they agreed that the approach taken here was likely
best for longer term maintainability:
https://lore.kernel.org/lkml/Z6Jk_UN9i69QGqUj@ghost/

Signed-off-by: Ian Rogers <irogers@google.com>
Reviewed-by: Howard Chu <howardchu95@gmail.com>
Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Link: https://lore.kernel.org/r/20250319050741.269828-11-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
16ab5c70 1470eaa5

-242
-1
tools/perf/Makefile.perf
··· 339 339 FEATURE_TESTS := all 340 340 endif 341 341 endif 342 - include $(srctree)/tools/perf/scripts/Makefile.syscalls 343 342 include Makefile.config 344 343 endif 345 344
-2
tools/perf/arch/alpha/entry/syscalls/Kbuild
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - syscall-y += syscalls_64.h
-5
tools/perf/arch/alpha/entry/syscalls/Makefile.syscalls
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - syscall_abis_64 += 4 - 5 - syscalltbl = $(srctree)/tools/perf/arch/alpha/entry/syscalls/syscall.tbl
-2
tools/perf/arch/arc/entry/syscalls/Kbuild
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - syscall-y += syscalls_32.h
-3
tools/perf/arch/arc/entry/syscalls/Makefile.syscalls
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - syscall_abis_32 += arc time32 renameat stat64 rlimit
-4
tools/perf/arch/arm/entry/syscalls/Kbuild
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - syscall_abis_32 += oabi 4 - syscalltbl = $(srctree)/tools/perf/arch/arm/entry/syscalls/syscall.tbl
-2
tools/perf/arch/arm/entry/syscalls/Makefile.syscalls
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - syscall-y += syscalls_32.h
-3
tools/perf/arch/arm64/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/arm64/entry/syscalls/Makefile.syscalls
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - syscall_abis_32 += 4 - syscall_abis_64 += renameat rlimit memfd_secret 5 - 6 - syscalltbl = $(srctree)/tools/perf/arch/arm64/entry/syscalls/syscall_%.tbl
-2
tools/perf/arch/csky/entry/syscalls/Kbuild
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - syscall-y += syscalls_32.h
-3
tools/perf/arch/csky/entry/syscalls/Makefile.syscalls
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - syscall_abis_32 += csky time32 stat64 rlimit
-2
tools/perf/arch/loongarch/entry/syscalls/Kbuild
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - syscall-y += syscalls_64.h
-3
tools/perf/arch/loongarch/entry/syscalls/Makefile.syscalls
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - syscall_abis_64 +=
-2
tools/perf/arch/mips/entry/syscalls/Kbuild
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - syscall-y += syscalls_64.h
-5
tools/perf/arch/mips/entry/syscalls/Makefile.syscalls
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - syscall_abis_64 += n64 4 - 5 - syscalltbl = $(srctree)/tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
-3
tools/perf/arch/parisc/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/parisc/entry/syscalls/Makefile.syscalls
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - syscall_abis_32 += 4 - syscall_abis_64 += 5 - 6 - syscalltbl = $(srctree)/tools/perf/arch/parisc/entry/syscalls/syscall.tbl
-3
tools/perf/arch/powerpc/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/powerpc/entry/syscalls/Makefile.syscalls
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - syscall_abis_32 += nospu 4 - syscall_abis_64 += nospu 5 - 6 - syscalltbl = $(srctree)/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
-2
tools/perf/arch/riscv/entry/syscalls/Kbuild
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - syscall-y += syscalls_64.h
-4
tools/perf/arch/riscv/entry/syscalls/Makefile.syscalls
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - syscall_abis_32 += riscv memfd_secret 4 - syscall_abis_64 += riscv rlimit memfd_secret
-2
tools/perf/arch/s390/entry/syscalls/Kbuild
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - syscall-y += syscalls_64.h
-5
tools/perf/arch/s390/entry/syscalls/Makefile.syscalls
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - syscall_abis_64 += renameat rlimit memfd_secret 4 - 5 - syscalltbl = $(srctree)/tools/perf/arch/s390/entry/syscalls/syscall.tbl
-2
tools/perf/arch/sh/entry/syscalls/Kbuild
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - syscall-y += syscalls_32.h
-4
tools/perf/arch/sh/entry/syscalls/Makefile.syscalls
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - syscall_abis_32 += 4 - syscalltbl = $(srctree)/tools/perf/arch/sh/entry/syscalls/syscall.tbl
-3
tools/perf/arch/sparc/entry/syscalls/Kbuild
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - syscall-y += syscalls_32.h 3 - syscall-y += syscalls_64.h
-5
tools/perf/arch/sparc/entry/syscalls/Makefile.syscalls
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - syscall_abis_32 += 4 - syscall_abis_64 += 5 - syscalltbl = $(srctree)/tools/perf/arch/sparc/entry/syscalls/syscall.tbl
-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
-2
tools/perf/arch/xtensa/entry/syscalls/Kbuild
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - syscall-y += syscalls_32.h
-4
tools/perf/arch/xtensa/entry/syscalls/Makefile.syscalls
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - 3 - syscall_abis_32 += 4 - syscalltbl = $(srctree)/tools/perf/arch/xtensa/entry/syscalls/syscall.tbl
-61
tools/perf/scripts/Makefile.syscalls
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - # This Makefile generates headers in 3 - # tools/perf/arch/$(SRCARCH)/include/generated/asm from the architecture's 4 - # syscall table. This will either be from the generic syscall table, or from a 5 - # table that is specific to that architecture. 6 - 7 - PHONY := all 8 - all: 9 - 10 - obj := $(OUTPUT)arch/$(SRCARCH)/include/generated/asm 11 - 12 - syscall_abis_32 := common,32 13 - syscall_abis_64 := common,64 14 - syscalltbl := $(srctree)/tools/scripts/syscall.tbl 15 - 16 - # let architectures override $(syscall_abis_%) and $(syscalltbl) 17 - -include $(srctree)/tools/perf/arch/$(SRCARCH)/entry/syscalls/Makefile.syscalls 18 - include $(srctree)/tools/build/Build.include 19 - -include $(srctree)/tools/perf/arch/$(SRCARCH)/entry/syscalls/Kbuild 20 - 21 - systbl := $(srctree)/tools/perf/scripts/syscalltbl.sh 22 - 23 - syscall-y := $(addprefix $(obj)/, $(syscall-y)) 24 - 25 - # Remove stale wrappers when the corresponding files are removed from generic-y 26 - old-headers := $(wildcard $(obj)/*.h) 27 - unwanted := $(filter-out $(syscall-y),$(old-headers)) 28 - 29 - quiet_cmd_remove = REMOVE $(unwanted) 30 - cmd_remove = rm -f $(unwanted) 31 - 32 - quiet_cmd_systbl = SYSTBL $@ 33 - cmd_systbl = $(CONFIG_SHELL) $(systbl) \ 34 - $(if $(systbl-args-$*),$(systbl-args-$*),$(systbl-args)) \ 35 - --abis $(subst $(space),$(comma),$(strip $(syscall_abis_$*))) \ 36 - $< $@ 37 - 38 - all: $(syscall-y) 39 - $(if $(unwanted),$(call cmd,remove)) 40 - @: 41 - 42 - $(obj)/syscalls_%.h: $(syscalltbl) $(systbl) FORCE 43 - $(call if_changed,systbl) 44 - 45 - targets := $(syscall-y) 46 - 47 - # Create output directory. Skip it if at least one old header exists 48 - # since we know the output directory already exists. 49 - ifeq ($(old-headers),) 50 - $(shell mkdir -p $(obj)) 51 - endif 52 - 53 - PHONY += FORCE 54 - 55 - FORCE: 56 - 57 - existing-targets := $(wildcard $(sort $(targets))) 58 - 59 - -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) 60 - 61 - .PHONY: $(PHONY)
-76
tools/perf/scripts/syscalltbl.sh
··· 1 - #!/bin/sh 2 - # SPDX-License-Identifier: GPL-2.0 3 - # 4 - # Generate a syscall table header. 5 - # 6 - # Each line of the syscall table should have the following format: 7 - # 8 - # NR ABI NAME [NATIVE] [COMPAT] 9 - # 10 - # NR syscall number 11 - # ABI ABI name 12 - # NAME syscall name 13 - # NATIVE native entry point (optional) 14 - # COMPAT compat entry point (optional) 15 - 16 - set -e 17 - 18 - usage() { 19 - echo >&2 "usage: $0 [--abis ABIS] INFILE OUTFILE" >&2 20 - echo >&2 21 - echo >&2 " INFILE input syscall table" 22 - echo >&2 " OUTFILE output header file" 23 - echo >&2 24 - echo >&2 "options:" 25 - echo >&2 " --abis ABIS ABI(s) to handle (By default, all lines are handled)" 26 - exit 1 27 - } 28 - 29 - # default unless specified by options 30 - abis= 31 - 32 - while [ $# -gt 0 ] 33 - do 34 - case $1 in 35 - --abis) 36 - abis=$(echo "($2)" | tr ',' '|') 37 - shift 2;; 38 - -*) 39 - echo "$1: unknown option" >&2 40 - usage;; 41 - *) 42 - break;; 43 - esac 44 - done 45 - 46 - if [ $# -ne 2 ]; then 47 - usage 48 - fi 49 - 50 - infile="$1" 51 - outfile="$2" 52 - 53 - sorted_table=$(mktemp /tmp/syscalltbl.XXXXXX) 54 - grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | sort -n > $sorted_table 55 - 56 - echo "static const char *const syscall_num_to_name[] = {" > $outfile 57 - # the params are: nr abi name entry compat 58 - # use _ for intentionally unused variables according to SC2034 59 - while read nr _ name _ _; do 60 - echo " [$nr] = \"$name\"," >> $outfile 61 - done < $sorted_table 62 - echo "};" >> $outfile 63 - 64 - echo "static const uint16_t syscall_sorted_names[] = {" >> $outfile 65 - 66 - # When sorting by name, add a suffix of 0s upto 20 characters so that system 67 - # calls that differ with a numerical suffix don't sort before those 68 - # without. This default behavior of sort differs from that of strcmp used at 69 - # runtime. Use sed to strip the trailing 0s suffix afterwards. 70 - grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | awk '{printf $3; for (i = length($3); i < 20; i++) { printf "0"; }; print " " $1}'| sort | sed 's/\([a-zA-Z1-9]\+\)0\+ \([0-9]\+\)/\1 \2/' > $sorted_table 71 - while read name nr; do 72 - echo " $nr, /* $name */" >> $outfile 73 - done < $sorted_table 74 - echo "};" >> $outfile 75 - 76 - rm -f $sorted_table