]> Pileus Git - ~andy/linux/blobdiff - arch/x86/vdso/vclock_gettime.c
time: Convert x86_64 to using new update_vsyscall
[~andy/linux] / arch / x86 / vdso / vclock_gettime.c
index 885eff49d6abe61c2bdfc3c6673acb69678f161b..4df6c373421a435dfeac34d68407ce10602d688d 100644 (file)
@@ -80,7 +80,7 @@ notrace static long vdso_fallback_gtod(struct timeval *tv, struct timezone *tz)
 }
 
 
-notrace static inline long vgetns(void)
+notrace static inline u64 vgetsns(void)
 {
        long v;
        cycles_t cycles;
@@ -91,21 +91,24 @@ notrace static inline long vgetns(void)
        else
                return 0;
        v = (cycles - gtod->clock.cycle_last) & gtod->clock.mask;
-       return (v * gtod->clock.mult) >> gtod->clock.shift;
+       return v * gtod->clock.mult;
 }
 
 /* Code size doesn't matter (vdso is 4k anyway) and this is faster. */
 notrace static int __always_inline do_realtime(struct timespec *ts)
 {
-       unsigned long seq, ns;
+       unsigned long seq;
+       u64 ns;
        int mode;
 
+       ts->tv_nsec = 0;
        do {
                seq = read_seqcount_begin(&gtod->seq);
                mode = gtod->clock.vclock_mode;
                ts->tv_sec = gtod->wall_time_sec;
-               ts->tv_nsec = gtod->wall_time_nsec;
-               ns = vgetns();
+               ns = gtod->wall_time_snsec;
+               ns += vgetsns();
+               ns >>= gtod->clock.shift;
        } while (unlikely(read_seqcount_retry(&gtod->seq, seq)));
 
        timespec_add_ns(ts, ns);
@@ -114,15 +117,18 @@ notrace static int __always_inline do_realtime(struct timespec *ts)
 
 notrace static int do_monotonic(struct timespec *ts)
 {
-       unsigned long seq, ns;
+       unsigned long seq;
+       u64 ns;
        int mode;
 
+       ts->tv_nsec = 0;
        do {
                seq = read_seqcount_begin(&gtod->seq);
                mode = gtod->clock.vclock_mode;
                ts->tv_sec = gtod->monotonic_time_sec;
-               ts->tv_nsec = gtod->monotonic_time_nsec;
-               ns = vgetns();
+               ns = gtod->monotonic_time_snsec;
+               ns += vgetsns();
+               ns >>= gtod->clock.shift;
        } while (unlikely(read_seqcount_retry(&gtod->seq, seq)));
        timespec_add_ns(ts, ns);