diff mbox series

[RFC,v4,03/11] lib: vdso: only read hrtimer_res when needed in __cvdso_clock_getres()

Message ID 7ac2f0d21652f95e2bbdfa6bd514ae6c7caf53ab.1579196675.git.christophe.leroy@c-s.fr (mailing list archive)
State RFC
Headers show
Series powerpc: switch VDSO to C implementation. | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/merge (20862247a368dbb75d6e97d82345999adaacf3cc)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/next (3a9d970f17e05a7b26f782beb8f7f2118d1741ea)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linus/master (0c99ee44b8921b872089a7374c733310d995fd92)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch powerpc/fixes (6da3eced8c5f3b03340b0c395bacd552c4d52411)
snowpatch_ozlabs/apply_patch warning Failed to apply on branch linux-next (2747d5fdab78f43210256cd52fb2718e0b3cce74)
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Christophe Leroy Jan. 16, 2020, 5:58 p.m. UTC
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>
---
 lib/vdso/gettimeofday.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c
index 9563be3cb5fa..8b3084d9a3ec 100644
--- a/lib/vdso/gettimeofday.c
+++ b/lib/vdso/gettimeofday.c
@@ -326,7 +326,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;
 
@@ -338,7 +337,6 @@  int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res)
 	    vd->clock_mode == VDSO_CLOCKMODE_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.
@@ -348,7 +346,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().