Skip to content

Commit e9a62f7

Browse files
committed
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@linutronix.de> Acked-by: Andy Lutomirski <luto@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Matt Rickard <matt@softrans.com.au> Cc: Stephen Boyd <sboyd@kernel.org> Cc: John Stultz <john.stultz@linaro.org> Cc: Florian Weimer <fweimer@redhat.com> Cc: "K. Y. Srinivasan" <kys@microsoft.com> Cc: Vitaly Kuznetsov <vkuznets@redhat.com> Cc: devel@linuxdriverproject.org Cc: virtualization@lists.linux-foundation.org Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Juergen Gross <jgross@suse.com> Link: https://lkml.kernel.org/r/20180917130707.407955860@linutronix.de
1 parent 49116f2 commit e9a62f7

File tree

1 file changed

+7
-28
lines changed

1 file changed

+7
-28
lines changed

arch/x86/entry/vdso/vclock_gettime.c

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -205,35 +205,12 @@ notrace static inline u64 vgetsns(int *mode)
205205
return v * gtod->mult;
206206
}
207207

208-
/* Code size doesn't matter (vdso is 4k anyway) and this is faster. */
209-
notrace static int __always_inline do_realtime(struct timespec *ts)
208+
notrace static int do_hres(clockid_t clk, struct timespec *ts)
210209
{
211-
struct vgtod_ts *base = &gtod->basetime[CLOCK_REALTIME];
210+
struct vgtod_ts *base = &gtod->basetime[clk];
212211
unsigned int seq;
213-
u64 ns;
214212
int mode;
215-
216-
do {
217-
seq = gtod_read_begin(gtod);
218-
mode = gtod->vclock_mode;
219-
ts->tv_sec = base->sec;
220-
ns = base->nsec;
221-
ns += vgetsns(&mode);
222-
ns >>= gtod->shift;
223-
} while (unlikely(gtod_read_retry(gtod, seq)));
224-
225-
ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns);
226-
ts->tv_nsec = ns;
227-
228-
return mode;
229-
}
230-
231-
notrace static int __always_inline do_monotonic(struct timespec *ts)
232-
{
233-
struct vgtod_ts *base = &gtod->basetime[CLOCK_MONOTONIC];
234-
unsigned int seq;
235213
u64 ns;
236-
int mode;
237214

238215
do {
239216
seq = gtod_read_begin(gtod);
@@ -278,11 +255,11 @@ notrace int __vdso_clock_gettime(clockid_t clock, struct timespec *ts)
278255
{
279256
switch (clock) {
280257
case CLOCK_REALTIME:
281-
if (do_realtime(ts) == VCLOCK_NONE)
258+
if (do_hres(CLOCK_REALTIME, ts) == VCLOCK_NONE)
282259
goto fallback;
283260
break;
284261
case CLOCK_MONOTONIC:
285-
if (do_monotonic(ts) == VCLOCK_NONE)
262+
if (do_hres(CLOCK_MONOTONIC, ts) == VCLOCK_NONE)
286263
goto fallback;
287264
break;
288265
case CLOCK_REALTIME_COARSE:
@@ -305,7 +282,9 @@ int clock_gettime(clockid_t, struct timespec *)
305282
notrace int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
306283
{
307284
if (likely(tv != NULL)) {
308-
if (unlikely(do_realtime((struct timespec *)tv) == VCLOCK_NONE))
285+
struct timespec *ts = (struct timespec *) tv;
286+
287+
if (unlikely(do_hres(CLOCK_REALTIME, ts) == VCLOCK_NONE))
309288
return vdso_fallback_gtod(tv, tz);
310289
tv->tv_usec /= 1000;
311290
}

0 commit comments

Comments
 (0)