Skip to content

Commit dc01c9f

Browse files
KAGA-KOKOjohnstultz-work
authored andcommitted
tile: Convert VDSO timekeeping to the precise mechanism
The code was only halfarsed converted to the new VSDO update mechanism and still uses the inaccurate base value which lacks the fractional part of xtime_nsec. Fix it up. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: John Stultz <[email protected]>
1 parent 988b0c5 commit dc01c9f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

arch/tile/kernel/time.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ void update_vsyscall_tz(void)
260260

261261
void update_vsyscall(struct timekeeper *tk)
262262
{
263-
struct timespec wall_time = tk_xtime(tk);
264263
struct timespec *wtm = &tk->wall_to_monotonic;
265264
struct clocksource *clock = tk->clock;
266265

@@ -271,12 +270,12 @@ void update_vsyscall(struct timekeeper *tk)
271270
++vdso_data->tb_update_count;
272271
smp_wmb();
273272
vdso_data->xtime_tod_stamp = clock->cycle_last;
274-
vdso_data->xtime_clock_sec = wall_time.tv_sec;
275-
vdso_data->xtime_clock_nsec = wall_time.tv_nsec;
273+
vdso_data->xtime_clock_sec = tk->xtime_sec;
274+
vdso_data->xtime_clock_nsec = tk->xtime_nsec;
276275
vdso_data->wtom_clock_sec = wtm->tv_sec;
277276
vdso_data->wtom_clock_nsec = wtm->tv_nsec;
278-
vdso_data->mult = clock->mult;
279-
vdso_data->shift = clock->shift;
277+
vdso_data->mult = tk->mult;
278+
vdso_data->shift = tk->shift;
280279
smp_wmb();
281280
++vdso_data->tb_update_count;
282281
}

arch/tile/kernel/vdso/vgettimeofday.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
8383
if (count & 1)
8484
continue;
8585

86-
cycles = (get_cycles() - vdso_data->xtime_tod_stamp);
87-
ns = (cycles * vdso_data->mult) >> vdso_data->shift;
8886
sec = vdso_data->xtime_clock_sec;
89-
ns += vdso_data->xtime_clock_nsec;
87+
cycles = get_cycles() - vdso_data->xtime_tod_stamp;
88+
ns = (cycles * vdso_data->mult) + vdso_data->xtime_clock_nsec;
89+
ns >>= vdso_data->shift;
90+
9091
if (ns >= NSEC_PER_SEC) {
9192
ns -= NSEC_PER_SEC;
9293
sec += 1;

0 commit comments

Comments
 (0)