]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sparc64, vdso: update the CLOCK_MONOTONIC_COARSE clock
authorNick Alcock <nick.alcock@oracle.com>
Mon, 2 Nov 2015 21:44:27 +0000 (21:44 +0000)
committerAllen Pais <allen.pais@oracle.com>
Wed, 4 Nov 2015 09:34:10 +0000 (15:04 +0530)
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

arch/sparc/kernel/vsyscall_gtod.c

index 142cdf6ac7e1643e78ea278cba6932a95540edfd..9020388e4446ceac1bc6e483149a35728facc3d2 100644 (file)
@@ -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);
 }