Skip to content

Commit 1b700c9

Browse files
committed
perf tools: Build syscall table .c header from kernel's syscall_64.tbl
We used libaudit to map ids to syscall names and vice-versa, but that imposes a delay in supporting new syscalls, having to wait for libaudit to get those new syscalls on its tables. To remove that delay, for x86_64 initially, grab a copy of arch/x86/entry/syscalls/syscall_64.tbl and use it to generate those tables. Syscalls currently not available in audit-libs: # trace -e copy_file_range,membarrier,mlock2,pread64,pwrite64,timerfd_create,userfaultfd Error: Invalid syscall copy_file_range, membarrier, mlock2, pread64, pwrite64, timerfd_create, userfaultfd Hint: try 'perf list syscalls:sys_enter_*' Hint: and: 'man syscalls' # With this patch: # trace -e copy_file_range,membarrier,mlock2,pread64,pwrite64,timerfd_create,userfaultfd 8505.733 ( 0.010 ms): gnome-shell/2519 timerfd_create(flags: 524288) = 36 8506.688 ( 0.005 ms): gnome-shell/2519 timerfd_create(flags: 524288) = 40 30023.097 ( 0.025 ms): qemu-system-x8/24629 pwrite64(fd: 18, buf: 0x7f63ae382000, count: 4096, pos: 529592320) = 4096 31268.712 ( 0.028 ms): qemu-system-x8/24629 pwrite64(fd: 18, buf: 0x7f63afd8b000, count: 4096, pos: 2314133504) = 4096 31268.854 ( 0.016 ms): qemu-system-x8/24629 pwrite64(fd: 18, buf: 0x7f63afda2000, count: 4096, pos: 2314137600) = 4096 Cc: Adrian Hunter <[email protected]> Cc: David Ahern <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/n/[email protected] [ Added make dep for 'prepare' in 'LIBPERF_IN', fix by Wang Nan to fix parallell build ] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 5af56fa commit 1b700c9

File tree

7 files changed

+456
-5
lines changed

7 files changed

+456
-5
lines changed

tools/perf/Makefile.perf

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ endif
183183
include config/Makefile
184184
endif
185185

186+
ifeq ($(config),0)
187+
include $(srctree)/tools/scripts/Makefile.arch
188+
-include arch/$(ARCH)/Makefile
189+
endif
190+
186191
# The FEATURE_DUMP_EXPORT holds location of the actual
187192
# FEATURE_DUMP file to be used to bypass feature detection
188193
# (for bpf or any other subproject)
@@ -388,7 +393,7 @@ endif
388393
__build-dir = $(subst $(OUTPUT),,$(dir $@))
389394
build-dir = $(if $(__build-dir),$(__build-dir),.)
390395

391-
prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h fixdep
396+
prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h fixdep archheaders
392397

393398
$(OUTPUT)%.o: %.c prepare FORCE
394399
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
@@ -428,7 +433,7 @@ $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
428433

429434
LIBPERF_IN := $(OUTPUT)libperf-in.o
430435

431-
$(LIBPERF_IN): fixdep FORCE
436+
$(LIBPERF_IN): prepare fixdep FORCE
432437
$(Q)$(MAKE) $(build)=libperf
433438

434439
$(LIB_FILE): $(LIBPERF_IN)
@@ -623,7 +628,7 @@ config-clean:
623628
$(call QUIET_CLEAN, config)
624629
$(Q)$(MAKE) -C $(srctree)/tools/build/feature/ $(if $(OUTPUT),OUTPUT=$(OUTPUT)feature/,) clean >/dev/null
625630

626-
clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean config-clean
631+
clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean config-clean
627632
$(call QUIET_CLEAN, core-objs) $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
628633
$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
629634
$(Q)$(RM) $(OUTPUT).config-detected
@@ -660,5 +665,5 @@ FORCE:
660665
.PHONY: all install clean config-clean strip install-gtk
661666
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
662667
.PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare
663-
.PHONY: libtraceevent_plugins
668+
.PHONY: libtraceevent_plugins archheaders
664669

tools/perf/arch/x86/Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,26 @@ endif
44
HAVE_KVM_STAT_SUPPORT := 1
55
PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
66
PERF_HAVE_JITDUMP := 1
7+
8+
###
9+
# Syscall table generation
10+
#
11+
12+
out := $(OUTPUT)arch/x86/include/generated/asm
13+
header := $(out)/syscalls_64.c
14+
sys := $(srctree)/tools/perf/arch/x86/entry/syscalls
15+
systbl := $(sys)/syscalltbl.sh
16+
17+
# Create output directory if not already present
18+
_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
19+
20+
$(header): $(sys)/syscall_64.tbl $(systbl)
21+
@(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
22+
(diff -B arch/x86/entry/syscalls/syscall_64.tbl ../../arch/x86/entry/syscalls/syscall_64.tbl >/dev/null) \
23+
|| echo "Warning: x86_64's syscall_64.tbl differs from kernel" >&2 )) || true
24+
$(Q)$(SHELL) '$(systbl)' $(sys)/syscall_64.tbl 'x86_64' > $@
25+
26+
clean::
27+
rm -f $(header)
28+
29+
archheaders: $(header)

0 commit comments

Comments
 (0)