powerpc/32: switch VDSO to C implementation.
Subsystems (8)
v2 cover powerpc/32: switch VDSO to C implementation.
This is a second tentative to switch powerpc/32 vdso to generic C implementation.
It will likely not work on 64 bits or even build properly at the moment.
powerpc is a bit special for VDSO as well as system calls in the way that it requires setting CR SO bit which cannot be done in C. Therefore, entry/exit and fallback needs to be performed in ASM.
To allow that, the fallback calls are moved out of the common code and left to the arches.
A few other changes in the common code have allowed performance improvement.
The performance has improved since first RFC, but it is still lower than current assembly VDSO.
On a powerpc8xx, with current powerpc/32 ASM VDSO:
gettimeofday: vdso: 737 nsec/call clock-getres-realtime: vdso: 475 nsec/call clock-gettime-realtime: vdso: 892 nsec/call clock-getres-monotonic: vdso: 475 nsec/call clock-gettime-monotonic: vdso: 1014 nsec/call
First try of C implementation:
gettimeofday: vdso: 1533 nsec/call clock-getres-realtime: vdso: 853 nsec/call clock-gettime-realtime: vdso: 1570 nsec/call clock-getres-monotonic: vdso: 835 nsec/call clock-gettime-monotonic: vdso: 1605 nsec/call
With this series:
gettimeofday: vdso: 1016 nsec/call clock-getres-realtime: vdso: 560 nsec/call clock-gettime-realtime: vdso: 1192 nsec/call clock-getres-monotonic: vdso: 560 nsec/call clock-gettime-monotonic: vdso: 1192 nsec/call
Changes made to other arches are untested, not even compiled.
Christophe Leroy (10):
lib: vdso: ensure all arches have 32bit fallback
lib: vdso: move call to fallback out of common code.
lib: vdso: Change __cvdso_clock_gettime/getres_common() to
__cvdso_clock_gettime/getres()
lib: vdso: get pointer to vdso data from the arch
lib: vdso: inline do_hres()
lib: vdso: make do_coarse() return 0
lib: vdso: don't use READ_ONCE() in __c_kernel_time()
lib: vdso: Avoid duplication in __cvdso_clock_getres() powerpc/vdso32: inline __get_datapage() powerpc/32: Switch VDSO to C implementation.
arch/arm/include/asm/vdso/gettimeofday.h | 26 +++ arch/arm/vdso/vgettimeofday.c | 32 ++- arch/arm64/include/asm/vdso/compat_gettimeofday.h | 2 - arch/arm64/include/asm/vdso/gettimeofday.h | 26 +++ arch/arm64/kernel/vdso/vgettimeofday.c | 24 +- arch/arm64/kernel/vdso32/vgettimeofday.c | 39 +++- arch/mips/include/asm/vdso/gettimeofday.h | 28 ++- arch/mips/vdso/vgettimeofday.c | 56 ++++- arch/powerpc/Kconfig | 2 + arch/powerpc/include/asm/vdso/gettimeofday.h | 45 ++++ arch/powerpc/include/asm/vdso/vsyscall.h | 27 +++ arch/powerpc/include/asm/vdso_datapage.h | 28 +-- arch/powerpc/kernel/asm-offsets.c | 23 +- arch/powerpc/kernel/time.c | 92 +------- arch/powerpc/kernel/vdso.c | 19 +- arch/powerpc/kernel/vdso32/Makefile | 19 +- arch/powerpc/kernel/vdso32/cacheflush.S | 9 +- arch/powerpc/kernel/vdso32/datapage.S | 28 +-- arch/powerpc/kernel/vdso32/gettimeofday.S | 265 +++------------------- arch/powerpc/kernel/vdso32/vgettimeofday.c | 32 +++ arch/x86/entry/vdso/vclock_gettime.c | 52 ++++- arch/x86/include/asm/vdso/gettimeofday.h | 28 ++- lib/vdso/gettimeofday.c | 100 +++----- 23 files changed, 505 insertions(+), 497 deletions(-) create mode 100644 arch/powerpc/include/asm/vdso/gettimeofday.h create mode 100644 arch/powerpc/include/asm/vdso/vsyscall.h create mode 100644 arch/powerpc/kernel/vdso32/vgettimeofday.c
Signature · 1 line
2.13.3
RFC PATCH v2 1/10 lib: vdso: ensure all arches have 32bit fallback
In order to simplify next step which moves fallback call at arch level, ensure all arches have a 32bit fallback instead of handling the lack of 32bit fallback in the common code based
on VDSO_HAS_32BIT_FALLBACK
--- arch/arm/include/asm/vdso/gettimeofday.h | 26 +++++++++++++++++++++ arch/arm64/include/asm/vdso/compat_gettimeofday.h | 2 -- arch/arm64/include/asm/vdso/gettimeofday.h | 26 +++++++++++++++++++++ arch/mips/include/asm/vdso/gettimeofday.h | 28 +++++++++++++++++++++-- arch/x86/include/asm/vdso/gettimeofday.h | 28 +++++++++++++++++++++-- lib/vdso/gettimeofday.c | 10 -------- 6 files changed, 104 insertions(+), 16 deletions(-)
arch/arm/include/asm/vdso/gettimeofday.h +26 -0
@@ -70,6 +70,32 @@ static __always_inline int clock_getres_fallback(return ret; } +static __always_inline +long clock_gettime32_fallback (clockid_t _clkid,struct old_timespec32 *_ts) +{ +struct __kernel_timespec ts; +int ret =clock_gettime_fallback (clock, &ts); + +if (likely (!ret)) { + _ts->tv_sec = ts.tv_sec; + _ts->tv_nsec = ts.tv_nsec; + } +return ret; +} + +static __always_inline +long clock_getres32_fallback (clockid_t _clkid,struct old_timespec32 *_ts) +{ +struct __kernel_timespec ts; +int ret =clock_getres_fallback (clock, &ts); + +if (likely (!ret && _ts)) { + _ts->tv_sec = ts.tv_sec; + _ts->tv_nsec = ts.tv_nsec; + } +return ret; +} + static __always_inline u64 __arch_get_hw_counter(int clock_mode) {#ifdef CONFIG_ARM_ARCH_TIMER
arch/arm64/include/asm/vdso/compat_gettimeofday.h +0 -2
@@ -16,8 +16,6 @@#define VDSO_HAS_CLOCK_GETRES 1 -#define VDSO_HAS_32BIT_FALLBACK 1 -static __always_inline int gettimeofday_fallback(struct __kernel_old_timeval *_tv,struct timezone *_tz)
arch/arm64/include/asm/vdso/gettimeofday.h +26 -0
@@ -66,6 +66,32 @@ int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)return ret; } +static __always_inline +long clock_gettime32_fallback (clockid_t _clkid,struct old_timespec32 *_ts) +{ +struct __kernel_timespec ts; +int ret =clock_gettime_fallback (clock, &ts); + +if (likely (!ret)) { + _ts->tv_sec = ts.tv_sec; + _ts->tv_nsec = ts.tv_nsec; + } +return ret; +} + +static __always_inline +long clock_getres32_fallback (clockid_t _clkid,struct old_timespec32 *_ts) +{ +struct __kernel_timespec ts; +int ret =clock_getres_fallback (clock, &ts); + +if (likely (!ret && _ts)) { + _ts->tv_sec = ts.tv_sec; + _ts->tv_nsec = ts.tv_nsec; + } +return ret; +} + static __always_inline u64 __arch_get_hw_counter(s32 clock_mode) {u64 res;
arch/mips/include/asm/vdso/gettimeofday.h +26 -2
@@ -109,8 +109,6 @@ static __always_inline int clock_getres_fallback(#if _MIPS_SIM != _MIPS_SIM_ABI64 -#define VDSO_HAS_32BIT_FALLBACK 1 -static __always_inline long clock_gettime32_fallback (clockid_t _clkid,struct old_timespec32 *_ts)
@@ -150,6 +148,32 @@ static __always_inline int clock_getres32_fallback( return error ? -ret : ret; } +#else +static __always_inline +long clock_gettime32_fallback (clockid_t _clkid,struct old_timespec32 *_ts) +{ +struct __kernel_timespec ts; +int ret =clock_gettime_fallback (clock, &ts); + +if (likely (!ret)) { + _ts->tv_sec = ts.tv_sec; + _ts->tv_nsec = ts.tv_nsec; + } +return ret; +} + +static __always_inline +long clock_getres32_fallback (clockid_t _clkid,struct old_timespec32 *_ts) +{ +struct __kernel_timespec ts; +int ret =clock_getres_fallback (clock, &ts); + +if (likely (!ret && _ts)) { + _ts->tv_sec = ts.tv_sec; + _ts->tv_nsec = ts.tv_nsec; + } +return ret; +}#endif #ifdef CONFIG_CSRC_R4K
arch/x86/include/asm/vdso/gettimeofday.h +26 -2
@@ -94,9 +94,33 @@ long clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)return ret; } -#else +static __always_inline +long clock_gettime32_fallback (clockid_t _clkid,struct old_timespec32 *_ts) +{ +struct __kernel_timespec ts; +int ret =clock_gettime_fallback (clock, &ts); -#define VDSO_HAS_32BIT_FALLBACK 1 +if (likely (!ret)) { + _ts->tv_sec = ts.tv_sec; + _ts->tv_nsec = ts.tv_nsec; + } +return ret; +} + +static __always_inline +long clock_getres32_fallback (clockid_t _clkid,struct old_timespec32 *_ts) +{ +struct __kernel_timespec ts; +int ret =clock_getres_fallback (clock, &ts); + +if (likely (!ret && _ts)) { + _ts->tv_sec = ts.tv_sec; + _ts->tv_nsec = ts.tv_nsec; + } +return ret; +} + +#else static __always_inline long clock_gettime_fallback (clockid_t _clkid,struct __kernel_timespec *_ts)
lib/vdso/gettimeofday.c +0 -10
@@ -125,13 +125,8 @@ __cvdso_clock_gettime32(clockid_t clock, struct old_timespec32 *res) ret =__cvdso_clock_gettime_common (clock, &ts); -#ifdef VDSO_HAS_32BIT_FALLBACK if (unlikely (ret))return clock_gettime32_fallback (clock, res); -#else -if (unlikely (ret)) - ret =clock_gettime_fallback (clock, &ts); -#endif if (likely (!ret)) { res->tv_sec = ts.tv_sec;
@@ -238,13 +233,8 @@ __cvdso_clock_getres_time32(clockid_t clock, struct old_timespec32 *res) ret =__cvdso_clock_getres_common (clock, &ts); -#ifdef VDSO_HAS_32BIT_FALLBACK if (unlikely (ret))return clock_getres32_fallback (clock, res); -#else -if (unlikely (ret)) - ret =clock_getres_fallback (clock, &ts); -#endif if (likely (!ret && res)) { res->tv_sec = ts.tv_sec;
Signature · 1 line
2.13.3
Andy Lutomirski
maintainerRe: [RFC PATCH v2 01/10] lib: vdso: ensure all arches have 32bit fallback
Quoted 5 lines · Christophe Leroy
In order to simplify next step which moves fallback call at arch level, ensure all arches have a 32bit fallback instead of handling the lack of 32bit fallback in the common code based
onVDSO_HAS_32BIT_FALLBACK
I don't like this. You've implemented what appear to be nonsensical fallbacks (the 32-bit fallback for a 64-bit vDSO build? There's no such thing).
How exactly does this simplify patch 2?
--Andy
Re: [RFC PATCH v2 01/10] lib: vdso: ensure all arches have 32bit fallback
Quoted 8 lines · Andy Lutomirski
Quoted 5 lines · Christophe Leroy
In order to simplify next step which moves fallback call at arch level, ensure all arches have a 32bit fallback instead of handling the lack of 32bit fallback in the common code based
onVDSO_HAS_32BIT_FALLBACK
Quoted 5 lines
I don't like this. You've implemented what appear to be nonsensical fallbacks (the 32-bit fallback for a 64-bit vDSO build? There's no such thing).
How exactly does this simplify patch 2?
There is a patchset from Vincenzo which fell through the cracks which addresses the VDS_HAS_32BIT_FALLBACK issue properly. I'm about to pick it up. See:
https://lore.kernel.org/lkml/[email protected]/
Thanks,
tglx
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [RFC PATCH v2 01/10] lib: vdso: ensure all arches have 32bit fallback
Quoted 18 lines · Thomas Gleixner
Quoted 12 lines · Andy Lutomirski
Quoted 7 lines
On Mon, Dec 23, 2019 at 6:31 AM Christophe Leroy
<[email protected]> wrote:In order to simplify next step which moves fallback call at arch level, ensure all arches have a 32bit fallback instead of handling the lack of 32bit fallback in the common code based
onVDSO_HAS_32BIT_FALLBACKI don't like this. You've implemented what appear to be nonsensical fallbacks (the 32-bit fallback for a 64-bit vDSO build? There's no such thing).
Quoted 8 lines
Quoted 1 line
How exactly does this simplify patch 2?
There is a patchset from Vincenzo which fell through the cracks which addresses the
VDS_HAS_32BIT_FALLBACKissue properly. I'm about to pick it up. See:
Thanks. I had been wondering why the conditionals were still there, since I remember seeing these patches.
Quoted 3 lines
Thanks,
tglx
kbuild test robot
build botRe: [RFC PATCH v2 01/10] lib: vdso: ensure all arches have 32bit fallback
In reply to Christophe Leroy[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please…
Hi Christophe,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on v5.5-rc3]
[also build test ERROR on next-20191220]
[cannot apply to powerpc/next arm64/for-next/core tip/timers/vdso] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Christophe-Leroy/powerpc-32-switch-VDSO-to-C-implementation/20191225-085921 base: 46cf053efec6a3a5f343fead837777efe8252a46 config: x86_64-defconfig (attached as .config) compiler: gcc-7 (Debian 7.5.0-3) 7.5.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
In file included from arch/x86/entry/vdso/../../../../lib/vdso/gettimeofday.c:26:0,
from arch/x86/entry/vdso/vclock_gettime.c:15:
arch/x86/include/asm/vdso/gettimeofday.h: In function 'clock_gettime32_fallback':
>> arch/x86/include/asm/vdso/gettimeofday.h:101:35: error: 'clock' undeclared (first use in this function); did you mean 'k_clock'?
int ret = clock_gettime_fallback(clock, &ts);
^~~~~
k_clock
arch/x86/include/asm/vdso/gettimeofday.h:101:35: note: each undeclared identifier is reported only once for each function it appears in
arch/x86/include/asm/vdso/gettimeofday.h: In function 'clock_getres32_fallback':
arch/x86/include/asm/vdso/gettimeofday.h:114:34: error: 'clock' undeclared (first use in this function); did you mean 'k_clock'?
int ret = clock_getres_fallback(clock, &ts);
^~~~~
k_clockvim +101 arch/x86/include/asm/vdso/gettimeofday.h
96
97 static __always_inline
98 long clock_gettime32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
99 {
100 struct __kernel_timespec ts;
> 101 int ret = clock_gettime_fallback(clock, &ts);
102
103 if (likely(!ret)) {
104 _ts->tv_sec = ts.tv_sec;
105 _ts->tv_nsec = ts.tv_nsec;
106 }
107 return ret;
108 }
109
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
kbuild test robot
build botRe: [RFC PATCH v2 01/10] lib: vdso: ensure all arches have 32bit fallback
In reply to Christophe Leroy[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please…
Hi Christophe,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on v5.5-rc3]
[also build test ERROR on next-20191220]
[cannot apply to powerpc/next arm64/for-next/core tip/timers/vdso] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Christophe-Leroy/powerpc-32-switch-VDSO-to-C-implementation/20191225-085921 base: 46cf053efec6a3a5f343fead837777efe8252a46 config: x86_64-randconfig-s0-20191225 (attached as .config) compiler: gcc-6 (Debian 6.3.0-18+deb9u1) 6.3.0 20170516 reproduce: # save the attached .config to linux build tree make ARCH=x86_64
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
In file included from arch/x86/entry/vdso/../../../../lib/vdso/gettimeofday.c:26:0,
from arch/x86/entry/vdso/vclock_gettime.c:15:
arch/x86/include/asm/vdso/gettimeofday.h: In function 'clock_gettime32_fallback':
>> arch/x86/include/asm/vdso/gettimeofday.h:101:35: error: 'clock' undeclared (first use in this function)
int ret = clock_gettime_fallback(clock, &ts);
^~~~~
arch/x86/include/asm/vdso/gettimeofday.h:101:35: note: each undeclared identifier is reported only once for each function it appears in
arch/x86/include/asm/vdso/gettimeofday.h: In function 'clock_getres32_fallback':
arch/x86/include/asm/vdso/gettimeofday.h:114:34: error: 'clock' undeclared (first use in this function)
int ret = clock_getres_fallback(clock, &ts);
^~~~~vim +/clock +101 arch/x86/include/asm/vdso/gettimeofday.h
96
97 static __always_inline
98 long clock_gettime32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
99 {
100 struct __kernel_timespec ts;
> 101 int ret = clock_gettime_fallback(clock, &ts);
102
103 if (likely(!ret)) {
104 _ts->tv_sec = ts.tv_sec;
105 _ts->tv_nsec = ts.tv_nsec;
106 }
107 return ret;
108 }
109
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
Re: [RFC PATCH v2 01/10] lib: vdso: ensure all arches have 32bit fallback
In reply to Christophe LeroyQuoted 7 lines · Christophe Leroy
In order to simplify next step which moves fallback call at arch level, ensure all arches have a 32bit fallback instead of handling the lack of 32bit fallback in the common code based
onVDSO_HAS_32BIT_FALLBACKSigned-off-by Christophe Leroy <[email protected]>
I like the idea of removing VDSO_HAS_32BIT_FALLBACK and ensuring that all 32-bit architectures implement them, but we really should *not* have any implementation calling the 64-bit syscalls.
Quoted 15 lines
arch/arm/include/asm/vdso/gettimeofday.h +15
-0+static __always_inline +long clock_gettime32_fallback (clockid_t _clkid,struct old_timespec32 *_ts) +{ +struct __kernel_timespec ts; +int ret =clock_gettime_fallback (clock, &ts); + +if (likely (!ret)) { + _ts->tv_sec = ts.tv_sec; + _ts->tv_nsec = ts.tv_nsec; + } +return ret; +} + +static __always_inline +long clock_getres32_fallback (clockid_t _clkid,struct old_timespec32 *_ts)
arch/arm/include/asm/vdso/gettimeofday.h static __always_inline int clock_getres_fallback( · line 97
Quoted 10 lines
arch/arm/include/asm/vdso/gettimeofday.h +10
-0+{ +struct __kernel_timespec ts; +int ret =clock_getres_fallback (clock, &ts); + +if (likely (!ret && _ts)) { + _ts->tv_sec = ts.tv_sec; + _ts->tv_nsec = ts.tv_nsec; + } +return ret; +}
Please change these to call __NR_clock_gettime and __NR_clock_getres_time instead of __NR_clock_gettime64/__NR_clock_getres_time64 for multiple reasons.
- When doing migration between containers, the vdso may get copied into an application running on a kernel that does not support the time64 variants, and then the fallback fails.
- When CONFIG_COMPAT_32BIT_TIME is disabled, the time32 syscalls return -ENOSYS, and the vdso version should have the exact same behavior to avoid surprises. In particular an application that checks clock_gettime() to see if the time32 are in part of the kernel would get an incorrect result here.
arch/arm64/include/asm/vdso/compat_gettimeofday.h already does this, I think you can just copy the implementation or find a way to share it.
Quoted 10 lines
arch/arm64/include/asm/vdso/gettimeofday.h +2
-0@@ -66,6 +66,32 @@ int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)return ret; } +static __always_inline +long clock_gettime32_fallback (clockid_t _clkid,struct old_timespec32 *_ts)
arch/arm64/include/asm/vdso/gettimeofday.h int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts) · line 80
Quoted 10 lines
arch/arm64/include/asm/vdso/gettimeofday.h +10
-0+{ +struct __kernel_timespec ts; +int ret =clock_gettime_fallback (clock, &ts); + +if (likely (!ret)) { + _ts->tv_sec = ts.tv_sec; + _ts->tv_nsec = ts.tv_nsec; + } +return ret; +}
As Andy said, this makes no sense at all, nothing should ever call this on a 64-bit architecture.
Quoted 21 lines
arch/mips/include/asm/vdso/gettimeofday.h +4
-2@@ -109,8 +109,6 @@ static __always_inline int clock_getres_fallback(#if _MIPS_SIM != _MIPS_SIM_ABI64 -#define VDSO_HAS_32BIT_FALLBACK 1 -static __always_inline long clock_gettime32_fallback (clockid_t _clkid,struct old_timespec32 *_ts)@@ -150,6 +148,32 @@ static __always_inline int clock_getres32_fallback( return error ? -ret : ret; } +#else +static __always_inline +long clock_gettime32_fallback (clockid_t _clkid,struct old_timespec32 *_ts) +{
arch/mips/include/asm/vdso/gettimeofday.h static __always_inline int clock_getres32_fallback( · line 164
Quoted 10 lines
arch/mips/include/asm/vdso/gettimeofday.h +10
-0+struct __kernel_timespec ts; +int ret =clock_gettime_fallback (clock, &ts); + +if (likely (!ret)) { + _ts->tv_sec = ts.tv_sec; + _ts->tv_nsec = ts.tv_nsec; + } +return ret; +} +
Same here.
Quoted 6 lines
lib/vdso/gettimeofday.c +0
-0@@ -125,13 +125,8 @@ __cvdso_clock_gettime32(clockid_t clock, struct old_timespec32 *res) ret =__cvdso_clock_gettime_common (clock, &ts);
lib/vdso/gettimeofday.c __cvdso_clock_gettime32(clockid_t clock, struct old_timespec32 *res) · line 132
Quoted 10 lines
lib/vdso/gettimeofday.c +0
-5-#ifdef VDSO_HAS_32BIT_FALLBACK if (unlikely (ret))return clock_gettime32_fallback (clock, res); -#else -if (unlikely (ret)) - ret =clock_gettime_fallback (clock, &ts); -#endif if (likely (!ret)) { res->tv_sec = ts.tv_sec;
Removing the #ifdef and the fallback seems fine. I think this is actually required for correctness on arm32 as well. Maybe enclose the entire function in
#ifdef VDSO_HAS_CLOCK_GETTIME32
to only define it when it is called?
lib/vdso/gettimeofday.c __cvdso_clock_getres_time32(clockid_t clock, struct old_timespec32 *res) · line 247
Quoted 11 lines
lib/vdso/gettimeofday.c +0
-5@@ -238,13 +233,8 @@ __cvdso_clock_getres_time32(clockid_t clock, struct old_timespec32 *res) ret =__cvdso_clock_getres_common (clock, &ts); -#ifdef VDSO_HAS_32BIT_FALLBACK if (unlikely (ret))return clock_getres32_fallback (clock, res); -#else -if (unlikely (ret)) - ret =clock_getres_fallback (clock, &ts); -#endif
The same applies to all the getres stuff of course.
Arnd
Re: [RFC PATCH v2 01/10] lib: vdso: ensure all arches have 32bit fallback
Quoted 21 lines · Arnd Bergmann
Review
Quoted 12 lines · Christophe Leroy
(quoted diff) +12
-0+static __always_inline +long clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts) +{ + struct __kernel_timespec ts; + int ret = clock_getres_fallback(clock, &ts); + + if (likely(!ret && _ts)) { + _ts->tv_sec = ts.tv_sec; + _ts->tv_nsec = ts.tv_nsec; + } + return ret; +}Please change these to call
__NR_clock_gettimeand__NR_clock_getres_timeinstead of __NR_clock_gettime64/__NR_clock_getres_time64 for multiple reasons.- When doing migration between containers, the vdso may get copied into an application running on a kernel that does not support the time64 variants, and then the fallback fails.
Quoted 8 lines
- When
CONFIG_COMPAT_32BIT_TIMEis disabled, the time32 syscalls return-ENOSYS, and the vdso version should have the exact same behavior to avoid surprises. In particular an application that checksclock_gettime()to see if the time32 are in part of the kernel would get an incorrect result here.
arch/arm64/include/asm/vdso/compat_gettimeofday.halready does this, I think you can just copy the implementation or find a way to share it.
There was a related discussion on this after a vdso regression on mips, and I suggested to drop the time32 functions completely from the vdso when CONFIG_COMPAT_32BIT_TIME is disabled, such as
(quoted diff) +0 -0
b/arch/powerpc/kernel/vdso32/vdso32.lds.S
index 00c025ba4a92..605f259fa24c 100644
arch/powerpc/kernel/vdso32/vdso32.lds.S +2 -0
@@ -145,10 +145,12 @@ VERSION __kernel_get_syscall_map; #ifndef CONFIG_PPC_BOOK3S_601 +#ifdef CONFIG_COMPAT_32BIT_TIME __kernel_gettimeofday; __kernel_clock_gettime; __kernel_clock_getres; __kernel_time; +#endif __kernel_get_tbfreq; #endif __kernel_sync_dicache;
Any opinions on this? If everyone agrees with that approach, I can send a cross-architecture patch to do this everywhere. It's probably best though if Christophe adds that to his series as it touches a lot of the same files and I would prefer to avoid conflicting changes.
Arnd
Re: [RFC PATCH v2 01/10] lib: vdso: ensure all arches have 32bit fallback
Le 02/01/2020 à 12:29, Arnd Bergmann a écrit :
Quoted 54 lines · Arnd Bergmann
Quoted 21 lines · Christophe Leroy
Review
Quoted 12 lines
(quoted diff) +12
-0+static __always_inline +long clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts) +{ + struct __kernel_timespec ts; + int ret = clock_getres_fallback(clock, &ts); + + if (likely(!ret && _ts)) { + _ts->tv_sec = ts.tv_sec; + _ts->tv_nsec = ts.tv_nsec; + } + return ret; +}Please change these to call
__NR_clock_gettimeand__NR_clock_getres_timeinstead of __NR_clock_gettime64/__NR_clock_getres_time64 for multiple reasons.- When doing migration between containers, the vdso may get copied into an application running on a kernel that does not support the time64 variants, and then the fallback fails.
Quoted 8 lines
- When
CONFIG_COMPAT_32BIT_TIMEis disabled, the time32 syscalls return-ENOSYS, and the vdso version should have the exact same behavior to avoid surprises. In particular an application that checksclock_gettime()to see if the time32 are in part of the kernel would get an incorrect result here.
arch/arm64/include/asm/vdso/compat_gettimeofday.halready does this, I think you can just copy the implementation or find a way to share it.There was a related discussion on this after a vdso regression on mips, and I suggested to drop the time32 functions completely from the vdso when
CONFIG_COMPAT_32BIT_TIMEis disabled, such asarch/powerpc/kernel/vdso32/vdso32.lds.S +2
-0@@ -145,10 +145,12 @@ VERSION __kernel_get_syscall_map; #ifndef CONFIG_PPC_BOOK3S_601 +#ifdef CONFIG_COMPAT_32BIT_TIME __kernel_gettimeofday; __kernel_clock_gettime; __kernel_clock_getres; __kernel_time; +#endif __kernel_get_tbfreq; #endif __kernel_sync_dicache;
Quoted 5 lines
Any opinions on this? If everyone agrees with that approach, I can send a cross-architecture patch to do this everywhere. It's probably best though if Christophe adds that to his series as it touches a lot of the same files and I would prefer to avoid conflicting changes.
I guess it would be wise.
I don't think my series to switch powerpc to C VDSO will get ready anytime soon, because (in addition to the performance impact) I'm having hard time with the 32 bits VDSO for PPC64. Many of the powerpc header files used by lib/vdso/gettimeofday.c are not ready for generating 32 bits code for PPC64. Main problem is that at many places, #ifdef CONFIG_PPC64 is used instead of #ifdef __powerpc64__. There are also some CONFIG options like CONFIG_GENERIC_ATOMIC64 that are selected only when CONFIG_PPC32 is set, but which are required for building the 32 bits VDSO. For that I don't even know how to deal with it.
So, feel free to send your patch, and if my series comes early enough to conflict, I'll manage it.
Christophe
RFC PATCH v2 2/10 lib: vdso: move call to fallback out of common code.
In reply to Christophe LeroyOn powerpc, VDSO functions and syscalls cannot be implemented in C because the Linux kernel ABI requires that CR[SO] bit is set in case of error and cleared when no error.
As this cannot be done in C, C VDSO functions and syscall'based fallback need a trampoline in ASM.
By moving the fallback calls out of the common code, arches like powerpc can implement both the call to C VDSO and the fallback call in a single trampoline function.
The two advantages are:
- No need play back and forth with CR[SO] and negative return value.
- No stack frame is required in VDSO C functions for the fallbacks.
The performance improvement is significant on powerpc.
--- arch/arm/vdso/vgettimeofday.c | 28 +++++++++++++++--- arch/arm64/kernel/vdso/vgettimeofday.c | 21 ++++++++++++-- arch/arm64/kernel/vdso32/vgettimeofday.c | 35 ++++++++++++++++++++--- arch/mips/vdso/vgettimeofday.c | 49 +++++++++++++++++++++++++++----- arch/x86/entry/vdso/vclock_gettime.c | 42 +++++++++++++++++++++++---- lib/vdso/gettimeofday.c | 31 ++++---------------- 6 files changed, 156 insertions(+), 50 deletions(-)
arch/arm/vdso/vgettimeofday.c +24 -4
@@ -10,25 +10,45 @@int __vdso_clock_gettime (clockid_t clock,struct old_timespec32 *ts) { -return __cvdso_clock_gettime32 (clock, ts); +int ret =__cvdso_clock_gettime32 (clock, ts); + +if (likely (!ret)) +return ret; + +return clock_gettime32_fallback (clock, &ts); }int __vdso_clock_gettime64 (clockid_t clock,struct __kernel_timespec *ts) { -return __cvdso_clock_gettime (clock, ts); +int ret =__cvdso_clock_gettime (clock, ts); + +if (likely (!ret)) +return ret; + +return clock_gettime_fallback (clock, ts); }int __vdso_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz) { -return __cvdso_gettimeofday (tv, tz); +int ret =__cvdso_gettimeofday (tv, tz); + +if (likely (!ret)) +return ret; + +return gettimeofday_fallback (tv, tz); }int __vdso_clock_getres (clockid_t clock_id,struct old_timespec32 *res) { -return __cvdso_clock_getres_time32 (clock_id, res); +int ret =__cvdso_clock_getres_time32 (clock_id, res); + +if (likely (!ret)) +return ret; + +return clock_getres32_fallback (clock, res); }/* Avoid unresolved references emitted by GCC */
arch/arm64/kernel/vdso/vgettimeofday.c +18 -3
@@ -11,17 +11,32 @@int __kernel_clock_gettime (clockid_t clock,struct __kernel_timespec *ts) { -return __cvdso_clock_gettime (clock, ts); +int ret =__cvdso_clock_gettime (clock, ts); + +if (likely (!ret)) +return ret; + +return clock_gettime_fallback (clock, ts); }int __kernel_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz) { -return __cvdso_gettimeofday (tv, tz); +int ret =__cvdso_gettimeofday (tv, tz); + +if (likely (!ret)) +return ret; + +return gettimeofday_fallback (tv, tz); }int __kernel_clock_getres (clockid_t clock_id,struct __kernel_timespec *res) { -return __cvdso_clock_getres (clock_id, res); +int ret =__cvdso_clock_getres (clock_id, res); + +if (likely (!ret)) +return ret; + +return clock_getres_fallback (clock, res); }
arch/arm64/kernel/vdso32/vgettimeofday.c +31 -4
@@ -11,37 +11,64 @@int __vdso_clock_gettime (clockid_t clock,struct old_timespec32 *ts) { +int ret; +/* The checks below are required for ABI consistency with arm */ if ((u32 )ts >=TASK_SIZE_32 )return -EFAULT ; -return __cvdso_clock_gettime32 (clock, ts); + ret =__cvdso_clock_gettime32 (clock, ts); + +if (likely (!ret)) +return ret; + +return clock_gettime32_fallback (clock, &ts); }int __vdso_clock_gettime64 (clockid_t clock,struct __kernel_timespec *ts) { +int ret; +/* The checks below are required for ABI consistency with arm */ if ((u32 )ts >=TASK_SIZE_32 )return -EFAULT ; -return __cvdso_clock_gettime (clock, ts); + ret =__cvdso_clock_gettime (clock, ts); + +if (likely (!ret)) +return ret; + +return clock_gettime_fallback (clock, ts); }int __vdso_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz) { -return __cvdso_gettimeofday (tv, tz); +int ret =__cvdso_gettimeofday (tv, tz); + +if (likely (!ret)) +return ret; + +return gettimeofday_fallback (tv, tz); }int __vdso_clock_getres (clockid_t clock_id,struct old_timespec32 *res) { +int ret; +struct __kernel_timespec ts; +/* The checks below are required for ABI consistency with arm */ if ((u32 )res >=TASK_SIZE_32 )return -EFAULT ; -return __cvdso_clock_getres_time32 (clock_id, res); + ret =__cvdso_clock_getres_time32 (clock_id, res); + +if (likely (!ret)) +return ret; + +return clock_getres32_fallback (clock, res); }/* Avoid unresolved references emitted by GCC */
arch/mips/vdso/vgettimeofday.c +42 -7
86 lines not on this page · raw message
arch/x86/entry/vdso/vclock_gettime.c +36 -6
78 lines not on this page · raw message
lib/vdso/gettimeofday.c +5 -26
@@ -16,9 +16,6 @@* - __arch_get_vdso_data(): to get the vdso datapage. * - __arch_get_hw_counter(): to get the hw counter based on the * clock_mode. -* - gettimeofday_fallback(): fallback for gettimeofday. -* - clock_gettime_fallback(): fallback for clock_gettime. -* - clock_getres_fallback(): fallback for clock_getres. */ #ifdef ENABLE_COMPAT_VDSO #include <asm/vdso/compat_gettimeofday.h>
@@ -110,23 +107,14 @@ __cvdso_clock_gettime_common(clockid_t clock, struct __kernel_timespec *ts)static __maybe_unused int __cvdso_clock_gettime (clockid_t clock,struct __kernel_timespec *ts) { -int ret =__cvdso_clock_gettime_common (clock, ts); - -if (unlikely (ret)) -return clock_gettime_fallback (clock, ts); -return 0 ; +return __cvdso_clock_gettime_common (clock, ts); }static __maybe_unused int __cvdso_clock_gettime32 (clockid_t clock,struct old_timespec32 *res) {struct __kernel_timespec ts; -int ret; - - ret =__cvdso_clock_gettime_common (clock, &ts); - -if (unlikely (ret)) -return clock_gettime32_fallback (clock, res); +int ret =__cvdso_clock_gettime_common (clock, &ts);if (likely (!ret)) { res->tv_sec = ts.tv_sec;
@@ -144,7 +132,7 @@ __cvdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)struct __kernel_timespec ts;if (do_hres (&vd[CS_HRES_COARSE ],CLOCK_REALTIME , &ts)) -return gettimeofday_fallback (tv, tz); +return -1 ; tv->tv_sec = ts.tv_sec; tv->tv_usec = (u32 )ts.tv_nsec /NSEC_PER_USEC ;
@@ -218,23 +206,14 @@ int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res)int __cvdso_clock_getres (clockid_t clock,struct __kernel_timespec *res) { -int ret =__cvdso_clock_getres_common (clock, res); - -if (unlikely (ret)) -return clock_getres_fallback (clock, res); -return 0 ; +return __cvdso_clock_getres_common (clock, res); }static __maybe_unused int __cvdso_clock_getres_time32 (clockid_t clock,struct old_timespec32 *res) {struct __kernel_timespec ts; -int ret; - - ret =__cvdso_clock_getres_common (clock, &ts); - -if (unlikely (ret)) -return clock_getres32_fallback (clock, res); +int ret =__cvdso_clock_getres_common (clock, &ts);if (likely (!ret && res)) { res->tv_sec = ts.tv_sec;
Signature · 1 line
2.13.3
Andy Lutomirski
maintainerRe: [RFC PATCH v2 02/10] lib: vdso: move call to fallback out of common code.
Quoted 11 lines · Christophe Leroy
On powerpc, VDSO functions and syscalls cannot be implemented in C because the Linux kernel ABI requires that CR[SO] bit is set in case of error and cleared when no error.
As this cannot be done in C, C VDSO functions and syscall'based fallback need a trampoline in ASM.
By moving the fallback calls out of the common code, arches like powerpc can implement both the call to C VDSO and the fallback call in a single trampoline function.
Maybe the issue is that I'm not a powerpc person, but I don't understand this. The common vDSO code is in C. Presumably this means that you need an asm trampoline no matter what to call the C code. Is the improvement that, with this change, you can have the asm trampoline do a single branch, so it's logically:
ret = [call the C code];
if (ret == 0) {
set success bit;
} else {
ret = fallback;
if (ret == 0)
set success bit;
else
set failure bit;
}
return ret;
instead of:
ret = [call the C code, which includes the fallback]; if (ret == 0)
set success bit;
else
set failure bit;
It's not obvious to me that the former ought to be faster.
Quoted 4 lines
The two advantages are:
- No need play back and forth with CR[SO] and negative return value.
- No stack frame is required in VDSO C functions for the fallbacks.
How is no stack frame required? Do you mean that the presence of the fallback causes worse code generation? Can you improve the fallback instead?
Re: [RFC PATCH v2 02/10] lib: vdso: move call to fallback out of common code.
Le 24/12/2019 à 03:24, Andy Lutomirski a écrit :
Quoted 20 lines
Quoted 11 lines · Christophe Leroy
On powerpc, VDSO functions and syscalls cannot be implemented in C because the Linux kernel ABI requires that CR[SO] bit is set in case of error and cleared when no error.
As this cannot be done in C, C VDSO functions and syscall'based fallback need a trampoline in ASM.
By moving the fallback calls out of the common code, arches like powerpc can implement both the call to C VDSO and the fallback call in a single trampoline function.
Maybe the issue is that I'm not a powerpc person, but I don't understand this. The common vDSO code is in C. Presumably this means that you need an asm trampoline no matter what to call the C code. Is the improvement that, with this change, you can have the asm trampoline do a single branch, so it's logically:
Quoted 10 lines
ret = [call the C code];
if (ret == 0) {
set success bit;
} else {
ret = fallback;
if (ret == 0)
set success bit;
else
set failure bit;
}
More simple than above, in fact it is:
ret = [call the C code];
if (ret == 0) {
set success bit;
} else {
ret = fallback [ which sets the success/failure bit];
}
return ret
Quoted 6 lines
return ret;
instead of:
ret = [call the C code, which includes the fallback];
C code cannot handle the success/failure bit so we need to do something which does:
int assembly_to_fallback()
{
ret = [syscall the fallback]
if (success bit set)
return ret;
else
return -ret;
}Also means going back and forth between the success bit and negative return.
Quoted 8 lines
if (ret == 0)
set success bit;
else
set failure bit;It's not obvious to me that the former ought to be faster.
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
The two advantages are:
- No need play back and forth with CR[SO] and negative return value.
- No stack frame is required in VDSO C functions for the fallbacks.How is no stack frame required? Do you mean that the presence of the fallback causes worse code generation? Can you improve the fallback instead?
When function F1 calls function F2 (with BL insn), the link register (LR) is set with the return address in F1, so that at the end of F2, F2 branches to LR (with BLR insn), that's how you return from functions.
When F2 calls function F3, the same happens, LR is set to the return of F3 into F2. It means that F2 has to save LR in order to be able to return to F1, otherwise the return address from F2 into F1 is lost.
But ... thinking about it once more, indeed fallback means doing a syscall, and in fact I realise that syscalls won't clobber LR, so it should be possible to do something. Let me try it.
Christophe
Re: [RFC PATCH v2 02/10] lib: vdso: move call to fallback out of common code.
Quoted 37 lines · christophe leroy
Quoted 14 lines · Andy Lutomirski
Quoted 7 lines
On Mon, Dec 23, 2019 at 6:31 AM Christophe Leroy
<[email protected]> wrote:On powerpc, VDSO functions and syscalls cannot be implemented in C because the Linux kernel ABI requires that CR[SO] bit is set in case of error and cleared when no error.
Quoted 6 lines
As this cannot be done in C, C VDSO functions and syscall'based fallback need a trampoline in ASM.
By moving the fallback calls out of the common code, arches like powerpc can implement both the call to C VDSO and the fallback call in a single trampoline function.
Quoted 15 lines
Maybe the issue is that I'm not a powerpc person, but I don't understand this. The common vDSO code is in C. Presumably this means that you need an asm trampoline no matter what to call the C code. Is the improvement that, with this change, you can have the asm trampoline do a single branch, so it's logically:
ret = [call the C code];
if (ret == 0) {
set success bit;
} else {
ret = fallback;
if (ret == 0)
set success bit;
else
set failure bit;
}More simple than above, in fact it is:
Quoted 7 lines
ret = [call the C code];
if (ret == 0) {
set success bit;
} else {
ret = fallback [ which sets the success/failure bit]; }
return ret
Cute.
Quoted 8 lines
Quoted 5 lines
return ret;
instead of:
ret = [call the C code, which includes the fallback];C code cannot handle the success/failure bit so we need to do something which does:
Quoted 8 lines
int
assembly_to_fallback()
{
ret = [syscall the fallback]
if (success bit set)return ret; else return -ret; }
Wait, your calling convention has syscalls return positive values on error?
But I think this is moot. The syscalls in question never return nonzero success values, so you should be able to inline the syscall without worrying about this.
Quoted 16 lines
Also means going back and forth between the success bit and negative return.
Quoted 6 lines
if (ret == 0)
set success bit;
else
set failure bit;
It's not obvious to me that the former ought to be faster.Quoted 1 line
Quoted 6 lines
Quoted 3 lines
The two advantages are:
- No need play back and forth with CR[SO] and negative return value.
- No stack frame is required in VDSO C functions for the fallbacks.How is no stack frame required? Do you mean that the presence of the fallback causes worse code generation? Can you improve the fallback instead?
Quoted 6 lines
When function F1 calls function F2 (with BL insn), the link register (LR) is set with the return address in F1, so that at the end of F2, F2 branches to LR (with BLR insn), that's how you return from functions.
When F2 calls function F3, the same happens, LR is set to the return of F3 into F2. It means that F2 has to save LR in order to be able to return to F1, otherwise the return address from F2 into F1 is lost.
But ... thinking about it once more, indeed fallback means doing a syscall, and in fact I realise that syscalls won't clobber LR, so it should be possible to do something. Let me try it.
With that plus assume that nonzero return means failure, I think you should have all your bases covered.
kbuild test robot
build botRe: [RFC PATCH v2 02/10] lib: vdso: move call to fallback out of common code.
In reply to Christophe Leroy[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please…
Hi Christophe,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on v5.5-rc3]
[also build test ERROR on next-20191220]
[cannot apply to powerpc/next arm64/for-next/core tip/timers/vdso] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Christophe-Leroy/powerpc-32-switch-VDSO-to-C-implementation/20191225-085921 base: 46cf053efec6a3a5f343fead837777efe8252a46 config: x86_64-defconfig (attached as .config) compiler: gcc-7 (Debian 7.5.0-3) 7.5.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
In file included from arch/x86//entry/vdso/../../../../lib/vdso/gettimeofday.c:23:0,
from arch/x86//entry/vdso/vclock_gettime.c:15:
arch/x86/include/asm/vdso/gettimeofday.h: In function 'clock_gettime32_fallback':
arch/x86/include/asm/vdso/gettimeofday.h:101:35: error: 'clock' undeclared (first use in this function); did you mean 'k_clock'?
int ret = clock_gettime_fallback(clock, &ts);
^~~~~
k_clock
arch/x86/include/asm/vdso/gettimeofday.h:101:35: note: each undeclared identifier is reported only once for each function it appears in
arch/x86/include/asm/vdso/gettimeofday.h: In function 'clock_getres32_fallback':
arch/x86/include/asm/vdso/gettimeofday.h:114:34: error: 'clock' undeclared (first use in this function); did you mean 'k_clock'?
int ret = clock_getres_fallback(clock, &ts);
^~~~~
k_clock
arch/x86//entry/vdso/vclock_gettime.c: In function '__vdso_clock_getres':
>> arch/x86//entry/vdso/vclock_gettime.c:62:34: error: 'clock_id' undeclared (first use in this function); did you mean 'clock_t'?
int ret = __cvdso_clock_getres(clock_id, res);
^~~~~~~~
clock_tvim +62 arch/x86//entry/vdso/vclock_gettime.c
55
56 int clock_gettime(clockid_t, struct __kernel_timespec *)
57 __attribute__((weak, alias("__vdso_clock_gettime")));
58
59 int __vdso_clock_getres(clockid_t clock,
60 struct __kernel_timespec *res)
61 {
> 62 int ret = __cvdso_clock_getres(clock_id, res);
63
64 if (likely(!ret))
65 return ret;
66
67 return clock_getres_fallback(clock, res);
68 }
69 int clock_getres(clockid_t, struct __kernel_timespec *)
70 __attribute__((weak, alias("__vdso_clock_getres")));
71 ---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
RFC PATCH v2 3/10 lib: vdso: Change __cvdso_clock_gettime/getres_common() to __cvdso_clock_gettime/getres()
In reply to Christophe Leroy__cvdso_clock_getres() just calls __cvdso_clock_getres_common(). __cvdso_clock_gettime() just calls __cvdso_clock_getres_common().
Drop __cvdso_clock_getres() and __cvdso_clock_gettime() Rename __cvdso_clock_gettime_common() into __cvdso_clock_gettime() Rename __cvdso_clock_getres_common() into __cvdso_clock_getres()
--- lib/vdso/gettimeofday.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
lib/vdso/gettimeofday.c +4 -15
@@ -79,7 +79,7 @@ static void do_coarse(const struct vdso_data *vd, clockid_t clk, }static __maybe_unused int -__cvdso_clock_gettime_common (clockid_t clock,struct __kernel_timespec *ts) +__cvdso_clock_gettime (clockid_t clock,struct __kernel_timespec *ts) {const struct vdso_data *vd =__arch_get_vdso_data ();u32 msk;
@@ -105,16 +105,10 @@ __cvdso_clock_gettime_common(clockid_t clock, struct __kernel_timespec *ts) }static __maybe_unused int -__cvdso_clock_gettime (clockid_t clock,struct __kernel_timespec *ts) -{ -return __cvdso_clock_gettime_common (clock, ts); -} - -static __maybe_unused int __cvdso_clock_gettime32 (clockid_t clock,struct old_timespec32 *res) {struct __kernel_timespec ts; -int ret =__cvdso_clock_gettime_common (clock, &ts); +int ret =__cvdso_clock_gettime (clock, &ts);if (likely (!ret)) { res->tv_sec = ts.tv_sec;
@@ -161,7 +155,7 @@ static __maybe_unused __kernel_old_time_t __cvdso_time(__kernel_old_time_t *time#ifdef VDSO_HAS_CLOCK_GETRES static __maybe_unused -int __cvdso_clock_getres_common (clockid_t clock,struct __kernel_timespec *res) +int __cvdso_clock_getres (clockid_t clock,struct __kernel_timespec *res) {const struct vdso_data *vd =__arch_get_vdso_data ();u64 hrtimer_res;
@@ -204,16 +198,11 @@ int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res)return 0 ; } -int __cvdso_clock_getres (clockid_t clock,struct __kernel_timespec *res) -{ -return __cvdso_clock_getres_common (clock, res); -} -static __maybe_unused int __cvdso_clock_getres_time32 (clockid_t clock,struct old_timespec32 *res) {struct __kernel_timespec ts; -int ret =__cvdso_clock_getres_common (clock, &ts); +int ret =__cvdso_clock_getres (clock, &ts);if (likely (!ret && res)) { res->tv_sec = ts.tv_sec;
Signature · 1 line
2.13.3
RFC PATCH v2 4/10 lib: vdso: get pointer to vdso data from the arch
In reply to Christophe LeroyOn powerpc, __arch_get_vdso_data() clobbers the link register, requiring the caller to set a stack frame in order to save it.
As the parent function already has to set a stack frame and save the link register to call the C vdso function, retriving the vdso data pointer there is lighter.
Give arches the opportunity to hand the vdso data pointer to C vdso functions.
--- arch/arm/vdso/vgettimeofday.c | 12 ++++++++---- arch/arm64/kernel/vdso/vgettimeofday.c | 9 ++++++--- arch/arm64/kernel/vdso32/vgettimeofday.c | 12 ++++++++---- arch/mips/vdso/vgettimeofday.c | 21 ++++++++++++++------- arch/x86/entry/vdso/vclock_gettime.c | 22 +++++++++++++++------- lib/vdso/gettimeofday.c | 28 ++++++++++++++-------------- 6 files changed, 65 insertions(+), 39 deletions(-)
arch/arm/vdso/vgettimeofday.c +8 -4
@@ -10,7 +10,8 @@int __vdso_clock_gettime (clockid_t clock,struct old_timespec32 *ts) { -int ret =__cvdso_clock_gettime32 (clock, ts); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_clock_gettime32 (vd, clock, ts);if (likely (!ret))return ret;
@@ -21,7 +22,8 @@ int __vdso_clock_gettime(clockid_t clock,int __vdso_clock_gettime64 (clockid_t clock,struct __kernel_timespec *ts) { -int ret =__cvdso_clock_gettime (clock, ts); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_clock_gettime (vd, clock, ts);if (likely (!ret))return ret;
@@ -32,7 +34,8 @@ int __vdso_clock_gettime64(clockid_t clock,int __vdso_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz) { -int ret =__cvdso_gettimeofday (tv, tz); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_gettimeofday (vd, tv, tz);if (likely (!ret))return ret;
@@ -43,7 +46,8 @@ int __vdso_gettimeofday(struct __kernel_old_timeval *tv,int __vdso_clock_getres (clockid_t clock_id,struct old_timespec32 *res) { -int ret =__cvdso_clock_getres_time32 (clock_id, res); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_clock_getres_time32 (vd, clock_id, res);if (likely (!ret))return ret;
arch/arm64/kernel/vdso/vgettimeofday.c +6 -3
@@ -11,7 +11,8 @@int __kernel_clock_gettime (clockid_t clock,struct __kernel_timespec *ts) { -int ret =__cvdso_clock_gettime (clock, ts); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_clock_gettime (vd, clock, ts);if (likely (!ret))return ret;
@@ -22,7 +23,8 @@ int __kernel_clock_gettime(clockid_t clock,int __kernel_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz) { -int ret =__cvdso_gettimeofday (tv, tz); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_gettimeofday (vd, tv, tz);if (likely (!ret))return ret;
@@ -33,7 +35,8 @@ int __kernel_gettimeofday(struct __kernel_old_timeval *tv,int __kernel_clock_getres (clockid_t clock_id,struct __kernel_timespec *res) { -int ret =__cvdso_clock_getres (clock_id, res); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_clock_getres (vd, clock_id, res);if (likely (!ret))return ret;
arch/arm64/kernel/vdso32/vgettimeofday.c +8 -4
@@ -11,13 +11,14 @@int __vdso_clock_gettime (clockid_t clock,struct old_timespec32 *ts) { +const struct vdso_data *vd =__arch_get_vdso_data ();int ret;/* The checks below are required for ABI consistency with arm */ if ((u32 )ts >=TASK_SIZE_32 )return -EFAULT ; - ret =__cvdso_clock_gettime32 (clock, ts); + ret =__cvdso_clock_gettime32 (vd, clock, ts);if (likely (!ret))return ret;
@@ -28,13 +29,14 @@ int __vdso_clock_gettime(clockid_t clock,int __vdso_clock_gettime64 (clockid_t clock,struct __kernel_timespec *ts) { +const struct vdso_data *vd =__arch_get_vdso_data ();int ret;/* The checks below are required for ABI consistency with arm */ if ((u32 )ts >=TASK_SIZE_32 )return -EFAULT ; - ret =__cvdso_clock_gettime (clock, ts); + ret =__cvdso_clock_gettime (vd, clock, ts);if (likely (!ret))return ret;
@@ -45,7 +47,8 @@ int __vdso_clock_gettime64(clockid_t clock,int __vdso_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz) { -int ret =__cvdso_gettimeofday (tv, tz); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_gettimeofday (vd, tv, tz);if (likely (!ret))return ret;
@@ -56,6 +59,7 @@ int __vdso_gettimeofday(struct __kernel_old_timeval *tv,int __vdso_clock_getres (clockid_t clock_id,struct old_timespec32 *res) { +const struct vdso_data *vd =__arch_get_vdso_data ();int ret;struct __kernel_timespec ts;
@@ -63,7 +67,7 @@ int __vdso_clock_getres(clockid_t clock_id,if ((u32 )res >=TASK_SIZE_32 )return -EFAULT ; - ret =__cvdso_clock_getres_time32 (clock_id, res); + ret =__cvdso_clock_getres_time32 (vd, clock_id, res);if (likely (!ret))return ret;
arch/mips/vdso/vgettimeofday.c +14 -7
@@ -14,7 +14,8 @@int __vdso_clock_gettime (clockid_t clock,struct old_timespec32 *ts) { -int ret =__cvdso_clock_gettime32 (clock, ts); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_clock_gettime32 (vd, clock, ts);if (likely (!ret))return ret;
@@ -25,7 +26,8 @@ int __vdso_clock_gettime(clockid_t clock,int __vdso_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz) { -int ret =__cvdso_gettimeofday (tv, tz); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_gettimeofday (vd, tv, tz);if (likely (!ret))return ret;
@@ -36,7 +38,8 @@ int __vdso_gettimeofday(struct __kernel_old_timeval *tv,int __vdso_clock_getres (clockid_t clock_id,struct old_timespec32 *res) { -int ret =__cvdso_clock_getres_time32 (clock_id, res); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_clock_getres_time32 (vd, clock_id, res);if (likely (!ret))return ret;
@@ -47,7 +50,8 @@ int __vdso_clock_getres(clockid_t clock_id,int __vdso_clock_gettime64 (clockid_t clock,struct __kernel_timespec *ts) { -int ret =__cvdso_clock_gettime (clock, ts); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_clock_gettime (vd, clock, ts);if (likely (!ret))return ret;
@@ -60,7 +64,8 @@ int __vdso_clock_gettime64(clockid_t clock,int __vdso_clock_gettime (clockid_t clock,struct __kernel_timespec *ts) { -int ret =__cvdso_clock_gettime (clock, ts); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_clock_gettime (vd, clock, ts);if (likely (!ret))return ret;
@@ -71,7 +76,8 @@ int __vdso_clock_gettime(clockid_t clock,int __vdso_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz) { -int ret =__cvdso_gettimeofday (tv, tz); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_gettimeofday (vd, tv, tz);if (likely (!ret))return ret;
@@ -82,7 +88,8 @@ int __vdso_gettimeofday(struct __kernel_old_timeval *tv,int __vdso_clock_getres (clockid_t clock_id,struct __kernel_timespec *res) { -int ret =__cvdso_clock_getres (clock_id, res); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_clock_getres (vd, clock_id, res);if (likely (!ret))return ret;
arch/x86/entry/vdso/vclock_gettime.c +15 -7
@@ -19,7 +19,8 @@ extern __kernel_old_time_t __vdso_time(__kernel_old_time_t *t);int __vdso_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz) { -int ret =__cvdso_gettimeofday (tv, tz); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_gettimeofday (vd, tv, tz);if (likely (!ret))return ret;
@@ -32,7 +33,9 @@ int gettimeofday(struct __kernel_old_timeval *, struct timezone *)__kernel_old_time_t __vdso_time (__kernel_old_time_t *t) { -return __cvdso_time (t); +const struct vdso_data *vd =__arch_get_vdso_data (); + +return __cvdso_time (vd, t); }__kernel_old_time_t time (__kernel_old_time_t *t) __attribute__((weak,alias ("__vdso_time" )));
@@ -45,7 +48,8 @@ extern int __vdso_clock_getres(clockid_t clock, struct __kernel_timespec *res);int __vdso_clock_gettime (clockid_t clock,struct __kernel_timespec *ts) { -int ret =__cvdso_clock_gettime (clock, ts); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_clock_gettime (vd, clock, ts);if (likely (!ret))return ret;
@@ -59,7 +63,8 @@ int clock_gettime(clockid_t, struct __kernel_timespec *)int __vdso_clock_getres (clockid_t clock,struct __kernel_timespec *res) { -int ret =__cvdso_clock_getres (clock_id, res); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_clock_getres (vd, clock_id, res);if (likely (!ret))return ret;
@@ -76,7 +81,8 @@ extern int __vdso_clock_getres(clockid_t clock, struct old_timespec32 *res);int __vdso_clock_gettime (clockid_t clock,struct old_timespec32 *ts) { -int ret =__cvdso_clock_gettime32 (clock, ts); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_clock_gettime32 (vd, clock, ts);if (likely (!ret))return ret;
@@ -89,7 +95,8 @@ int clock_gettime(clockid_t, struct old_timespec32 *)int __vdso_clock_gettime64 (clockid_t clock,struct __kernel_timespec *ts) { -int ret =__cvdso_clock_gettime (clock, ts); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_clock_gettime (vd, clock, ts);if (likely (!ret))return ret;
@@ -102,7 +109,8 @@ int clock_gettime64(clockid_t, struct __kernel_timespec *)int __vdso_clock_getres (clockid_t clock,struct old_timespec32 *res) { -int ret =__cvdso_clock_getres_time32 (clock, res); +const struct vdso_data *vd =__arch_get_vdso_data (); +int ret =__cvdso_clock_getres_time32 (vd, clock, res);if (likely (!ret))return ret;
lib/vdso/gettimeofday.c +14 -14
@@ -13,7 +13,6 @@/* * The generic vDSO implementation requires that gettimeofday.h * provides: -* - __arch_get_vdso_data(): to get the vdso datapage. * - __arch_get_hw_counter(): to get the hw counter based on the * clock_mode. */
@@ -79,9 +78,9 @@ static void do_coarse(const struct vdso_data *vd, clockid_t clk, }static __maybe_unused int -__cvdso_clock_gettime (clockid_t clock,struct __kernel_timespec *ts) +__cvdso_clock_gettime (const struct vdso_data *vd,clockid_t clock, +struct __kernel_timespec *ts) { -const struct vdso_data *vd =__arch_get_vdso_data ();u32 msk;/* Check for negative values or invalid clocks */
@@ -105,10 +104,11 @@ __cvdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts) }static __maybe_unused int -__cvdso_clock_gettime32 (clockid_t clock,struct old_timespec32 *res) +__cvdso_clock_gettime32 (const struct vdso_data *vd,clockid_t clock, +struct old_timespec32 *res) {struct __kernel_timespec ts; -int ret =__cvdso_clock_gettime (clock, &ts); +int ret =__cvdso_clock_gettime (vd, clock, &ts);if (likely (!ret)) { res->tv_sec = ts.tv_sec;
@@ -118,10 +118,9 @@ __cvdso_clock_gettime32(clockid_t clock, struct old_timespec32 *res) }static __maybe_unused int -__cvdso_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz) +__cvdso_gettimeofday (const struct vdso_data *vd,struct __kernel_old_timeval *tv, +struct timezone *tz) { -const struct vdso_data *vd =__arch_get_vdso_data (); -if (likely (tv !=NULL )) {struct __kernel_timespec ts;
@@ -141,9 +140,9 @@ __cvdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) }#ifdef VDSO_HAS_TIME -static __maybe_unused __kernel_old_time_t __cvdso_time (__kernel_old_time_t *time) +static __maybe_unused __kernel_old_time_t +__cvdso_time (const struct vdso_data *vd,__kernel_old_time_t *time) { -const struct vdso_data *vd =__arch_get_vdso_data ();__kernel_old_time_t t =READ_ONCE (vd[CS_HRES_COARSE ].basetime[CLOCK_REALTIME ].sec);if (time)
@@ -155,9 +154,9 @@ static __maybe_unused __kernel_old_time_t __cvdso_time(__kernel_old_time_t *time#ifdef VDSO_HAS_CLOCK_GETRES static __maybe_unused -int __cvdso_clock_getres (clockid_t clock,struct __kernel_timespec *res) +int __cvdso_clock_getres (const struct vdso_data *vd,clockid_t clock, +struct __kernel_timespec *res) { -const struct vdso_data *vd =__arch_get_vdso_data ();u64 hrtimer_res;u32 msk;u64 ns;
@@ -199,10 +198,11 @@ int __cvdso_clock_getres(clockid_t clock, struct __kernel_timespec *res) }static __maybe_unused int -__cvdso_clock_getres_time32 (clockid_t clock,struct old_timespec32 *res) +__cvdso_clock_getres_time32 (const struct vdso_data *vd,clockid_t clock, +struct old_timespec32 *res) {struct __kernel_timespec ts; -int ret =__cvdso_clock_getres (clock, &ts); +int ret =__cvdso_clock_getres (vd, clock, &ts);if (likely (!ret && res)) { res->tv_sec = ts.tv_sec;
Signature · 1 line
2.13.3
Andy Lutomirski
maintainerRe: [RFC PATCH v2 04/10] lib: vdso: get pointer to vdso data from the arch
Quoted 7 lines · Christophe Leroy
On powerpc,
__arch_get_vdso_data()clobbers the link register, requiring the caller to set a stack frame in order to save it.As the parent function already has to set a stack frame and save the link register to call the C vdso function, retriving the vdso data pointer there is lighter.
I'm confused. Can't you inline __arch_get_vdso_data()? Or is the issue that you can't retrieve the program counter on power without clobbering the link register?
I would imagine that this patch generates worse code on any architecture with PC-relative addressing modes (which includes at least x86_64, and I would guess includes most modern architectures).
--Andy
Re: [RFC PATCH v2 04/10] lib: vdso: get pointer to vdso data from the arch
Le 24/12/2019 à 03:27, Andy Lutomirski a écrit :
Quoted 6 lines
Quoted 4 lines · Christophe Leroy
On powerpc,
__arch_get_vdso_data()clobbers the link register, requiring the caller to set a stack frame in order to save it.
Quoted 7 lines
Quoted 3 lines
As the parent function already has to set a stack frame and save the link register to call the C vdso function, retriving the vdso data pointer there is lighter.
I'm confused. Can't you inline
__arch_get_vdso_data()? Or is the issue that you can't retrieve the program counter on power without clobbering the link register?
Yes it can be inlined (I did it in V1 https://patchwork.ozlabs.org/patch/1180571/), but you can't do it without clobbering the link register, because the only way to get the program counter is to do to as if you were calling another function but you call to the address which just follows where you are, so that it sets LR which the simulated return address which corresponds to the address following the branch.
static __always_inline
const struct vdso_data *__arch_get_vdso_data(void)
{
void *ptr;
asm volatile(
" bcl 20, 31, .+4;\n"
" mflr %0;\n"
" addi %0, %0, __kernel_datapage_offset - (.-4);\n"
: "=b"(ptr) : : "lr");
return ptr + *(unsigned long *)ptr;
}Quoted 4 lines
I would imagine that this patch generates worse code on any architecture with PC-relative addressing modes (which includes at least
x86_64, and I would guess includes most modern architectures).
Why ? Powerpc is also using PC-relative addressing for all calls but indirect calls.
As the other arch C VDSO callers are in C and written in such a way that callee is inlined into callers, and as __arch_get_vdso_data() is inlined, it should make no difference, shouldn't it ?
Christophe
Re: [RFC PATCH v2 04/10] lib: vdso: get pointer to vdso data from the arch
Quoted 36 lines · christophe leroy
Quoted 7 lines · Andy Lutomirski
Quoted 6 lines
On Mon, Dec 23, 2019 at 6:31 AM Christophe Leroy
<[email protected]> wrote:On powerpc,
__arch_get_vdso_data()clobbers the link register, requiring the caller to set a stack frame in order to save it.Quoted 6 lines
Quoted 3 lines
As the parent function already has to set a stack frame and save the link register to call the C vdso function, retriving the vdso data pointer there is lighter.
I'm confused. Can't you inline
__arch_get_vdso_data()? Or is the issue that you can't retrieve the program counter on power without clobbering the link register?Yes it can be inlined (I did it in V1 https://patchwork.ozlabs.org/patch/1180571/), but you can't do it without clobbering the link register, because the only way to get the program counter is to do to as if you were calling another function but you call to the address which just follows where you are, so that it sets LR which the simulated return address which corresponds to the address following the branch.
static
__always_inline
const structvdso_data*__arch_get_vdso_data(void){ void *ptr; asm volatile( " bcl 20, 31, .+4;\n" " mflr %0;\n" " addi %0, %0, __kernel_datapage_offset - (.-4);\n" : "=b"(ptr) : : "lr"); return ptr + *(unsigned long *)ptr; }
Quoted 5 lines
Quoted 3 lines
I would imagine that this patch generates worse code on any architecture with PC-relative addressing modes (which includes at least
x86_64, and I would guess includes most modern architectures).Why ? Powerpc is also using PC-relative addressing for all calls but indirect calls.
I mean PC-relative access for data. The data page is at a constant, known offset from the vDSO text.
I haven’t checked how much x86_64 benefits from this, but at least the non-array fields ought to be accessible with a PC-relative access.
It should be possible to refactor a little bit so that the compiler can still see what’s going on. Maybe your patch actually does this. I’d want to look at the assembly. This also might not matter much on x86_64 in particular, since x86_64 can convert a PC-relative address to an absolute address with a single instruction with no clobbers.
Does power have PC-relative data access? If so, I wonder if the code can be arranged so that even the array accesses don’t require computing an absolute address at any point.
Andy Lutomirski
maintainerRe: [RFC PATCH v2 04/10] lib: vdso: get pointer to vdso data from the arch
Quoted 43 lines · Andy Lutomirski
Quoted 37 lines · christophe leroy
Quoted 7 lines · Andy Lutomirski
Quoted 6 lines
On Mon, Dec 23, 2019 at 6:31 AM Christophe Leroy
<[email protected]> wrote:On powerpc,
__arch_get_vdso_data()clobbers the link register, requiring the caller to set a stack frame in order to save it.Quoted 6 lines
Quoted 3 lines
As the parent function already has to set a stack frame and save the link register to call the C vdso function, retriving the vdso data pointer there is lighter.
I'm confused. Can't you inline
__arch_get_vdso_data()? Or is the issue that you can't retrieve the program counter on power without clobbering the link register?Yes it can be inlined (I did it in V1 https://patchwork.ozlabs.org/patch/1180571/), but you can't do it without clobbering the link register, because the only way to get the program counter is to do to as if you were calling another function but you call to the address which just follows where you are, so that it sets LR which the simulated return address which corresponds to the address following the branch.
static
__always_inline
const structvdso_data*__arch_get_vdso_data(void){ void *ptr; asm volatile( " bcl 20, 31, .+4;\n" " mflr %0;\n" " addi %0, %0, __kernel_datapage_offset - (.-4);\n" : "=b"(ptr) : : "lr"); return ptr + *(unsigned long *)ptr; }Quoted 5 lines
Quoted 3 lines
I would imagine that this patch generates worse code on any architecture with PC-relative addressing modes (which includes at least
x86_64, and I would guess includes most modern architectures).Why ? Powerpc is also using PC-relative addressing for all calls but indirect calls.
Quoted 7 lines
I mean PC-relative access for data. The data page is at a constant, known offset from the vDSO text.
I haven’t checked how much
x86_64benefits from this, but at least the non-array fields ought to be accessible with a PC-relative access.It should be possible to refactor a little bit so that the compiler can still see what’s going on. Maybe your patch actually does this. I’d want to look at the assembly. This also might not matter much on
x86_64in particular, sincex86_64can convert a PC-relative address to an absolute address with a single instruction with no clobbers.Does power have PC-relative data access? If so, I wonder if the code can be arranged so that even the array accesses don’t require computing an absolute address at any point.
Indeed the x86 code is also suboptimal, but at least the unnecessary absolute address calculation is cheap on x86_64. Ideally we'd pass around offsets into the vdso data instead of passing pointers, and maybe the compiler will figure it out. I can try to play with this in the morning.
Re: [RFC PATCH v2 04/10] lib: vdso: get pointer to vdso data from the arch
In reply to Andy LutomirskiQuoted 1 line · Andy Lutomirski
Does power have PC-relative data access? If so, I wonder if the code can be arranged so that even the array accesses don’t require computing an absolute address at any point.
Not before ISA 3.0 (that is Power9).
The bcl/mflr dance isn't *that* expensive, if you use it sparingly.
Segher
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
RFC PATCH v2 5/10 lib: vdso: inline do_hres()
In reply to Christophe Leroydo_hres() is called from several places, so GCC doesn't inline it at first.
do_hres() takes a struct __kernel_timespec * parameter for passing the result. In the 32 bits case, this parameter corresponds to a local var in the caller. In order to provide a pointer to this structure, the caller has to put it in its stack and do_hres() has to write the result in the stack. This is suboptimal, especially on RISC processor like powerpc.
By making GCC inline the function, the struct __kernel_timespec remains a local var using registers, avoiding the need to write and read stack.
The improvement is significant on powerpc.
--- lib/vdso/gettimeofday.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/vdso/gettimeofday.c +2 -2
@@ -34,8 +34,8 @@ u64 vdso_calc_delta(u64 cycles, u64 last, u64 mask, u32 mult) }#endif -static int do_hres (const struct vdso_data *vd,clockid_t clk, -struct __kernel_timespec *ts) +static inline int do_hres (const struct vdso_data *vd,clockid_t clk, +struct __kernel_timespec *ts) {const struct vdso_timestamp *vdso_ts = &vd->basetime[clk];u64 cycles, last, sec, ns;
Signature · 1 line
2.13.3
Andy Lutomirski
maintainerRe: [RFC PATCH v2 05/10] lib: vdso: inline do_hres()
Quoted 11 lines · Christophe Leroy
do_hres()is called from several places, so GCC doesn't inline it at first.
do_hres()takes a struct__kernel_timespec* parameter for passing the result. In the 32 bits case, this parameter corresponds to a local var in the caller. In order to provide a pointer to this structure, the caller has to put it in its stack anddo_hres()has to write the result in the stack. This is suboptimal, especially on RISC processor like powerpc.
Quoted 5 lines
By making GCC inline the function, the struct
__kernel_timespecremains a local var using registers, avoiding the need to write and read stack.The improvement is significant on powerpc.
I'm okay with it, mainly because I don't expect many workloads to have more than one copy of the code hot at the same time.
Re: [RFC PATCH v2 05/10] lib: vdso: inline do_hres()
In reply to Christophe LeroyQuoted 11 lines · Christophe Leroy
do_hres()is called from several places, so GCC doesn't inline it at first.
do_hres()takes a struct__kernel_timespec* parameter for passing the result. In the 32 bits case, this parameter corresponds to a local var in the caller. In order to provide a pointer to this structure, the caller has to put it in its stack anddo_hres()has to write the result in the stack. This is suboptimal, especially on RISC processor like powerpc.
Quoted 7 lines
By making GCC inline the function, the struct
__kernel_timespecremains a local var using registers, avoiding the need to write and read stack.The improvement is significant on powerpc.
Signed-off-by Christophe Leroy <[email protected]>
Good idea, I can see how this ends up being an improvement for most of the callers.
Re: [RFC PATCH v2 05/10] lib: vdso: inline do_hres()
Quoted 17 lines · Arnd Bergmann
Quoted 15 lines · Christophe Leroy
do_hres()is called from several places, so GCC doesn't inline it at first.
do_hres()takes a struct__kernel_timespec* parameter for passing the result. In the 32 bits case, this parameter corresponds to a local var in the caller. In order to provide a pointer to this structure, the caller has to put it in its stack anddo_hres()has to write the result in the stack. This is suboptimal, especially on RISC processor like powerpc.By making GCC inline the function, the struct
__kernel_timespecremains a local var using registers, avoiding the need to write and read stack.
Quoted 8 lines
Quoted 3 lines
The improvement is significant on powerpc.
Signed-off-by Christophe Leroy <[email protected]>Good idea, I can see how this ends up being an improvement for most of the callers.
Acked-by Arnd Bergmann <[email protected]>
https://lore.kernel.org/r/[email protected]
On the way to be applied.
Thanks,
tglx
Re: [RFC PATCH v2 05/10] lib: vdso: inline do_hres()
Quoted 22 lines · Thomas Gleixner
Quoted 21 lines · Arnd Bergmann
Quoted 18 lines · Christophe Leroy
do_hres()is called from several places, so GCC doesn't inline it at first.
do_hres()takes a struct__kernel_timespec* parameter for passing the result. In the 32 bits case, this parameter corresponds to a local var in the caller. In order to provide a pointer to this structure, the caller has to put it in its stack anddo_hres()has to write the result in the stack. This is suboptimal, especially on RISC processor like powerpc.By making GCC inline the function, the struct
__kernel_timespecremains a local var using registers, avoiding the need to write and read stack.The improvement is significant on powerpc.
Signed-off-by Christophe Leroy <[email protected]>
Quoted 9 lines
Quoted 4 lines
Good idea, I can see how this ends up being an improvement for most of the callers.
Acked-by Arnd Bergmann <[email protected]>https://lore.kernel.org/r/[email protected]On the way to be applied.
Oh nice, I get even better result with the way it is done by Dmitry compared to my own first patch.
On an mpc8xx at 132Mhz (32bits powerpc), before the patch I have
gettimeofday: vdso: 1256 nsec/call clock-gettime-monotonic-raw: vdso: 1449 nsec/call clock-gettime-monotonic-coarse: vdso: 768 nsec/call clock-gettime-monotonic: vdso: 1390 nsec/call
With the patch I have:
gettimeofday: vdso: 947 nsec/call clock-gettime-monotonic-raw: vdso: 1156 nsec/call clock-gettime-monotonic-coarse: vdso: 638 nsec/call clock-gettime-monotonic: vdso: 1094 nsec/call
So that's a 20-25% improvement.
I modified it slightly as follows:
lib/vdso/gettimeofday.c +16 -13
@@ -37,8 +37,8 @@ u64 vdso_calc_delta(u64 cycles, u64 last, u64 mask, u32 mult) }#endif -static int do_hres (const struct vdso_data *vd,clockid_t clk, -struct __kernel_timespec *ts) +static __always_inline int do_hres(const struct vdso_data *vd, clockid_t clk, +struct __kernel_timespec *ts) {const struct vdso_timestamp *vdso_ts = &vd->basetime[clk];u64 cycles, last, sec, ns;
@@ -67,8 +67,8 @@ static int do_hres(const struct vdso_data *vd, clockid_t clk,return 0 ; } -static void do_coarse (const struct vdso_data *vd,clockid_t clk, -struct __kernel_timespec *ts) +static __always_inline int do_coarse(const struct vdso_data *vd, clockid_t clk, +struct __kernel_timespec *ts) {const struct vdso_timestamp *vdso_ts = &vd->basetime[clk];u32 seq;
@@ -78,6 +78,8 @@ static void do_coarse(const struct vdso_data *vd, clockid_t clk, ts->tv_sec = vdso_ts->sec; ts->tv_nsec = vdso_ts->nsec; }while (unlikely (vdso_read_retry (vd, seq))); + +return 0 ; } static __maybe_unused int
@@ -95,15 +97,16 @@ __cvdso_clock_gettime_common(const struct vdso_data *vd, clockid_t clock,* clocks are handled in the VDSO directly. */ msk =1U << clock; -if (likely (msk &VDSO_HRES )) { -return do_hres (&vd[CS_HRES_COARSE ], clock, ts); - }else if (msk &VDSO_COARSE ) { -do_coarse (&vd[CS_HRES_COARSE ], clock, ts); -return 0 ; - }else if (msk &VDSO_RAW ) { -return do_hres (&vd[CS_RAW ], clock, ts); - } -return -1 ; +if (likely (msk &VDSO_HRES )) + vd +=CS_HRES_COARSE ; +else if (msk &VDSO_COARSE ) +return do_coarse (&vd[CS_HRES_COARSE ], clock, ts); +else if (msk &VDSO_RAW ) + vd +=CS_RAW ; +else +return -1 ; + +return do_hres (vd, clock, ts); } static __maybe_unused int
---
Christophe
RFC PATCH v2 6/10 lib: vdso: make do_coarse() return 0
In reply to Christophe Leroydo_coarse() is similare to do_hres() except that it never fails.
Change its type to int instead of void and get it return 0 at all time. This cleans the code a bit.
--- lib/vdso/gettimeofday.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
lib/vdso/gettimeofday.c +8 -7
@@ -64,7 +64,7 @@ static inline int do_hres(const struct vdso_data *vd, clockid_t clk,return 0 ; } -static void do_coarse (const struct vdso_data *vd,clockid_t clk, +static int do_coarse (const struct vdso_data *vd,clockid_t clk,struct __kernel_timespec *ts) {const struct vdso_timestamp *vdso_ts = &vd->basetime[clk];
@@ -75,6 +75,8 @@ static void do_coarse(const struct vdso_data *vd, clockid_t clk, ts->tv_sec = vdso_ts->sec; ts->tv_nsec = vdso_ts->nsec; }while (unlikely (vdso_read_retry (vd, seq))); + +return 0 ; } static __maybe_unused int
@@ -92,14 +94,13 @@ __cvdso_clock_gettime(const struct vdso_data *vd, clockid_t clock,* clocks are handled in the VDSO directly. */ msk =1U << clock; -if (likely (msk &VDSO_HRES )) { +if (likely (msk &VDSO_HRES ))return do_hres (&vd[CS_HRES_COARSE ], clock, ts); - }else if (msk &VDSO_COARSE ) { -do_coarse (&vd[CS_HRES_COARSE ], clock, ts); -return 0 ; - }else if (msk &VDSO_RAW ) { +else if (msk &VDSO_COARSE ) +return do_coarse (&vd[CS_HRES_COARSE ], clock, ts); +else if (msk &VDSO_RAW )return do_hres (&vd[CS_RAW ], clock, ts); - } +return -1 ; }
Signature · 1 line
2.13.3
RFC PATCH v2 7/10 lib: vdso: don't use READ_ONCE() in __c_kernel_time()
In reply to Christophe LeroyREAD_ONCE() forces the read of the 64 bit value of vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec allthough only the lower part is needed.
This results in a suboptimal code:
00000af4 <__c_kernel_time>:
af4: 2c 03 00 00 cmpwi r3,0 af8: 81 44 00 20 lwz r10,32(r4) afc: 81 64 00 24 lwz r11,36(r4) b00: 41 82 00 08 beq b08 <__c_kernel_time+0x14> b04: 91 63 00 00 stw r11,0(r3) b08: 7d 63 5b 78 mr r3,r11
b0c: 4e 80 00 20 blr
By removing the READ_ONCE(), only the lower part is read from memory, and the code is cleaner:
00000af4 <__c_kernel_time>:
af4: 7c 69 1b 79 mr. r9,r3
af8: 80 64 00 24 lwz r3,36(r4)
afc: 4d 82 00 20 beqlr
b00: 90 69 00 00 stw r3,0(r9)
b04: 4e 80 00 20 blr
--- lib/vdso/gettimeofday.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/vdso/gettimeofday.c +1 -1
@@ -144,7 +144,7 @@ __cvdso_gettimeofday(const struct vdso_data *vd, struct __kernel_old_timeval *tvstatic __maybe_unused __kernel_old_time_t __cvdso_time (const struct vdso_data *vd,__kernel_old_time_t *time) { -__kernel_old_time_t t =READ_ONCE (vd[CS_HRES_COARSE ].basetime[CLOCK_REALTIME ].sec); +__kernel_old_time_t t = vd[CS_HRES_COARSE ].basetime[CLOCK_REALTIME ].sec;if (time) *time = t;
Signature · 1 line
2.13.3
Re: [RFC PATCH v2 07/10] lib: vdso: don't use READ_ONCE() in __c_kernel_time()
Quoted 4 lines · Christophe Leroy
READ_ONCE()forces the read of the 64 bit value of vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec allthough only the lower part is needed.
Seems reasonable and very unlikely to be harmful. That being said, this function really ought to be considered deprecated -- 32-bit time_t is insufficient.
Do you get even better code if you move the read into the if statement?
--Andy
Re: [RFC PATCH v2 07/10] lib: vdso: don't use READ_ONCE() in __c_kernel_time()
Le 24/12/2019 à 02:58, Andy Lutomirski a écrit :
Quoted 7 lines
Quoted 4 lines · Christophe Leroy
READ_ONCE()forces the read of the 64 bit value of vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec allthough only the lower part is needed.
Quoted 5 lines
Seems reasonable and very unlikely to be harmful. That being said, this function really ought to be considered deprecated -- 32-bit
time_tis insufficient.Do you get even better code if you move the read into the if statement?
Euh ...
How can you return t when time pointer is NULL if you read t only when time pointer is not NULL ?
Christophe
Re: [RFC PATCH v2 07/10] lib: vdso: don't use READ_ONCE() in __c_kernel_time()
Quoted 12 lines · christophe leroy
Quoted 7 lines · Andy Lutomirski
Quoted 6 lines
On Mon, Dec 23, 2019 at 6:31 AM Christophe Leroy
<[email protected]> wrote:
READ_ONCE()forces the read of the 64 bit value of vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec allthough only the lower part is needed.
Quoted 10 lines
Quoted 4 lines
Seems reasonable and very unlikely to be harmful. That being said, this function really ought to be considered deprecated -- 32-bit
time_tis insufficient.
Do you get even better code if you move the read into the if statement?Euh ...
How can you return t when time pointer is NULL if you read t only when time pointer is not NULL ?
Duh, never mind.
But this means your patch may be buggy: you need to make sure the compiler returns the *same* value it stores. Maybe you’re saved by the potential aliasing between the data page and the passed parameter and the value you read, but that’sa bad thing to rely on.
Try barrier() after the read.
Re: [RFC PATCH v2 07/10] lib: vdso: don't use READ_ONCE() in __c_kernel_time()
In reply to Christophe LeroyQuoted 6 lines · Christophe Leroy
lib/vdso/gettimeofday.c +0
-0
lib/vdso/gettimeofday.c __cvdso_gettimeofday(const struct vdso_data *vd, struct __kernel_old_timeval *tv · line 150
Quoted 8 lines
lib/vdso/gettimeofday.c +1
-1@@ -144,7 +144,7 @@ __cvdso_gettimeofday(const struct vdso_data *vd, struct __kernel_old_timeval *tvstatic __maybe_unused __kernel_old_time_t __cvdso_time (const struct vdso_data *vd,__kernel_old_time_t *time) { -__kernel_old_time_t t =READ_ONCE (vd[CS_HRES_COARSE ].basetime[CLOCK_REALTIME ].sec); +__kernel_old_time_t t = vd[CS_HRES_COARSE ].basetime[CLOCK_REALTIME ].sec;if (time) *time = t;
Allows the compiler to load twice, i.e. the returned value might be different from the stored value. So no.
Thanks,
tglx
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [RFC PATCH v2 07/10] lib: vdso: don't use READ_ONCE() in __c_kernel_time()
Quoted 13 lines · Thomas Gleixner
Quoted 12 lines · Christophe Leroy
lib/vdso/gettimeofday.c +1
-1@@ -144,7 +144,7 @@ __cvdso_gettimeofday(const struct vdso_data *vd, struct __kernel_old_timeval *tvstatic __maybe_unused __kernel_old_time_t __cvdso_time (const struct vdso_data *vd,__kernel_old_time_t *time) { -__kernel_old_time_t t =READ_ONCE (vd[CS_HRES_COARSE ].basetime[CLOCK_REALTIME ].sec); +__kernel_old_time_t t = vd[CS_HRES_COARSE ].basetime[CLOCK_REALTIME ].sec;
Quoted 6 lines
lib/vdso/gettimeofday.c __cvdso_gettimeofday(const struct vdso_data *vd, struct __kernel_old_timeval *tv · line 150
Quoted 2 lines
lib/vdso/gettimeofday.c +0
-0if (time) *time = t;Allows the compiler to load twice, i.e. the returned value might be different from the stored value. So no.
With READ_ONCE() the 64 bits are being read:
00000ac8 <__c_kernel_time>:
ac8: 2c 03 00 00 cmpwi r3,0 acc: 81 44 00 20 lwz r10,32(r4) ad0: 81 64 00 24 lwz r11,36(r4) ad4: 41 82 00 08 beq adc <__c_kernel_time+0x14> ad8: 91 63 00 00 stw r11,0(r3) adc: 7d 63 5b 78 mr r3,r11
ae0: 4e 80 00 20 blr
Without the READ_ONCE() only 32 bits are read. That's the most optimal.
00000ac8 <__c_kernel_time>:
ac8: 7c 69 1b 79 mr. r9,r3
acc: 80 64 00 24 lwz r3,36(r4)
ad0: 4d 82 00 20 beqlr
ad4: 90 69 00 00 stw r3,0(r9)
ad8: 4e 80 00 20 blr
Without READ_ONCE() but with a barrier() after the read, we should get the same result but GCC (GCC 8.1) does less good:
00000ac8 <__c_kernel_time>:
ac8: 81 24 00 24 lwz r9,36(r4) acc: 2f 83 00 00 cmpwi cr7,r3,0 ad0: 41 9e 00 08 beq cr7,ad8 <__c_kernel_time+0x10> ad4: 91 23 00 00 stw r9,0(r3) ad8: 7d 23 4b 78 mr r3,r9
adc: 4e 80 00 20 blr
Assuming both part of the 64 bits data will fall into a single cacheline, the second read is in the noise.
So agreed to drop this change.
Christophe
Re: [RFC PATCH v2 07/10] lib: vdso: don't use READ_ONCE() in __c_kernel_time()
Quoted 10 lines · Christophe Leroy
With
READ_ONCE()the 64 bits are being read:Without the
READ_ONCE()only 32 bits are read. That's the most optimal.Without
READ_ONCE()but with abarrier()after the read, we should get the same result but GCC (GCC 8.1) does less good:Assuming both part of the 64 bits data will fall into a single cacheline, the second read is in the noise.
They definitely are in the same cacheline.
Quoted 1 line
So agreed to drop this change.
We could be smart about this and force the compiler to issue a 32bit read for 32bit builds. See below. Not sure whether it's worth it, but OTOH it will take quite a while until the 32bit time interfaces die completely.
Thanks,
tglx
8<------------
include/vdso/datapage.h +16 -1
@@ -21,6 +21,18 @@#define CS_RAW 1#define CS_BASES (CS_RAW + 1) +#ifdef __LITTLE_ENDIAN +struct sec_hl { +u32 sec_l; +u32 sec_h; +}; +#else +struct sec_hl { +u32 sec_h; +u32 sec_l; +}; +#endif +/** * struct vdso_timestamp - basetime per clock_id * @sec: seconds
@@ -35,7 +47,10 @@* vdso_data.cs[x].shift. */ struct vdso_timestamp { -u64 sec; +union { +u64 sec; +struct sec_hl sec_hl; + };u64 nsec; };
lib/vdso/gettimeofday.c +6 -1
@@ -165,8 +165,13 @@ static __maybe_unused intstatic __maybe_unused __kernel_old_time_t __cvdso_time (__kernel_old_time_t *time) {const struct vdso_data *vd =__arch_get_vdso_data (); -__kernel_old_time_t t =READ_ONCE (vd[CS_HRES_COARSE ].basetime[CLOCK_REALTIME ].sec); +__kernel_old_time_t t; +#if BITS_PER_LONG ==32 + t =READ_ONCE (vd[CS_HRES_COARSE ].basetime[CLOCK_REALTIME ].sec_hl.sec_l); +#else + t =READ_ONCE (vd[CS_HRES_COARSE ].basetime[CLOCK_REALTIME ].sec); +#endif if (time) *time = t;
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [RFC PATCH v2 07/10] lib: vdso: don't use READ_ONCE() in __c_kernel_time()
Le 11/01/2020 à 12:07, Thomas Gleixner a écrit :
Quoted 12 lines
Quoted 10 lines · Christophe Leroy
With
READ_ONCE()the 64 bits are being read:Without the
READ_ONCE()only 32 bits are read. That's the most optimal.Without
READ_ONCE()but with abarrier()after the read, we should get the same result but GCC (GCC 8.1) does less good:Assuming both part of the 64 bits data will fall into a single cacheline, the second read is in the noise.
Quoted 8 lines
They definitely are in the same cacheline.
Quoted 1 line
So agreed to drop this change.
We could be smart about this and force the compiler to issue a 32bit read for 32bit builds. See below. Not sure whether it's worth it, but OTOH it will take quite a while until the 32bit time interfaces die completely.
I don't think it is worth something so big to just save 1 or 2 cycles in time() function. Lets keep it as it is.
Thanks,
Christophe
Quoted 57 lines
Thanks,
tglx
8<------------
include/vdso/datapage.h +16
-1@@ -21,6 +21,18 @@#define CS_RAW 1#define CS_BASES (CS_RAW + 1) +#ifdef __LITTLE_ENDIAN +struct sec_hl { +u32 sec_l; +u32 sec_h; +}; +#else +struct sec_hl { +u32 sec_h; +u32 sec_l; +}; +#endif +/** * struct vdso_timestamp - basetime per clock_id * @sec: seconds @@ -35,7 +47,10 @@* vdso_data.cs[x].shift. */ struct vdso_timestamp { -u64 sec; +union { +u64 sec; +struct sec_hl sec_hl; + };u64 nsec; };lib/vdso/gettimeofday.c +6
-1@@ -165,8 +165,13 @@ static __maybe_unused intstatic __maybe_unused __kernel_old_time_t __cvdso_time (__kernel_old_time_t *time) {const struct vdso_data *vd =__arch_get_vdso_data (); -__kernel_old_time_t t =READ_ONCE (vd[CS_HRES_COARSE ].basetime[CLOCK_REALTIME ].sec); +__kernel_old_time_t t; +#if BITS_PER_LONG ==32 + t =READ_ONCE (vd[CS_HRES_COARSE ].basetime[CLOCK_REALTIME ].sec_hl.sec_l); +#else + t =READ_ONCE (vd[CS_HRES_COARSE ].basetime[CLOCK_REALTIME ].sec); +#endif if (time) *time = t;
RFC PATCH v2 8/10 lib: vdso: Avoid duplication in __cvdso_clock_getres()
In reply to Christophe LeroyVDSO_HRES and VDSO_RAW clocks are handled the same way.
Don't duplicate code.
--- lib/vdso/gettimeofday.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
lib/vdso/gettimeofday.c +1 -6
@@ -172,7 +172,7 @@ int __cvdso_clock_getres(const struct vdso_data *vd, clockid_t clock,* clocks are handled in the VDSO directly. */ msk =1U << clock; -if (msk &VDSO_HRES ) { +if (msk & (VDSO_HRES |VDSO_RAW )) {/* * Preserves the behaviour of posix_get_hrtimer_res(). */
@@ -182,11 +182,6 @@ int __cvdso_clock_getres(const struct vdso_data *vd, clockid_t clock,* Preserves the behaviour of posix_get_coarse_res(). */ ns =LOW_RES_NSEC ; - }else if (msk &VDSO_RAW ) { -/* -* Preserves the behaviour of posix_get_hrtimer_res(). -*/ - ns = hrtimer_res; }else {return -1 ; }
Signature · 1 line
2.13.3
Re: [RFC PATCH v2 08/10] lib: vdso: Avoid duplication in __cvdso_clock_getres()
Quoted 6 lines · Christophe Leroy
VDSO_HRESandVDSO_RAWclocks are handled the same way.Don't duplicate code.
Signed-off-by Christophe Leroy <[email protected]>
RFC PATCH v2 9/10 powerpc/vdso32: inline __get_datapage()
In reply to Christophe Leroy__get_datapage() is only a few instructions to retrieve the address of the page where the kernel stores data to the VDSO.
By inlining this function into its users, a bl/blr pair and a mflr/mtlr pair is avoided, plus a few reg moves.
The improvement is noticeable (about 55 nsec/call on an 8xx)
vdsotest before the patch:
gettimeofday: vdso: 731 nsec/call clock-gettime-realtime-coarse: vdso: 668 nsec/call clock-gettime-monotonic-coarse: vdso: 745 nsec/call
vdsotest after the patch:
gettimeofday: vdso: 677 nsec/call clock-gettime-realtime-coarse: vdso: 613 nsec/call clock-gettime-monotonic-coarse: vdso: 690 nsec/call
---
v3: define get_datapage macro in asm/vdso_datapage.h
v4: fixed build failure with old binutils
--- arch/powerpc/include/asm/vdso_datapage.h | 10 ++++++++++ arch/powerpc/kernel/vdso32/cacheflush.S | 9 ++++----- arch/powerpc/kernel/vdso32/datapage.S | 28 +++------------------------- arch/powerpc/kernel/vdso32/gettimeofday.S | 12 +++++------- 4 files changed, 22 insertions(+), 37 deletions(-)
arch/powerpc/include/asm/vdso_datapage.h +10 -0
@@ -118,6 +118,16 @@ struct vdso_data {extern struct vdso_data *vdso_data; +#else /* __ASSEMBLY__ */ + +.macro get_datapage ptr, tmp + bcl 20, 31, .+4 + mflr \ptr + addi \ptr, \ptr, (__kernel_datapage_offset - (.-4))@l + lwz \tmp, 0(\ptr) + add \ptr, \tmp, \ptr +.endm +#endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */
arch/powerpc/kernel/vdso32/cacheflush.S +4 -5
@@ -8,6 +8,7 @@ #include <asm/processor.h> #include <asm/ppc_asm.h> #include <asm/vdso.h> +#include <asm/vdso_datapage.h> #include <asm/asm-offsets.h> .text
@@ -24,14 +25,12 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache) .cfi_startproc mflr r12 .cfi_register lr,r12 - mr r11,r3 - bl __get_datapage@local + get_datapage r10, r0 mtlr r12 - mr r10,r3 lwz r7,CFG_DCACHE_BLOCKSZ(r10) addi r5,r7,-1 - andc r6,r11,r5 /* round low to line bdy */ + andc r6,r3,r5 /* round low to line bdy */ subf r8,r6,r4 /* compute length */ add r8,r8,r5 /* ensure we get enough */ lwz r9,CFG_DCACHE_LOGBLOCKSZ(r10)
@@ -48,7 +47,7 @@ V_FUNCTION_BEGIN(__kernel_sync_dicache) lwz r7,CFG_ICACHE_BLOCKSZ(r10) addi r5,r7,-1 - andc r6,r11,r5 /* round low to line bdy */ + andc r6,r3,r5 /* round low to line bdy */ subf r8,r6,r4 /* compute length */ add r8,r8,r5 lwz r9,CFG_ICACHE_LOGBLOCKSZ(r10)
arch/powerpc/kernel/vdso32/datapage.S +3 -25
@@ -10,35 +10,13 @@ #include <asm/asm-offsets.h> #include <asm/unistd.h> #include <asm/vdso.h> +#include <asm/vdso_datapage.h> .text .global __kernel_datapage_offset; __kernel_datapage_offset: .long 0 -V_FUNCTION_BEGIN(__get_datapage) - .cfi_startproc - /* We don't want that exposed or overridable as we want other objects - * to be able to bl directly to here - */ - .protected __get_datapage - .hidden __get_datapage - - mflr r0 - .cfi_register lr,r0 - - bcl 20,31,data_page_branch -data_page_branch: - mflr r3 - mtlr r0 - addi r3, r3, __kernel_datapage_offset-data_page_branch - lwz r0,0(r3) - .cfi_restore lr - add r3,r0,r3 - blr - .cfi_endproc -V_FUNCTION_END(__get_datapage) - /* * void *__kernel_get_syscall_map(unsigned int *syscall_count) ; *
@@ -53,7 +31,7 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map) mflr r12 .cfi_register lr,r12 mr r4,r3 - bl __get_datapage@local + get_datapage r3, r0 mtlr r12 addi r3,r3,CFG_SYSCALL_MAP32 cmpli cr0,r4,0
@@ -75,7 +53,7 @@ V_FUNCTION_BEGIN(__kernel_get_tbfreq) .cfi_startproc mflr r12 .cfi_register lr,r12 - bl __get_datapage@local + get_datapage r3, r0 lwz r4,(CFG_TB_TICKS_PER_SEC + 4)(r3) lwz r3,CFG_TB_TICKS_PER_SEC(r3) mtlr r12
arch/powerpc/kernel/vdso32/gettimeofday.S +5 -7
@@ -9,6 +9,7 @@ #include <asm/processor.h> #include <asm/ppc_asm.h> #include <asm/vdso.h> +#include <asm/vdso_datapage.h> #include <asm/asm-offsets.h> #include <asm/unistd.h>
@@ -33,8 +34,7 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday) mr r10,r3 /* r10 saves tv */ mr r11,r4 /* r11 saves tz */ - bl __get_datapage@local /* get data page */ - mr r9, r3 /* datapage ptr in r9 */ + get_datapage r9, r0 cmplwi r10,0 /* check if tv is NULL */ beq 3f lis r7,1000000@ha /* load up USEC_PER_SEC */
@@ -74,8 +74,7 @@ V_FUNCTION_BEGIN(__kernel_clock_gettime) mflr r12 /* r12 saves lr */ .cfi_register lr,r12 mr r11,r4 /* r11 saves tp */ - bl __get_datapage@local /* get data page */ - mr r9,r3 /* datapage ptr in r9 */ + get_datapage r9, r0 lis r7,NSEC_PER_SEC@h /* want nanoseconds */ ori r7,r7,NSEC_PER_SEC@l 50: bl __do_get_tspec@local /* get sec/nsec from tb & kernel */
@@ -156,7 +155,7 @@ V_FUNCTION_BEGIN(__kernel_clock_getres) mflr r12 .cfi_register lr,r12 - bl __get_datapage@local /* get data page */ + get_datapage r3, r0 lwz r5, CLOCK_HRTIMER_RES(r3) mtlr r12 li r3,0
@@ -190,8 +189,7 @@ V_FUNCTION_BEGIN(__kernel_time) .cfi_register lr,r12 mr r11,r3 /* r11 holds t */ - bl __get_datapage@local - mr r9, r3 /* datapage ptr in r9 */ + get_datapage r9, r0 lwz r3,STAMP_XTIME_SEC+LOPART(r9)
Signature · 1 line
2.13.3
RFC PATCH v2 10/10 powerpc/32: Switch VDSO to C implementation.
In reply to Christophe LeroyThis is a tentative to switch powerpc/32 vdso to
generic C implementation.
It will likely not work on 64 bits or even build properly at the moment, hence the RFC status.
powerpc is a bit special for VDSO as well as system calls in the way that it requires setting CR SO bit which cannot be done in C. Therefore, entry/exit and fallback needs to be performed in ASM.
On powerpc 8xx, performance is degraded by 30-40% for gettime and by 15-20% for getres
On a powerpc885 at 132MHz:
With current powerpc/32 ASM VDSO:
gettimeofday: vdso: 737 nsec/call clock-getres-realtime-coarse: vdso: 3081 nsec/call clock-gettime-realtime-coarse: vdso: 2861 nsec/call clock-getres-realtime: vdso: 475 nsec/call clock-gettime-realtime: vdso: 892 nsec/call clock-getres-boottime: vdso: 2621 nsec/call clock-gettime-boottime: vdso: 3857 nsec/call clock-getres-tai: vdso: 2620 nsec/call clock-gettime-tai: vdso: 3854 nsec/call clock-getres-monotonic-raw: vdso: 2621 nsec/call clock-gettime-monotonic-raw: vdso: 3499 nsec/call clock-getres-monotonic-coarse: vdso: 3083 nsec/call clock-gettime-monotonic-coarse: vdso: 3082 nsec/call clock-getres-monotonic: vdso: 475 nsec/call clock-gettime-monotonic: vdso: 1014 nsec/call
Once switched to C implementation:
gettimeofday: vdso: 1016 nsec/call clock-getres-realtime-coarse: vdso: 614 nsec/call clock-gettime-realtime-coarse: vdso: 760 nsec/call clock-getres-realtime: vdso: 560 nsec/call clock-gettime-realtime: vdso: 1192 nsec/call clock-getres-boottime: vdso: 560 nsec/call clock-gettime-boottime: vdso: 1194 nsec/call clock-getres-tai: vdso: 560 nsec/call clock-gettime-tai: vdso: 1192 nsec/call clock-getres-monotonic-raw: vdso: 560 nsec/call clock-gettime-monotonic-raw: vdso: 1248 nsec/call clock-getres-monotonic-coarse: vdso: 614 nsec/call clock-gettime-monotonic-coarse: vdso: 760 nsec/call clock-getres-monotonic: vdso: 560 nsec/call clock-gettime-monotonic: vdso: 1192 nsec/call
On a powerpc 8321 running at 333MHz
With current powerpc/32 ASM VDSO:
gettimeofday: vdso: 190 nsec/call clock-getres-realtime-coarse: vdso: 1449 nsec/call clock-gettime-realtime-coarse: vdso: 1352 nsec/call clock-getres-realtime: vdso: 135 nsec/call clock-gettime-realtime: vdso: 244 nsec/call clock-getres-boottime: vdso: 1313 nsec/call clock-gettime-boottime: vdso: 1701 nsec/call clock-getres-tai: vdso: 1268 nsec/call clock-gettime-tai: vdso: 1742 nsec/call clock-getres-monotonic-raw: vdso: 1310 nsec/call clock-gettime-monotonic-raw: vdso: 1584 nsec/call clock-getres-monotonic-coarse: vdso: 1488 nsec/call clock-gettime-monotonic-coarse: vdso: 1503 nsec/call clock-getres-monotonic: vdso: 135 nsec/call clock-gettime-monotonic: vdso: 283 nsec/call
Once switched to C implementation:
gettimeofday: vdso: 347 nsec/call clock-getres-realtime-coarse: vdso: 169 nsec/call clock-gettime-realtime-coarse: vdso: 271 nsec/call clock-getres-realtime: vdso: 150 nsec/call clock-gettime-realtime: vdso: 383 nsec/call clock-getres-boottime: vdso: 157 nsec/call clock-gettime-boottime: vdso: 377 nsec/call clock-getres-tai: vdso: 150 nsec/call clock-gettime-tai: vdso: 380 nsec/call clock-getres-monotonic-raw: vdso: 153 nsec/call clock-gettime-monotonic-raw: vdso: 407 nsec/call clock-getres-monotonic-coarse: vdso: 169 nsec/call clock-gettime-monotonic-coarse: vdso: 271 nsec/call clock-getres-monotonic: vdso: 153 nsec/call clock-gettime-monotonic: vdso: 377 nsec/call
--- arch/powerpc/Kconfig | 2 + arch/powerpc/include/asm/vdso/gettimeofday.h | 45 +++++ arch/powerpc/include/asm/vdso/vsyscall.h | 27 +++ arch/powerpc/include/asm/vdso_datapage.h | 18 +- arch/powerpc/kernel/asm-offsets.c | 23 +-- arch/powerpc/kernel/time.c | 92 +--------- arch/powerpc/kernel/vdso.c | 19 +- arch/powerpc/kernel/vdso32/Makefile | 19 +- arch/powerpc/kernel/vdso32/gettimeofday.S | 261 ++++----------------------- arch/powerpc/kernel/vdso32/vgettimeofday.c | 32 ++++ 10 files changed, 178 insertions(+), 360 deletions(-) create mode 100644 arch/powerpc/include/asm/vdso/gettimeofday.h create mode 100644 arch/powerpc/include/asm/vdso/vsyscall.h create mode 100644 arch/powerpc/kernel/vdso32/vgettimeofday.c
arch/powerpc/Kconfig +2 -0
@@ -169,6 +169,7 @@ config PPC select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER select GENERIC_TIME_VSYSCALL + select GENERIC_GETTIMEOFDAY select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_HUGE_VMAP if PPC_BOOK3S_64 && PPC_RADIX_MMU select HAVE_ARCH_JUMP_LABEL
@@ -198,6 +199,7 @@ config PPC select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_TRACER select HAVE_GCC_PLUGINS if GCC_VERSION >= 50200 # plugin support on gcc <= 5.1 is buggy on PPC + select HAVE_GENERIC_VDSO select HAVE_HW_BREAKPOINT if PERF_EVENTS && (PPC_BOOK3S || PPC_8xx) select HAVE_IDE select HAVE_IOREMAP_PROT
arch/powerpc/include/asm/vdso/gettimeofday.h new file +45 -0
45 lines not on this page · raw message
arch/powerpc/include/asm/vdso/vsyscall.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_VDSO_VSYSCALL_H +#define __ASM_VDSO_VSYSCALL_H + +#ifndef __ASSEMBLY__ + +#include <linux/timekeeper_internal.h> +#include <asm/vdso_datapage.h> + +extern struct vdso_arch_data *vdso_arch_data; + +/* +* Update the vDSO data page to keep in sync with kernel timekeeping. +*/ +static __always_inline +struct vdso_data *__powerpc_get_k_vdso_data(void) +{ +return vdso_arch_data->data; +} +#define __arch_get_k_vdso_data __powerpc_get_k_vdso_data + +/* The asm-generic header needs to be included after the definitions above */ +#include <asm-generic/vdso/vsyscall.h> + +#endif /* !__ASSEMBLY__ */ + +#endif /* __ASM_VDSO_VSYSCALL_H */
arch/powerpc/include/asm/vdso_datapage.h +4 -14
@@ -36,6 +36,7 @@#include <linux/unistd.h> #include <linux/time.h> +#include <vdso/datapage.h> #define SYSCALL_MAP_SIZE ((NR_syscalls + 31) / 32)
@@ -93,20 +94,9 @@ struct vdso_data {/* * And here is the simpler 32 bits version */ -struct vdso_data { -__u64 tb_orig_stamp;/* Timebase at boot 0x30 */ +struct vdso_arch_data { +struct vdso_data data[CS_BASES ];__u64 tb_ticks_per_sec;/* Timebase tics / sec 0x38 */ -__u64 tb_to_xs;/* Inverse of TB to 2^20 0x40 */ -__u64 stamp_xsec;/* 0x48 */ -__u32 tb_update_count;/* Timebase atomicity ctr 0x50 */ -__u32 tz_minuteswest;/* Minutes west of Greenwich 0x58 */ -__u32 tz_dsttime;/* Type of dst correction 0x5C */ -__s32 wtom_clock_sec;/* Wall to monotonic clock */ -__s32 wtom_clock_nsec; -__s32 stamp_xtime_sec;/* xtime seconds as at tb_orig_stamp */ -__s32 stamp_xtime_nsec;/* xtime nsecs as at tb_orig_stamp */ -__u32 stamp_sec_fraction;/* fractional seconds of stamp_xtime */ -__u32 hrtimer_res;/* hrtimer resolution */ __u32 syscall_map_32[SYSCALL_MAP_SIZE ];/* map of syscalls */ __u32 dcache_block_size;/* L1 d-cache block size */ __u32 icache_block_size;/* L1 i-cache block size */
@@ -116,7 +106,7 @@ struct vdso_data {#endif /* CONFIG_PPC64 */ -extern struct vdso_data *vdso_data; +extern struct vdso_arch_data *vdso_arch_data;#else /* __ASSEMBLY__ */
arch/powerpc/kernel/asm-offsets.c +6 -17
@@ -376,23 +376,12 @@ int main(void)#endif /* ! CONFIG_PPC64 */ /* datapage offsets for use by vdso */ -OFFSET (CFG_TB_ORIG_STAMP , vdso_data, tb_orig_stamp); -OFFSET (CFG_TB_TICKS_PER_SEC , vdso_data, tb_ticks_per_sec); -OFFSET (CFG_TB_TO_XS , vdso_data, tb_to_xs); -OFFSET (CFG_TB_UPDATE_COUNT , vdso_data, tb_update_count); -OFFSET (CFG_TZ_MINUTEWEST , vdso_data, tz_minuteswest); -OFFSET (CFG_TZ_DSTTIME , vdso_data, tz_dsttime); -OFFSET (CFG_SYSCALL_MAP32 , vdso_data, syscall_map_32); -OFFSET (WTOM_CLOCK_SEC , vdso_data, wtom_clock_sec); -OFFSET (WTOM_CLOCK_NSEC , vdso_data, wtom_clock_nsec); -OFFSET (STAMP_XTIME_SEC , vdso_data, stamp_xtime_sec); -OFFSET (STAMP_XTIME_NSEC , vdso_data, stamp_xtime_nsec); -OFFSET (STAMP_SEC_FRAC , vdso_data, stamp_sec_fraction); -OFFSET (CLOCK_HRTIMER_RES , vdso_data, hrtimer_res); -OFFSET (CFG_ICACHE_BLOCKSZ , vdso_data, icache_block_size); -OFFSET (CFG_DCACHE_BLOCKSZ , vdso_data, dcache_block_size); -OFFSET (CFG_ICACHE_LOGBLOCKSZ , vdso_data, icache_log_block_size); -OFFSET (CFG_DCACHE_LOGBLOCKSZ , vdso_data, dcache_log_block_size); +OFFSET (CFG_TB_TICKS_PER_SEC , vdso_arch_data, tb_ticks_per_sec); +OFFSET (CFG_SYSCALL_MAP32 , vdso_arch_data, syscall_map_32); +OFFSET (CFG_ICACHE_BLOCKSZ , vdso_arch_data, icache_block_size); +OFFSET (CFG_DCACHE_BLOCKSZ , vdso_arch_data, dcache_block_size); +OFFSET (CFG_ICACHE_LOGBLOCKSZ , vdso_arch_data, icache_log_block_size); +OFFSET (CFG_DCACHE_LOGBLOCKSZ , vdso_arch_data, dcache_log_block_size);#ifdef CONFIG_PPC64 OFFSET (CFG_SYSCALL_MAP64 , vdso_data, syscall_map_64);OFFSET (TVAL64_TV_SEC , __kernel_old_timeval, tv_sec);
arch/powerpc/kernel/time.c +1 -91
104 lines not on this page · raw message
arch/powerpc/kernel/vdso.c +10 -9
@@ -17,6 +17,7 @@#include <linux/elf.h> #include <linux/security.h> #include <linux/memblock.h> +#include <vdso/datapage.h> #include <asm/pgtable.h> #include <asm/processor.h>
@@ -71,10 +72,10 @@ static int vdso_ready;* with it, it will become dynamically allocated */ static union { -struct vdso_data data; +struct vdso_arch_data arch_data;u8 page[PAGE_SIZE ]; } vdso_data_store __page_aligned_data; -struct vdso_data *vdso_data = &vdso_data_store.data; +struct vdso_arch_data *vdso_arch_data = &vdso_data_store.arch_data;/* Format of the patch table */ struct vdso_patch_def
@@ -661,7 +662,7 @@ static void __init vdso_setup_syscall_map(void)0x80000000UL >> (i &0x1f );#else /* CONFIG_PPC64 */ if (sys_call_table[i] != sys_ni_syscall) - vdso_data->syscall_map_32[i >>5 ] |= + vdso_arch_data->syscall_map_32[i >>5 ] |=0x80000000UL >> (i &0x1f );#endif /* CONFIG_PPC64 */ }
@@ -729,10 +730,10 @@ static int __init vdso_init(void) vdso64_pages = (&vdso64_end - &vdso64_start) >>PAGE_SHIFT ;DBG ("vdso64_kbase: %p, 0x%x pages\n" , vdso64_kbase, vdso64_pages);#else - vdso_data->dcache_block_size =L1_CACHE_BYTES ; - vdso_data->dcache_log_block_size =L1_CACHE_SHIFT ; - vdso_data->icache_block_size =L1_CACHE_BYTES ; - vdso_data->icache_log_block_size =L1_CACHE_SHIFT ; + vdso_arch_data->dcache_block_size =L1_CACHE_BYTES ; + vdso_arch_data->dcache_log_block_size =L1_CACHE_SHIFT ; + vdso_arch_data->icache_block_size =L1_CACHE_BYTES ; + vdso_arch_data->icache_log_block_size =L1_CACHE_SHIFT ;#endif /* CONFIG_PPC64 */
@@ -775,7 +776,7 @@ static int __init vdso_init(void)get_page (pg); vdso32_pagelist[i] = pg; } - vdso32_pagelist[i++] =virt_to_page (vdso_data); + vdso32_pagelist[i++] =virt_to_page (vdso_arch_data); vdso32_pagelist[i] =NULL ;#endif
@@ -792,7 +793,7 @@ static int __init vdso_init(void) vdso64_pagelist[i] =NULL ;#endif /* CONFIG_PPC64 */ -get_page (virt_to_page (vdso_data)); +get_page (virt_to_page (vdso_arch_data));smp_wmb (); vdso_ready =1 ;
arch/powerpc/kernel/vdso32/Makefile +15 -4
@@ -2,10 +2,17 @@ # List of files in the vdso, has to be asm only for now +ARCH_REL_TYPE_ABS := R_PPC_JUMP_SLOT|R_PPC_GLOB_DAT|R_PPC_ADDR32|R_PPC_ADDR24|R_PPC_ADDR16|R_PPC_ADDR16_LO|R_PPC_ADDR16_HI|R_PPC_ADDR16_HA|R_PPC_ADDR14|R_PPC_ADDR14_BRTAKEN|R_PPC_ADDR14_BRNTAKEN +include $(srctree)/lib/vdso/Makefile + obj-vdso32-$(CONFIG_PPC64) = getcpu.o obj-vdso32 = sigtramp.o gettimeofday.o datapage.o cacheflush.o note.o \ $(obj-vdso32-y) +ifneq ($(c-gettimeofday-y),) + CFLAGS_vgettimeofday.o += -include $(c-gettimeofday-y) +endif + # Build rules ifdef CROSS32_COMPILE
@@ -38,8 +45,8 @@ CPPFLAGS_vdso32.lds += -P -C -Upowerpc $(obj)/vdso32_wrapper.o : $(obj)/vdso32.so # link rule for the .so file, .lds has to be first -$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) FORCE - $(call if_changed,vdso32ld) +$(obj)/vdso32.so.dbg: $(src)/vdso32.lds $(obj-vdso32) $(obj)/vgettimeofday.o FORCE + $(call if_changed,vdso32ld_and_check) # strip rule for the .so file $(obj)/%.so: OBJCOPYFLAGS := -S
@@ -49,12 +56,16 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE # assembly rules for the .S files $(obj-vdso32): %.o: %.S FORCE $(call if_changed_dep,vdso32as) +$(obj)/vgettimeofday.o: %.o: %.c FORCE + $(call if_changed_dep,vdso32cc) # actual build commands -quiet_cmd_vdso32ld = VDSO32L $@ - cmd_vdso32ld = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) +quiet_cmd_vdso32ld_and_check = VDSO32L $@ + cmd_vdso32ld_and_check = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check) quiet_cmd_vdso32as = VDSO32A $@ cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) -c -o $@ $< +quiet_cmd_vdso32cc = VDSO32A $@ + cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $< # install commands for the unstripped file quiet_cmd_vdso_install = INSTALL $@
arch/powerpc/kernel/vdso32/gettimeofday.S +36 -225
293 lines not on this page · raw message
arch/powerpc/kernel/vdso32/vgettimeofday.c new file +32 -0
@@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* ARM64 userspace implementations of gettimeofday() and similar. +* +* Copyright (C) 2018 ARM Limited +* +*/ +#include <linux/time.h> +#include <linux/types.h> + +int __c_kernel_clock_gettime (clockid_t clock,struct old_timespec32 *ts, +const struct vdso_data *vd) +{ +return __cvdso_clock_gettime32 (vd, clock, ts); +} + +int __c_kernel_gettimeofday (struct __kernel_old_timeval *tv,struct timezone *tz, +const struct vdso_data *vd) +{ +return __cvdso_gettimeofday (vd, tv, tz); +} + +int __c_kernel_clock_getres (clockid_t clock_id,struct old_timespec32 *res, +const struct vdso_data *vd) +{ +return __cvdso_clock_getres_time32 (vd, clock_id, res); +} + +time_t __c_kernel_time (time_t *time,const struct vdso_data *vd) +{ +return __cvdso_time (vd, time); +}
Signature · 1 line
2.13.3
kbuild test robot
build botRe: [RFC PATCH v2 10/10] powerpc/32: Switch VDSO to C implementation.
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please…
Hi Christophe,
[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on v5.5-rc3]
[also build test ERROR on next-20191220]
[cannot apply to powerpc/next arm64/for-next/core tip/timers/vdso] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Christophe-Leroy/powerpc-32-switch-VDSO-to-C-implementation/20191225-085921 base: 46cf053efec6a3a5f343fead837777efe8252a46 config: powerpc-allmodconfig (attached as .config) compiler: powerpc64-linux-gcc (GCC) 7.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=powerpc
If you fix the issue, kindly add following tag
All error/warnings (new ones prefixed by >>):
In file included from arch/powerpc/kernel/asm-offsets.c:38:0:
>> arch/powerpc/include/asm/vdso_datapage.h:49:8: error: redefinition of 'struct vdso_data'
struct vdso_data {
^~~~~~~~~
In file included from arch/powerpc/include/asm/vdso_datapage.h:39:0,
from arch/powerpc/kernel/asm-offsets.c:38:
include/vdso/datapage.h:59:8: note: originally defined here
struct vdso_data {
^~~~~~~~~
In file included from arch/powerpc/kernel/asm-offsets.c:29:0:
arch/powerpc/kernel/asm-offsets.c: In function 'main':
>> include/linux/compiler_types.h:129:35: error: invalid use of undefined type 'struct vdso_arch_data'
#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
^
include/linux/kbuild.h:6:62: note: in definition of macro 'DEFINE'
asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
^~~
include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
^~~~~~~~~~~~~~~~~~~
include/linux/kbuild.h:11:14: note: in expansion of macro 'offsetof'
DEFINE(sym, offsetof(struct str, mem))
^~~~~~~~
>> arch/powerpc/kernel/asm-offsets.c:379:2: note: in expansion of macro 'OFFSET'
OFFSET(CFG_TB_TICKS_PER_SEC, vdso_arch_data, tb_ticks_per_sec);
^~~~~~
>> include/linux/compiler_types.h:129:35: error: invalid use of undefined type 'struct vdso_arch_data'
#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
^
include/linux/kbuild.h:6:62: note: in definition of macro 'DEFINE'
asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
^~~
include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
^~~~~~~~~~~~~~~~~~~
include/linux/kbuild.h:11:14: note: in expansion of macro 'offsetof'
DEFINE(sym, offsetof(struct str, mem))
^~~~~~~~
arch/powerpc/kernel/asm-offsets.c:380:2: note: in expansion of macro 'OFFSET'
OFFSET(CFG_SYSCALL_MAP32, vdso_arch_data, syscall_map_32);
^~~~~~
>> include/linux/compiler_types.h:129:35: error: invalid use of undefined type 'struct vdso_arch_data'
#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
^
include/linux/kbuild.h:6:62: note: in definition of macro 'DEFINE'
asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
^~~
include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
^~~~~~~~~~~~~~~~~~~
include/linux/kbuild.h:11:14: note: in expansion of macro 'offsetof'
DEFINE(sym, offsetof(struct str, mem))
^~~~~~~~
arch/powerpc/kernel/asm-offsets.c:381:2: note: in expansion of macro 'OFFSET'
OFFSET(CFG_ICACHE_BLOCKSZ, vdso_arch_data, icache_block_size);
^~~~~~
>> include/linux/compiler_types.h:129:35: error: invalid use of undefined type 'struct vdso_arch_data'
#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
^
include/linux/kbuild.h:6:62: note: in definition of macro 'DEFINE'
asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
^~~
include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
^~~~~~~~~~~~~~~~~~~
include/linux/kbuild.h:11:14: note: in expansion of macro 'offsetof'
DEFINE(sym, offsetof(struct str, mem))
^~~~~~~~
arch/powerpc/kernel/asm-offsets.c:382:2: note: in expansion of macro 'OFFSET'
OFFSET(CFG_DCACHE_BLOCKSZ, vdso_arch_data, dcache_block_size);
^~~~~~
>> include/linux/compiler_types.h:129:35: error: invalid use of undefined type 'struct vdso_arch_data'
#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
^
include/linux/kbuild.h:6:62: note: in definition of macro 'DEFINE'
asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
^~~
include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
^~~~~~~~~~~~~~~~~~~
include/linux/kbuild.h:11:14: note: in expansion of macro 'offsetof'
DEFINE(sym, offsetof(struct str, mem))
^~~~~~~~
arch/powerpc/kernel/asm-offsets.c:383:2: note: in expansion of macro 'OFFSET'
OFFSET(CFG_ICACHE_LOGBLOCKSZ, vdso_arch_data, icache_log_block_size);
^~~~~~
>> include/linux/compiler_types.h:129:35: error: invalid use of undefined type 'struct vdso_arch_data'
#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)
^
include/linux/kbuild.h:6:62: note: in definition of macro 'DEFINE'
asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val))
^~~
include/linux/stddef.h:17:32: note: in expansion of macro '__compiler_offsetof'
#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
^~~~~~~~~~~~~~~~~~~
include/linux/kbuild.h:11:14: note: in expansion of macro 'offsetof'
DEFINE(sym, offsetof(struct str, mem))
^~~~~~~~
arch/powerpc/kernel/asm-offsets.c:384:2: note: in expansion of macro 'OFFSET'
OFFSET(CFG_DCACHE_LOGBLOCKSZ, vdso_arch_data, dcache_log_block_size);
^~~~~~ make[2]: *** [arch/powerpc/kernel/asm-offsets.s] Error 1 make[2]: Target '__build' not remade because of errors. make[1]: *** [prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [sub-make] Error 2
18 real 5 user 5 sys 61.63% cpu make prepare
vim +49 arch/powerpc/include/asm/vdso_datapage.h
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 48
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 @49 struct vdso_data {
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 50 __u8 eye_catcher[16]; /* Eyecatcher: SYSTEMCFG:PPC64 0x00 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 51 struct { /* Systemcfg version numbers */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 52 __u32 major; /* Major number 0x10 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 53 __u32 minor; /* Minor number 0x14 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 54 } version;
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 55
e8222502ee6157e include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2006-03-28 56 /* Note about the platform flags: it now only contains the lpar
25985edcedea639 arch/powerpc/include/asm/vdso_datapage.h Lucas De Marchi 2011-03-30 57 * bit. The actual platform number is dead and buried
e8222502ee6157e include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2006-03-28 58 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 59 __u32 platform; /* Platform flags 0x18 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 60 __u32 processor; /* Processor type 0x1C */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 61 __u64 processorCount; /* # of physical processors 0x20 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 62 __u64 physicalMemorySize; /* Size of real memory(B) 0x28 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 63 __u64 tb_orig_stamp; /* Timebase at boot 0x30 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 64 __u64 tb_ticks_per_sec; /* Timebase tics / sec 0x38 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 65 __u64 tb_to_xs; /* Inverse of TB to 2^20 0x40 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 66 __u64 stamp_xsec; /* 0x48 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 67 __u64 tb_update_count; /* Timebase atomicity ctr 0x50 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 68 __u32 tz_minuteswest; /* Minutes west of Greenwich 0x58 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 69 __u32 tz_dsttime; /* Type of dst correction 0x5C */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 70 __u32 dcache_size; /* L1 d-cache size 0x60 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 71 __u32 dcache_line_size; /* L1 d-cache line size 0x64 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 72 __u32 icache_size; /* L1 i-cache size 0x68 */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 73 __u32 icache_line_size; /* L1 i-cache line size 0x6C */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 74
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 75 /* those additional ones don't have to be located anywhere
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 76 * special as they were not part of the original systemcfg
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 77 */
fbe481756df5767 include/asm-powerpc/vdso_datapage.h Olof Johansson 2007-11-20 78 __u32 dcache_block_size; /* L1 d-cache block size */
fbe481756df5767 include/asm-powerpc/vdso_datapage.h Olof Johansson 2007-11-20 79 __u32 icache_block_size; /* L1 i-cache block size */
fbe481756df5767 include/asm-powerpc/vdso_datapage.h Olof Johansson 2007-11-20 80 __u32 dcache_log_block_size; /* L1 d-cache log block size */
fbe481756df5767 include/asm-powerpc/vdso_datapage.h Olof Johansson 2007-11-20 81 __u32 icache_log_block_size; /* L1 i-cache log block size */
8fd63a9ea752846 arch/powerpc/include/asm/vdso_datapage.h Paul Mackerras 2010-06-20 82 __u32 stamp_sec_fraction; /* fractional seconds of stamp_xtime */
b5b4453e7912f05 arch/powerpc/include/asm/vdso_datapage.h Michael Ellerman 2019-03-14 83 __s32 wtom_clock_nsec; /* Wall to monotonic clock nsec */
b5b4453e7912f05 arch/powerpc/include/asm/vdso_datapage.h Michael Ellerman 2019-03-14 84 __s64 wtom_clock_sec; /* Wall to monotonic clock sec */
176ed98c8a76ee0 arch/powerpc/include/asm/vdso_datapage.h Arnd Bergmann 2019-10-27 85 __s64 stamp_xtime_sec; /* xtime secs as at tb_orig_stamp */
176ed98c8a76ee0 arch/powerpc/include/asm/vdso_datapage.h Arnd Bergmann 2019-10-27 86 __s64 stamp_xtime_nsec; /* xtime nsecs as at tb_orig_stamp */
552263456215ada arch/powerpc/include/asm/vdso_datapage.h Vincenzo Frascino 2019-12-02 87 __u32 hrtimer_res; /* hrtimer resolution */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 88 __u32 syscall_map_64[SYSCALL_MAP_SIZE]; /* map of syscalls */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 89 __u32 syscall_map_32[SYSCALL_MAP_SIZE]; /* map of syscalls */
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 90 };
a7f290dad32ee34 include/asm-powerpc/vdso_datapage.h Benjamin Herrenschmidt 2005-11-11 91 :::::: The code at line 49 was first introduced by commit
:::::: a7f290dad32ee34d931561b7943c858fe2aae503 [PATCH] powerpc: Merge vdso's and add vdso support to 32 bits kernel
:::::: TO: Benjamin Herrenschmidt <[email protected]> :::::: CC: Paul Mackerras <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org Intel Corporation
Surprising code generated for vdso_read_begin()
In reply to Christophe LeroyWondering why we get something so complicated/redundant for vdso_read_begin() <include/vdso/helpers.h>
static __always_inline u32 vdso_read_begin(const struct vdso_data *vd)
{
u32 seq;
while ((seq = READ_ONCE(vd->seq)) & 1)
cpu_relax();
smp_rmb();
return seq;
}6e0: 81 05 00 f0 lwz r8,240(r5) 6e4: 71 09 00 01 andi. r9,r8,1 6e8: 41 82 00 10 beq 6f8 <__c_kernel_clock_gettime+0x158> 6ec: 81 05 00 f0 lwz r8,240(r5) 6f0: 71 0a 00 01 andi. r10,r8,1 6f4: 40 82 ff f8 bne 6ec <__c_kernel_clock_gettime+0x14c>
6f8:
r5 being vd pointer
Why the first triplet, not only the second triplet ? Something wrong with using READ_ONCE() for that ?
Christophe
Re: Surprising code generated for vdso_read_begin()
Quoted 21 lines · Christophe Leroy
Wondering why we get something so complicated/redundant for
vdso_read_begin()<include/vdso/helpers.h>static
__always_inlineu32vdso_read_begin(const struct vdso_data *vd){ u32 seq; while ((seq = READ_ONCE(vd->seq)) & 1) cpu_relax(); smp_rmb(); return seq; }6e0: 81 05 00 f0 lwz r8,240(r5) 6e4: 71 09 00 01 andi. r9,r8,1 6e8: 41 82 00 10 beq 6f8 <__c_kernel_clock_gettime+0x158> 6ec: 81 05 00 f0 lwz r8,240(r5) 6f0: 71 0a 00 01 andi. r10,r8,1 6f4: 40 82 ff f8 bne 6ec <__c_kernel_clock_gettime+0x14c>
Quoted 6 lines
6f8:
r5 being vd pointer
Why the first triplet, not only the second triplet ? Something wrong with using
READ_ONCE()for that ?
It looks like the compiler did loop peeling. What GCC version is this? Please try current trunk (to become GCC 10), or at least GCC 9?
Segher
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: Surprising code generated for vdso_read_begin()
Le 09/01/2020 à 21:07, Segher Boessenkool a écrit :
Quoted 24 lines · Christophe Leroy
Quoted 23 lines
Wondering why we get something so complicated/redundant for
vdso_read_begin()<include/vdso/helpers.h>static
__always_inlineu32vdso_read_begin(const struct vdso_data *vd){ u32 seq; while ((seq = READ_ONCE(vd->seq)) & 1) cpu_relax(); smp_rmb(); return seq; }6e0: 81 05 00 f0 lwz r8,240(r5) 6e4: 71 09 00 01 andi. r9,r8,1 6e8: 41 82 00 10 beq 6f8 <__c_kernel_clock_gettime+0x158> 6ec: 81 05 00 f0 lwz r8,240(r5) 6f0: 71 0a 00 01 andi. r10,r8,1 6f4: 40 82 ff f8 bne 6ec <__c_kernel_clock_gettime+0x14c>6f8:
Quoted 8 lines
Quoted 4 lines
r5 being vd pointer
Why the first triplet, not only the second triplet ? Something wrong with using
READ_ONCE()for that ?It looks like the compiler did loop peeling. What GCC version is this? Please try current trunk (to become GCC 10), or at least GCC 9?
It is with GCC 5.5
https://mirrors.edge.kernel.org/pub/tools/crosstool/ doesn't have more recent than 8.1
With 8.1, the problem doesn't show up.
Thanks
Christophe
Re: Surprising code generated for vdso_read_begin()
Quoted 8 lines · Christophe Leroy
Le 09/01/2020 à 21:07, Segher Boessenkool a écrit :
Quoted 2 lines
It looks like the compiler did loop peeling. What GCC version is this? Please try current trunk (to become GCC 10), or at least GCC 9?
It is with GCC 5.5
https://mirrors.edge.kernel.org/pub/tools/crosstool/ doesn't have more recent than 8.1
Arnd, can you update the tools? We are at 8.3 and 9.2 now :-) Or is this hard and/or painful to do?
Quoted 1 line
With 8.1, the problem doesn't show up.
Good to hear that. Hrm, I wonder when it was fixed...
Segher
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: Surprising code generated for vdso_read_begin()
Quoted 6 lines · Segher Boessenkool
Quoted 4 lines · Christophe Leroy
Quoted 2 lines · Segher Boessenkool
It looks like the compiler did loop peeling. What GCC version is this? Please try current trunk (to become GCC 10), or at least GCC 9?
Quoted 7 lines
Quoted 4 lines
It is with GCC 5.5
https://mirrors.edge.kernel.org/pub/tools/crosstool/ doesn't have more recent than 8.1
Arnd, can you update the tools? We are at 8.3 and 9.2 now :-) Or is this hard and/or painful to do?
To follow up on this older thread, I have now uploaded 6.5, 7.5, 8.3 and 9.2 binaries, as well as a recent 10.0 snapshot.
I hope these work, let me know if there are problems.
Arnd
Re: Surprising code generated for vdso_read_begin()
Le 16/02/2020 à 19:10, Arnd Bergmann a écrit :
Quoted 10 lines
Quoted 8 lines · Segher Boessenkool
Quoted 6 lines · Christophe Leroy
Quoted 2 lines · Segher Boessenkool
It looks like the compiler did loop peeling. What GCC version is this? Please try current trunk (to become GCC 10), or at least GCC 9?
It is with GCC 5.5
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
https://mirrors.edge.kernel.org/pub/tools/crosstool/ doesn't have more recent than 8.1
Arnd, can you update the tools? We are at 8.3 and 9.2 now :-) Or is this hard and/or painful to do?
To follow up on this older thread, I have now uploaded 6.5, 7.5, 8.3 and 9.2 binaries, as well as a recent 10.0 snapshot.
Thanks Arnd,
I have built the VDSO with 9.2, I get less performant result than with 8.2 (same performance as with 5.5).
After a quick look, I see:
- Irrelevant NOPs to align loops and stuff, allthough -mpcu=860 should avoid that.
- A stack frame is set for saving r31 in __c_kernel_clock_gettime. GCC 8.1 don't need that, all VDSO functions are frameless with 8.1
Christophe
Re: Surprising code generated for vdso_read_begin()
Quoted 23 lines · Christophe Leroy
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · Segher Boessenkool
Quoted 6 lines · Christophe Leroy
Quoted 2 lines · Segher Boessenkool
It looks like the compiler did loop peeling. What GCC version is this? Please try current trunk (to become GCC 10), or at least GCC 9?
It is with GCC 5.5
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
https://mirrors.edge.kernel.org/pub/tools/crosstool/ doesn't have more recent than 8.1
Arnd, can you update the tools? We are at 8.3 and 9.2 now :-) Or is this hard and/or painful to do?
To follow up on this older thread, I have now uploaded 6.5, 7.5, 8.3 and 9.2 binaries, as well as a recent 10.0 snapshot.
Thanks Arnd,
Quoted 8 lines
I have built the VDSO with 9.2, I get less performant result than with 8.2 (same performance as with 5.5).
After a quick look, I see:
- Irrelevant NOPs to align loops and stuff, allthough -mpcu=860 should avoid that.
- A stack frame is set for saving r31 in__c_kernel_clock_gettime. GCC 8.1 don't need that, all VDSO functions are frameless with 8.1
If you think it should be fixed in gcc, maybe try to reproduce it in
https://godbolt.org/ and open a gcc bug against that.
Also, please try the gcc-10 snapshot, which has the highest chance of getting fixes if it shows the same issue (or worse).
Arnd
Re: Surprising code generated for vdso_read_begin()
Quoted 28 lines · Arnd Bergmann
Quoted 26 lines · Christophe Leroy
Quoted 10 lines · Arnd Bergmann
Quoted 8 lines · Segher Boessenkool
Quoted 6 lines · Christophe Leroy
Quoted 2 lines · Segher Boessenkool
It looks like the compiler did loop peeling. What GCC version is this? Please try current trunk (to become GCC 10), or at least GCC 9?
It is with GCC 5.5
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
https://mirrors.edge.kernel.org/pub/tools/crosstool/ doesn't have more recent than 8.1
Arnd, can you update the tools? We are at 8.3 and 9.2 now :-) Or is this hard and/or painful to do?
To follow up on this older thread, I have now uploaded 6.5, 7.5, 8.3 and 9.2 binaries, as well as a recent 10.0 snapshot.
Thanks Arnd,
I have built the VDSO with 9.2, I get less performant result than with 8.2 (same performance as with 5.5).
Quoted 8 lines
Quoted 5 lines
After a quick look, I see:
- Irrelevant NOPs to align loops and stuff, allthough -mpcu=860 should avoid that.
- A stack frame is set for saving r31 in__c_kernel_clock_gettime. GCC 8.1 don't need that, all VDSO functions are frameless with 8.1If you think it should be fixed in gcc, maybe try to reproduce it in
https://godbolt.org/
(Feel free to skip this step; and don't put links to godbolt (or anything else external) in our bugzilla, please; such links go stale before you know it.)
Quoted 1 line
and open a gcc bug against that.
Yes please :-)
Quoted 2 lines
Also, please try the gcc-10 snapshot, which has the highest chance of getting fixes if it shows the same issue (or worse).
If it is a regression, chances are it will be backported. (But not to 9.3, which is due in just a few weeks, just like 8.4). If it is just a side effect of some other change, it will probably *not* be undone, not on trunk (GCC 10) either. It depends.
But sure, always test trunk if you can.
Segher
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel