lib/vdso: Only read hrtimer_res when needed in __cvdso_clock_getres()
authorChristophe Leroy <christophe.leroy@c-s.fr>
Thu, 16 Jan 2020 17:58:27 +0000 (17:58 +0000)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 16 Jan 2020 20:24:46 +0000 (21:24 +0100)
Only perform READ_ONCE(vd[CS_HRES_COARSE].hrtimer_res) for
HRES and RAW clocks.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/7ac2f0d21652f95e2bbdfa6bd514ae6c7caf53ab.1579196675.git.christophe.leroy@c-s.fr
lib/vdso/gettimeofday.c

index f342ac1fce774e83c6032670264c6292ff153545..f8b8ec5e63aca5e5ffcbf2de5c902c0080cf84b0 100644 (file)
@@ -312,7 +312,6 @@ static __maybe_unused
 int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res)
 {
        const struct vdso_data *vd = __arch_get_vdso_data();
-       u64 hrtimer_res;
        u32 msk;
        u64 ns;
 
@@ -323,7 +322,6 @@ int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res)
        if (IS_ENABLED(CONFIG_TIME_NS) && vd->clock_mode == VCLOCK_TIMENS)
                vd = __arch_get_timens_vdso_data();
 
-       hrtimer_res = READ_ONCE(vd[CS_HRES_COARSE].hrtimer_res);
        /*
         * Convert the clockid to a bitmask and use it to check which
         * clocks are handled in the VDSO directly.
@@ -333,7 +331,7 @@ int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res)
                /*
                 * Preserves the behaviour of posix_get_hrtimer_res().
                 */
-               ns = hrtimer_res;
+               ns = READ_ONCE(vd[CS_HRES_COARSE].hrtimer_res);
        } else if (msk & VDSO_COARSE) {
                /*
                 * Preserves the behaviour of posix_get_coarse_res().