[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-e9a62f76f93c6f28b6c7e908eb12e5f1313870a2@git.kernel.org>
Date: Thu, 4 Oct 2018 14:06:45 -0700
From: tip-bot for Thomas Gleixner <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, sboyd@...nel.org,
john.stultz@...aro.org, kys@...rosoft.com, pbonzini@...hat.com,
peterz@...radead.org, fweimer@...hat.com, matt@...trans.com.au,
jgross@...e.com, hpa@...or.com, vkuznets@...hat.com, arnd@...db.de,
luto@...nel.org, tglx@...utronix.de, mingo@...nel.org
Subject: [tip:x86/vdso] x86/vdso: Collapse high resolution functions
Commit-ID: e9a62f76f93c6f28b6c7e908eb12e5f1313870a2
Gitweb: https://git.kernel.org/tip/e9a62f76f93c6f28b6c7e908eb12e5f1313870a2
Author: Thomas Gleixner <tglx@...utronix.de>
AuthorDate: Mon, 17 Sep 2018 14:45:39 +0200
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitDate: Thu, 4 Oct 2018 23:00:25 +0200
x86/vdso: Collapse high resolution functions
do_realtime() and do_monotonic() are now the same except for the storage
array index. Hand the index in as an argument and collapse the functions.
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Acked-by: Andy Lutomirski <luto@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Matt Rickard <matt@...trans.com.au>
Cc: Stephen Boyd <sboyd@...nel.org>
Cc: John Stultz <john.stultz@...aro.org>
Cc: Florian Weimer <fweimer@...hat.com>
Cc: "K. Y. Srinivasan" <kys@...rosoft.com>
Cc: Vitaly Kuznetsov <vkuznets@...hat.com>
Cc: devel@...uxdriverproject.org
Cc: virtualization@...ts.linux-foundation.org
Cc: Paolo Bonzini <pbonzini@...hat.com>
Cc: Arnd Bergmann <arnd@...db.de>
Cc: Juergen Gross <jgross@...e.com>
Link: https://lkml.kernel.org/r/20180917130707.407955860@linutronix.de
---
arch/x86/entry/vdso/vclock_gettime.c | 35 +++++++----------------------------
1 file changed, 7 insertions(+), 28 deletions(-)
diff --git a/arch/x86/entry/vdso/vclock_gettime.c b/arch/x86/entry/vdso/vclock_gettime.c
index 2c73e7f57316..1351b76638fb 100644
--- a/arch/x86/entry/vdso/vclock_gettime.c
+++ b/arch/x86/entry/vdso/vclock_gettime.c
@@ -205,35 +205,12 @@ notrace static inline u64 vgetsns(int *mode)
return v * gtod->mult;
}
-/* Code size doesn't matter (vdso is 4k anyway) and this is faster. */
-notrace static int __always_inline do_realtime(struct timespec *ts)
+notrace static int do_hres(clockid_t clk, struct timespec *ts)
{
- struct vgtod_ts *base = >od->basetime[CLOCK_REALTIME];
+ struct vgtod_ts *base = >od->basetime[clk];
unsigned int seq;
- u64 ns;
int mode;
-
- do {
- seq = gtod_read_begin(gtod);
- mode = gtod->vclock_mode;
- ts->tv_sec = base->sec;
- ns = base->nsec;
- ns += vgetsns(&mode);
- ns >>= gtod->shift;
- } while (unlikely(gtod_read_retry(gtod, seq)));
-
- ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns);
- ts->tv_nsec = ns;
-
- return mode;
-}
-
-notrace static int __always_inline do_monotonic(struct timespec *ts)
-{
- struct vgtod_ts *base = >od->basetime[CLOCK_MONOTONIC];
- unsigned int seq;
u64 ns;
- int mode;
do {
seq = gtod_read_begin(gtod);
@@ -278,11 +255,11 @@ notrace int __vdso_clock_gettime(clockid_t clock, struct timespec *ts)
{
switch (clock) {
case CLOCK_REALTIME:
- if (do_realtime(ts) == VCLOCK_NONE)
+ if (do_hres(CLOCK_REALTIME, ts) == VCLOCK_NONE)
goto fallback;
break;
case CLOCK_MONOTONIC:
- if (do_monotonic(ts) == VCLOCK_NONE)
+ if (do_hres(CLOCK_MONOTONIC, ts) == VCLOCK_NONE)
goto fallback;
break;
case CLOCK_REALTIME_COARSE:
@@ -305,7 +282,9 @@ int clock_gettime(clockid_t, struct timespec *)
notrace int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
{
if (likely(tv != NULL)) {
- if (unlikely(do_realtime((struct timespec *)tv) == VCLOCK_NONE))
+ struct timespec *ts = (struct timespec *) tv;
+
+ if (unlikely(do_hres(CLOCK_REALTIME, ts) == VCLOCK_NONE))
return vdso_fallback_gtod(tv, tz);
tv->tv_usec /= 1000;
}
Powered by blists - more mailing lists