perf tools: Create generic syscall table support

Currently each architecture in perf independently generates syscall
headers.

Adapt the work that has gone into unifying syscall header
implementations in the kernel to work with perf tools.

Introduce this framework with riscv at first. riscv previously relied on
libaudit, but with this change, perf tools for riscv no longer needs
this external dependency.

Signed-off-by: Charlie Jenkins <charlie@rivosinc.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-1-7543b5293098@rivosinc.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Charlie Jenkins
2025-01-08 18:36:16 -08:00
committed by Arnaldo Carvalho de Melo
parent 6bfb4c571b
commit 4a73aff8c5
13 changed files with 588 additions and 77 deletions

View File

@@ -0,0 +1,61 @@
# SPDX-License-Identifier: GPL-2.0
# This Makefile generates headers in
# tools/perf/arch/$(SRCARCH)/include/generated/asm from the architecture's
# syscall table. This will either be from the generic syscall table, or from a
# table that is specific to that architecture.
PHONY := all
all:
obj := $(OUTPUT)arch/$(SRCARCH)/include/generated/asm
syscall_abis_32 := common,32
syscall_abis_64 := common,64
syscalltbl := $(srctree)/tools/scripts/syscall.tbl
# let architectures override $(syscall_abis_%) and $(syscalltbl)
-include $(srctree)/tools/perf/arch/$(SRCARCH)/entry/syscalls/Makefile.syscalls
include $(srctree)/tools/build/Build.include
-include $(srctree)/tools/perf/arch/$(SRCARCH)/entry/syscalls/Kbuild
systbl := $(srctree)/tools/perf/scripts/syscalltbl.sh
syscall-y := $(addprefix $(obj)/, $(syscall-y))
# Remove stale wrappers when the corresponding files are removed from generic-y
old-headers := $(wildcard $(obj)/*.h)
unwanted := $(filter-out $(syscall-y),$(old-headers))
quiet_cmd_remove = REMOVE $(unwanted)
cmd_remove = rm -f $(unwanted)
quiet_cmd_systbl = SYSTBL $@
cmd_systbl = $(CONFIG_SHELL) $(systbl) \
$(if $(systbl-args-$*),$(systbl-args-$*),$(systbl-args)) \
--abis $(subst $(space),$(comma),$(strip $(syscall_abis_$*))) \
$< $@
all: $(syscall-y)
$(if $(unwanted),$(call cmd,remove))
@:
$(obj)/syscalls_%.h: $(syscalltbl) $(systbl) FORCE
$(call if_changed,systbl)
targets := $(syscall-y)
# Create output directory. Skip it if at least one old header exists
# since we know the output directory already exists.
ifeq ($(old-headers),)
$(shell mkdir -p $(obj))
endif
PHONY += FORCE
FORCE:
existing-targets := $(wildcard $(sort $(targets)))
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
.PHONY: $(PHONY)