Re: [PATCH RESEND v1 2/4] lib/vdso: Add vdso_data pointer as input to __arch_get_timens_vdso_data()
On 3/31/21 5:48 PM, Christophe Leroy wrote: > For the same reason as commit e876f0b69dc9 ("lib/vdso: Allow > architectures to provide the vdso data pointer"), powerpc wants to > avoid calculation of relative position to code. > > As the timens_vdso_data is next page to vdso_data, provide > vdso_data pointer to __arch_get_timens_vdso_data() in order > to ease the calculation on powerpc in following patches. > > Signed-off-by: Christophe Leroy Reviewed-by: Vincenzo Frascino > --- > arch/arm64/include/asm/vdso/compat_gettimeofday.h | 3 ++- > arch/arm64/include/asm/vdso/gettimeofday.h| 2 +- > arch/s390/include/asm/vdso/gettimeofday.h | 3 ++- > arch/x86/include/asm/vdso/gettimeofday.h | 3 ++- > lib/vdso/gettimeofday.c | 15 +-- > 5 files changed, 16 insertions(+), 10 deletions(-) > > diff --git a/arch/arm64/include/asm/vdso/compat_gettimeofday.h > b/arch/arm64/include/asm/vdso/compat_gettimeofday.h > index 7508b0ac1d21..ecb6fd4c3c64 100644 > --- a/arch/arm64/include/asm/vdso/compat_gettimeofday.h > +++ b/arch/arm64/include/asm/vdso/compat_gettimeofday.h > @@ -155,7 +155,8 @@ static __always_inline const struct vdso_data > *__arch_get_vdso_data(void) > } > > #ifdef CONFIG_TIME_NS > -static __always_inline const struct vdso_data > *__arch_get_timens_vdso_data(void) > +static __always_inline > +const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data > *vd) > { > const struct vdso_data *ret; > > diff --git a/arch/arm64/include/asm/vdso/gettimeofday.h > b/arch/arm64/include/asm/vdso/gettimeofday.h > index 631ab1281633..de86230a9436 100644 > --- a/arch/arm64/include/asm/vdso/gettimeofday.h > +++ b/arch/arm64/include/asm/vdso/gettimeofday.h > @@ -100,7 +100,7 @@ const struct vdso_data *__arch_get_vdso_data(void) > > #ifdef CONFIG_TIME_NS > static __always_inline > -const struct vdso_data *__arch_get_timens_vdso_data(void) > +const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data > *vd) > { > return _timens_data; > } > diff --git a/arch/s390/include/asm/vdso/gettimeofday.h > b/arch/s390/include/asm/vdso/gettimeofday.h > index ed89ef742530..383c53c3 100644 > --- a/arch/s390/include/asm/vdso/gettimeofday.h > +++ b/arch/s390/include/asm/vdso/gettimeofday.h > @@ -68,7 +68,8 @@ long clock_getres_fallback(clockid_t clkid, struct > __kernel_timespec *ts) > } > > #ifdef CONFIG_TIME_NS > -static __always_inline const struct vdso_data > *__arch_get_timens_vdso_data(void) > +static __always_inline > +const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data > *vd) > { > return _timens_data; > } > diff --git a/arch/x86/include/asm/vdso/gettimeofday.h > b/arch/x86/include/asm/vdso/gettimeofday.h > index df01d7349d79..1936f21ed8cd 100644 > --- a/arch/x86/include/asm/vdso/gettimeofday.h > +++ b/arch/x86/include/asm/vdso/gettimeofday.h > @@ -58,7 +58,8 @@ extern struct ms_hyperv_tsc_page hvclock_page > #endif > > #ifdef CONFIG_TIME_NS > -static __always_inline const struct vdso_data > *__arch_get_timens_vdso_data(void) > +static __always_inline > +const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data > *vd) > { > return __timens_vdso_data; > } > diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c > index c6f6dee08746..ce2f69552003 100644 > --- a/lib/vdso/gettimeofday.c > +++ b/lib/vdso/gettimeofday.c > @@ -49,13 +49,15 @@ static inline bool vdso_cycles_ok(u64 cycles) > static __always_inline int do_hres_timens(const struct vdso_data *vdns, > clockid_t clk, > struct __kernel_timespec *ts) > { > - const struct vdso_data *vd = __arch_get_timens_vdso_data(); > + const struct vdso_data *vd; > const struct timens_offset *offs = &vdns->offset[clk]; > const struct vdso_timestamp *vdso_ts; > u64 cycles, last, ns; > u32 seq; > s64 sec; > > + vd = vdns - (clk == CLOCK_MONOTONIC_RAW ? CS_RAW : CS_HRES_COARSE); > + vd = __arch_get_timens_vdso_data(vd); > if (clk != CLOCK_MONOTONIC_RAW) > vd = &vd[CS_HRES_COARSE]; > else > @@ -92,7 +94,8 @@ static __always_inline int do_hres_timens(const struct > vdso_data *vdns, clockid_ > return 0; > } > #else > -static __always_inline const struct vdso_data > *__arch_get_timens_vdso_data(void) > +static __always_inline > +const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data > *vd) > { > return NULL; > } > @@ -162,7 +165,7 @@ static __always_inline int do_hres(const struct vdso_data > *vd, clockid_t clk, > static __always_inline int do_coarse_timens(const struct vdso_data *vdns, > clockid_t clk, > struct __kernel_timespec *ts) > { > - const struct vdso_data *vd = __arch_get_timens_vdso_data(); > + const struct vdso_data *vd = __arch_get_timens_vdso_data(vdns); > const
Re: [PATCH RESEND v1 2/4] lib/vdso: Add vdso_data pointer as input to __arch_get_timens_vdso_data()
On Wed, Mar 31 2021 at 16:48, Christophe Leroy wrote: > For the same reason as commit e876f0b69dc9 ("lib/vdso: Allow > architectures to provide the vdso data pointer"), powerpc wants to > avoid calculation of relative position to code. > > As the timens_vdso_data is next page to vdso_data, provide > vdso_data pointer to __arch_get_timens_vdso_data() in order > to ease the calculation on powerpc in following patches. > > Signed-off-by: Christophe Leroy Reviewed-by: Thomas Gleixner
Re: [PATCH RESEND v1 2/4] lib/vdso: Add vdso_data pointer as input to __arch_get_timens_vdso_data()
On Wed, Mar 31, 2021 at 04:48:45PM +, Christophe Leroy wrote: > For the same reason as commit e876f0b69dc9 ("lib/vdso: Allow > architectures to provide the vdso data pointer"), powerpc wants to > avoid calculation of relative position to code. > > As the timens_vdso_data is next page to vdso_data, provide > vdso_data pointer to __arch_get_timens_vdso_data() in order > to ease the calculation on powerpc in following patches. > Acked-by: Andrei Vagin > Signed-off-by: Christophe Leroy
[PATCH RESEND v1 2/4] lib/vdso: Add vdso_data pointer as input to __arch_get_timens_vdso_data()
For the same reason as commit e876f0b69dc9 ("lib/vdso: Allow architectures to provide the vdso data pointer"), powerpc wants to avoid calculation of relative position to code. As the timens_vdso_data is next page to vdso_data, provide vdso_data pointer to __arch_get_timens_vdso_data() in order to ease the calculation on powerpc in following patches. Signed-off-by: Christophe Leroy --- arch/arm64/include/asm/vdso/compat_gettimeofday.h | 3 ++- arch/arm64/include/asm/vdso/gettimeofday.h| 2 +- arch/s390/include/asm/vdso/gettimeofday.h | 3 ++- arch/x86/include/asm/vdso/gettimeofday.h | 3 ++- lib/vdso/gettimeofday.c | 15 +-- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/arch/arm64/include/asm/vdso/compat_gettimeofday.h b/arch/arm64/include/asm/vdso/compat_gettimeofday.h index 7508b0ac1d21..ecb6fd4c3c64 100644 --- a/arch/arm64/include/asm/vdso/compat_gettimeofday.h +++ b/arch/arm64/include/asm/vdso/compat_gettimeofday.h @@ -155,7 +155,8 @@ static __always_inline const struct vdso_data *__arch_get_vdso_data(void) } #ifdef CONFIG_TIME_NS -static __always_inline const struct vdso_data *__arch_get_timens_vdso_data(void) +static __always_inline +const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd) { const struct vdso_data *ret; diff --git a/arch/arm64/include/asm/vdso/gettimeofday.h b/arch/arm64/include/asm/vdso/gettimeofday.h index 631ab1281633..de86230a9436 100644 --- a/arch/arm64/include/asm/vdso/gettimeofday.h +++ b/arch/arm64/include/asm/vdso/gettimeofday.h @@ -100,7 +100,7 @@ const struct vdso_data *__arch_get_vdso_data(void) #ifdef CONFIG_TIME_NS static __always_inline -const struct vdso_data *__arch_get_timens_vdso_data(void) +const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd) { return _timens_data; } diff --git a/arch/s390/include/asm/vdso/gettimeofday.h b/arch/s390/include/asm/vdso/gettimeofday.h index ed89ef742530..383c53c3 100644 --- a/arch/s390/include/asm/vdso/gettimeofday.h +++ b/arch/s390/include/asm/vdso/gettimeofday.h @@ -68,7 +68,8 @@ long clock_getres_fallback(clockid_t clkid, struct __kernel_timespec *ts) } #ifdef CONFIG_TIME_NS -static __always_inline const struct vdso_data *__arch_get_timens_vdso_data(void) +static __always_inline +const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd) { return _timens_data; } diff --git a/arch/x86/include/asm/vdso/gettimeofday.h b/arch/x86/include/asm/vdso/gettimeofday.h index df01d7349d79..1936f21ed8cd 100644 --- a/arch/x86/include/asm/vdso/gettimeofday.h +++ b/arch/x86/include/asm/vdso/gettimeofday.h @@ -58,7 +58,8 @@ extern struct ms_hyperv_tsc_page hvclock_page #endif #ifdef CONFIG_TIME_NS -static __always_inline const struct vdso_data *__arch_get_timens_vdso_data(void) +static __always_inline +const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd) { return __timens_vdso_data; } diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index c6f6dee08746..ce2f69552003 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -49,13 +49,15 @@ static inline bool vdso_cycles_ok(u64 cycles) static __always_inline int do_hres_timens(const struct vdso_data *vdns, clockid_t clk, struct __kernel_timespec *ts) { - const struct vdso_data *vd = __arch_get_timens_vdso_data(); + const struct vdso_data *vd; const struct timens_offset *offs = &vdns->offset[clk]; const struct vdso_timestamp *vdso_ts; u64 cycles, last, ns; u32 seq; s64 sec; + vd = vdns - (clk == CLOCK_MONOTONIC_RAW ? CS_RAW : CS_HRES_COARSE); + vd = __arch_get_timens_vdso_data(vd); if (clk != CLOCK_MONOTONIC_RAW) vd = &vd[CS_HRES_COARSE]; else @@ -92,7 +94,8 @@ static __always_inline int do_hres_timens(const struct vdso_data *vdns, clockid_ return 0; } #else -static __always_inline const struct vdso_data *__arch_get_timens_vdso_data(void) +static __always_inline +const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd) { return NULL; } @@ -162,7 +165,7 @@ static __always_inline int do_hres(const struct vdso_data *vd, clockid_t clk, static __always_inline int do_coarse_timens(const struct vdso_data *vdns, clockid_t clk, struct __kernel_timespec *ts) { - const struct vdso_data *vd = __arch_get_timens_vdso_data(); + const struct vdso_data *vd = __arch_get_timens_vdso_data(vdns); const struct vdso_timestamp *vdso_ts = &vd->basetime[clk]; const struct timens_offset *offs = &vdns->offset[clk]; u64 nsec; @@ -310,7 +313,7 @@ __cvdso_gettimeofday_data(const struct vdso_data *vd, if (unlikely(tz != NULL)) { if (IS_ENABLED(CONFIG_TIME_NS) &&