From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
arnd@arndb.de, tglx@linutronix.de, vincenzo.frascino@arm.com,
luto@kernel.org
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
x86@kernel.org
Subject: [RFC PATCH v3 08/12] lib: vdso: allow arches to provide vdso data pointer
Date: Mon, 13 Jan 2020 17:08:46 +0000 (UTC) [thread overview]
Message-ID: <381e547dbb3c48fd39d6cf208033bba38ad048fb.1578934751.git.christophe.leroy@c-s.fr> (raw)
In-Reply-To: <cover.1578934751.git.christophe.leroy@c-s.fr>
On powerpc, __arch_get_vdso_data() clobbers the link register,
requiring the caller to save it.
As the parent function already has to set a stack frame and saves
the link register before calling 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.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
lib/vdso/gettimeofday.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c
index da15a8842825..ea1a55507af5 100644
--- a/lib/vdso/gettimeofday.c
+++ b/lib/vdso/gettimeofday.c
@@ -104,9 +104,15 @@ static __always_inline int do_coarse(const struct vdso_data *vd, clockid_t clk,
}
static __maybe_unused int
+#ifdef VDSO_GETS_VD_PTR_FROM_ARCH
+__cvdso_clock_gettime_common(const struct vdso_data *vd, clockid_t clock,
+ struct __kernel_timespec *ts)
+{
+#else
__cvdso_clock_gettime_common(clockid_t clock, struct __kernel_timespec *ts)
{
const struct vdso_data *vd = __arch_get_vdso_data();
+#endif
u32 msk;
/* Check for negative values or invalid clocks */
@@ -131,9 +137,16 @@ __cvdso_clock_gettime_common(clockid_t clock, struct __kernel_timespec *ts)
}
static __maybe_unused int
+#ifdef VDSO_GETS_VD_PTR_FROM_ARCH
+__cvdso_clock_gettime(const struct vdso_data *vd, clockid_t clock,
+ struct __kernel_timespec *ts)
+{
+ int ret = __cvdso_clock_gettime_common(vd, clock, ts);
+#else
__cvdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts)
{
int ret = __cvdso_clock_gettime_common(clock, ts);
+#endif
if (unlikely(ret))
return clock_gettime_fallback(clock, ts);
@@ -141,12 +154,21 @@ __cvdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts)
}
static __maybe_unused int
+#ifdef VDSO_GETS_VD_PTR_FROM_ARCH
+__cvdso_clock_gettime32(const struct vdso_data *vd, clockid_t clock,
+ struct old_timespec32 *res)
+#else
__cvdso_clock_gettime32(clockid_t clock, struct old_timespec32 *res)
+#endif
{
struct __kernel_timespec ts;
int ret;
+#ifdef VDSO_GETS_VD_PTR_FROM_ARCH
+ ret = __cvdso_clock_gettime_common(vd, clock, &ts);
+#else
ret = __cvdso_clock_gettime_common(clock, &ts);
+#endif
#ifdef VDSO_HAS_32BIT_FALLBACK
if (unlikely(ret))
@@ -164,9 +186,15 @@ __cvdso_clock_gettime32(clockid_t clock, struct old_timespec32 *res)
}
static __maybe_unused int
+#ifdef VDSO_GETS_VD_PTR_FROM_ARCH
+__cvdso_gettimeofday(const struct vdso_data *vd, struct __kernel_old_timeval *tv,
+ struct timezone *tz)
+{
+#else
__cvdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
{
const struct vdso_data *vd = __arch_get_vdso_data();
+#endif
if (likely(tv != NULL)) {
struct __kernel_timespec ts;
@@ -187,9 +215,15 @@ __cvdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
}
#ifdef VDSO_HAS_TIME
+#ifdef VDSO_GETS_VD_PTR_FROM_ARCH
+static __maybe_unused __kernel_old_time_t
+__cvdso_time(const struct vdso_data *vd, __kernel_old_time_t *time)
+{
+#else
static __maybe_unused __kernel_old_time_t __cvdso_time(__kernel_old_time_t *time)
{
const struct vdso_data *vd = __arch_get_vdso_data();
+#endif
__kernel_old_time_t t = READ_ONCE(vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec);
if (time)
@@ -201,9 +235,15 @@ static __maybe_unused __kernel_old_time_t __cvdso_time(__kernel_old_time_t *time
#ifdef VDSO_HAS_CLOCK_GETRES
static __maybe_unused
+#ifdef VDSO_GETS_VD_PTR_FROM_ARCH
+int __cvdso_clock_getres_common(const struct vdso_data *vd, clockid_t clock,
+ struct __kernel_timespec *res)
+{
+#else
int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res)
{
const struct vdso_data *vd = __arch_get_vdso_data();
+#endif
u32 msk;
u64 ns;
@@ -238,9 +278,16 @@ int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res)
}
static __maybe_unused
+#ifdef VDSO_GETS_VD_PTR_FROM_ARCH
+int __cvdso_clock_getres(const struct vdso_data *vd, clockid_t clock,
+ struct __kernel_timespec *res)
+{
+ int ret = __cvdso_clock_getres_common(vd, clock, res);
+#else
int __cvdso_clock_getres(clockid_t clock, struct __kernel_timespec *res)
{
int ret = __cvdso_clock_getres_common(clock, res);
+#endif
if (unlikely(ret))
return clock_getres_fallback(clock, res);
@@ -248,12 +295,21 @@ int __cvdso_clock_getres(clockid_t clock, struct __kernel_timespec *res)
}
static __maybe_unused int
+#ifdef VDSO_GETS_VD_PTR_FROM_ARCH
+__cvdso_clock_getres_time32(const struct vdso_data *vd, clockid_t clock,
+ struct old_timespec32 *res)
+#else
__cvdso_clock_getres_time32(clockid_t clock, struct old_timespec32 *res)
+#endif
{
struct __kernel_timespec ts;
int ret;
+#ifdef VDSO_GETS_VD_PTR_FROM_ARCH
+ ret = __cvdso_clock_getres_common(vd, clock, &ts);
+#else
ret = __cvdso_clock_getres_common(clock, &ts);
+#endif
#ifdef VDSO_HAS_32BIT_FALLBACK
if (unlikely(ret))
--
2.13.3
next prev parent reply other threads:[~2020-01-13 17:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-13 17:08 [RFC PATCH v3 00/12] powerpc: switch VDSO to C implementation Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 01/12] powerpc/64: Don't provide time functions in compat VDSO32 Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 02/12] powerpc/vdso: Switch VDSO to generic C implementation Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 03/12] lib: vdso: mark __cvdso_clock_getres() as static Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 04/12] lib: vdso: inline do_hres() and do_coarse() Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 05/12] lib: vdso: Avoid duplication in __cvdso_clock_getres() Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 06/12] lib: vdso: __iter_div_u64_rem() is suboptimal for 32 bit time Christophe Leroy
2020-01-14 11:31 ` Thomas Gleixner
2020-01-13 17:08 ` [RFC PATCH v3 07/12] powerpc/vdso: simplify __get_datapage() Christophe Leroy
2020-01-13 17:08 ` Christophe Leroy [this message]
2020-01-14 23:06 ` [RFC PATCH v3 08/12] lib: vdso: allow arches to provide vdso data pointer Thomas Gleixner
2020-01-15 6:15 ` Christophe Leroy
2020-01-16 9:16 ` Christophe Leroy
2020-01-16 10:35 ` Thomas Gleixner
2020-01-16 20:22 ` Andy Lutomirski
2020-01-13 17:08 ` [RFC PATCH v3 09/12] powerpc/vdso: provide inline alternative to __get_datapage() Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 10/12] powerpc/vdso: provide vdso data pointer from the ASM caller Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 11/12] lib: vdso: split clock verification out of __arch_get_hw_counter() Christophe Leroy
2020-01-13 17:08 ` [RFC PATCH v3 12/12] powerpc/vdso: provide __arch_is_hw_counter_valid() Christophe Leroy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=381e547dbb3c48fd39d6cf208033bba38ad048fb.1578934751.git.christophe.leroy@c-s.fr \
--to=christophe.leroy@c-s.fr \
--cc=arnd@arndb.de \
--cc=benh@kernel.crashing.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=luto@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=tglx@linutronix.de \
--cc=vincenzo.frascino@arm.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).