From b3e0c78968c31b652d1c22680d4ffb039b139cdf Mon Sep 17 00:00:00 2001 From: Nick Alcock Date: Mon, 2 Nov 2015 21:44:27 +0000 Subject: [PATCH] sparc64, vdso: update the CLOCK_MONOTONIC_COARSE clock In the significant rewrite involved in porting the SPARC vDSO code to v4.1, the CLOCK_MONOTONIC_COARSE clock moved from being computed from the CLOCK_REALTIME variable in the vvar page to being tracked by its own vvar (mirroring a similar change done for x86): this vvar is maintained in the same way, but is derived only once per jiffy tick rather than every time clock_gettime() is called, which is likely faster under sufficiently insane clock_gettime() than the way we did it in v3.0. Unfortunately, the code to maintain this variable in arch/sparc/kernel/vsyscall_gtod.c was never implemented, so clock_gettime(CLOCK_MONOTONIC_COARSE) always returns zero. This is a little coarser than the user would probably like. Easily fixed by updating the relevant vvar in the same way as is done on x86. Reported-by: Wim Coekaerts Signed-off-by: Nick Alcock Reviewed-by: Dave Kleikamp Tested-by: Dave Kleikamp Orabug: 22137842 --- arch/sparc/kernel/vsyscall_gtod.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/sparc/kernel/vsyscall_gtod.c b/arch/sparc/kernel/vsyscall_gtod.c index 142cdf6ac7e1..9020388e4446 100644 --- a/arch/sparc/kernel/vsyscall_gtod.c +++ b/arch/sparc/kernel/vsyscall_gtod.c @@ -55,5 +55,15 @@ void update_vsyscall(struct timekeeper *tk) vdata->wall_time_coarse.tv_nsec = (long)(tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift); + vdata->monotonic_time_coarse.tv_sec = + vdata->wall_time_coarse.tv_sec + tk->wall_to_monotonic.tv_sec; + vdata->monotonic_time_coarse.tv_nsec = + vdata->wall_time_coarse.tv_nsec + tk->wall_to_monotonic.tv_nsec; + + while (vdata->monotonic_time_coarse.tv_nsec >= NSEC_PER_SEC) { + vdata->monotonic_time_coarse.tv_nsec -= NSEC_PER_SEC; + vdata->monotonic_time_coarse.tv_sec++; + } + write_seqcount_end(&vdata->seq); } -- 2.50.1