arm64: vdso: replace gettimeofday.S with arm vgettimeofday.C
PATCH v2 9/10 arm64: vdso: replace gettimeofday.S with arm vgettimeofday.C
Take an effort represented in the previous 8 patches to recode the arm64 vdso code from assembler to C previously submitted by Andrew Pinski <[email protected]>, rework it for use in both arm and arm64, overlapping any optimizations for each architecture.
apinski at cavium.com makes the following claims in the original patch:
This allows the compiler to optimize the divide by 1000 and remove the other divides.
On ThunderX, gettimeofday improves by 32%. On ThunderX 2, gettimeofday improves by 18%.
Note I noticed a bug in the old implementation of __kernel_clock_getres; it was checking only the lower 32bits of the pointer; this would work for most cases but could fail in a few.
v2: turned off profiling, restored quiet_cmd_vdsoas
--- arch/arm64/include/asm/vdso_datapage.h | 2 +- arch/arm64/kernel/asm-offsets.c | 2 +- arch/arm64/kernel/vdso.c | 2 +- arch/arm64/kernel/vdso/Makefile | 16 +- arch/arm64/kernel/vdso/compiler.h | 67 +++++++ arch/arm64/kernel/vdso/datapage.h | 58 ++++++ arch/arm64/kernel/vdso/gettimeofday.S | 328 --------------------------------- arch/arm64/kernel/vdso/vgettimeofday.c | 3 + 8 files changed, 141 insertions(+), 337 deletions(-) create mode 100644 arch/arm64/kernel/vdso/compiler.h create mode 100644 arch/arm64/kernel/vdso/datapage.h delete mode 100644 arch/arm64/kernel/vdso/gettimeofday.S create mode 100644 arch/arm64/kernel/vdso/vgettimeofday.c
arch/arm64/include/asm/vdso_datapage.h +1 -1
@@ -25,7 +25,7 @@ struct vdso_data {__u64 raw_time_sec;/* Raw time */ __u64 raw_time_nsec;__u64 xtime_clock_sec;/* Kernel time */ -__u64 xtime_clock_nsec; +__u64 xtime_clock_snsec;__u64 xtime_coarse_sec;/* Coarse time */ __u64 xtime_coarse_nsec;__u64 wtm_clock_sec;/* Wall to monotonic time */
arch/arm64/kernel/asm-offsets.c +1 -1
@@ -104,7 +104,7 @@ int main(void)DEFINE (VDSO_RAW_TIME_SEC , offsetof(struct vdso_data , raw_time_sec));DEFINE (VDSO_RAW_TIME_NSEC , offsetof(struct vdso_data , raw_time_nsec));DEFINE (VDSO_XTIME_CLK_SEC , offsetof(struct vdso_data , xtime_clock_sec)); -DEFINE (VDSO_XTIME_CLK_NSEC , offsetof(struct vdso_data , xtime_clock_nsec)); +DEFINE (VDSO_XTIME_CLK_NSEC , offsetof(struct vdso_data , xtime_clock_snsec));DEFINE (VDSO_XTIME_CRS_SEC , offsetof(struct vdso_data , xtime_coarse_sec));DEFINE (VDSO_XTIME_CRS_NSEC , offsetof(struct vdso_data , xtime_coarse_nsec));DEFINE (VDSO_WTM_CLK_SEC , offsetof(struct vdso_data , wtm_clock_sec));
arch/arm64/kernel/vdso.c +1 -1
@@ -238,7 +238,7 @@ void update_vsyscall(struct timekeeper *tk) vdso_data->raw_time_sec = tk->raw_sec; vdso_data->raw_time_nsec = tk->tkr_raw.xtime_nsec; vdso_data->xtime_clock_sec = tk->xtime_sec; - vdso_data->xtime_clock_nsec = tk->tkr_mono.xtime_nsec; + vdso_data->xtime_clock_snsec = tk->tkr_mono.xtime_nsec; vdso_data->cs_mono_mult = tk->tkr_mono.mult; vdso_data->cs_raw_mult = tk->tkr_raw.mult;/* tkr_mono.shift == tkr_raw.shift */
arch/arm64/kernel/vdso/Makefile +10 -6
@@ -5,18 +5,26 @@ # Heavily based on the vDSO Makefiles for other archs. # -obj-vdso := gettimeofday.o note.o sigreturn.o +obj-vdso := vgettimeofday.o note.o sigreturn.o # Build rules targets := $(obj-vdso) vdso.so vdso.so.dbg obj-vdso := $(addprefix $(obj)/, $(obj-vdso)) -ccflags-y := -shared -fno-common -fno-builtin +ccflags-y := -shared -fno-common -fno-builtin -fno-stack-protector +ccflags-y += -DDISABLE_BRANCH_PROFILING ccflags-y += -nostdlib -Wl,-soname=linux-vdso.so.1 \ $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) +# Force -O2 to avoid libgcc dependencies +CFLAGS_REMOVE_vgettimeofday.o = -pg -Os +CFLAGS_vgettimeofday.o = -O2 -mcmodel=tiny + # Disable gcov profiling for VDSO code GCOV_PROFILE := n +KASAN_SANITIZE := n +UBSAN_SANITIZE := n +KCOV_INSTRUMENT := n # Workaround for bare-metal (ELF) toolchains that neglect to pass -shared # down to collect2, resulting in silent corruption of the vDSO image.
@@ -48,10 +56,6 @@ endef include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE $(call if_changed,vdsosym) -# Assembly rules for the .S files -$(obj-vdso): %.o: %.S FORCE - $(call if_changed_dep,vdsoas) - # Actual build commands quiet_cmd_vdsold = VDSOL $@ cmd_vdsold = $(CC) $(c_flags) -Wl,-n -Wl,-T $^ -o $@
arch/arm64/kernel/vdso/compiler.h new file +67 -0
67 lines not on this page · raw message
arch/arm64/kernel/vdso/datapage.h new file +58 -0
58 lines not on this page · raw message
arch/arm64/kernel/vdso/gettimeofday.S deleted +0 -328
328 lines not on this page · raw message
arch/arm64/kernel/vdso/vgettimeofday.c new file +3 -0
@@ -0,0 +1,3 @@ +#include "compiler.h" +#include "datapage.h" +#include "../../../arm/vdso/vgettimeofday.c"
Signature · 1 line
2.15.0.rc0.271.g36b669edcc-goog