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 <wim.coekaerts@oracle.com>
Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Tested-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Orabug:
22137842
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);
}