Skip to content

Commit 49a101d

Browse files
chleroyKAGA-KOKO
authored andcommitted
lib/vdso: Only read hrtimer_res when needed in __cvdso_clock_getres()
Only perform READ_ONCE(vd[CS_HRES_COARSE].hrtimer_res) for HRES and RAW clocks. Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/7ac2f0d21652f95e2bbdfa6bd514ae6c7caf53ab.1579196675.git.christophe.leroy@c-s.fr
1 parent 99570c3 commit 49a101d

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

lib/vdso/gettimeofday.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ static __maybe_unused
312312
int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res)
313313
{
314314
const struct vdso_data *vd = __arch_get_vdso_data();
315-
u64 hrtimer_res;
316315
u32 msk;
317316
u64 ns;
318317

@@ -323,7 +322,6 @@ int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res)
323322
if (IS_ENABLED(CONFIG_TIME_NS) && vd->clock_mode == VCLOCK_TIMENS)
324323
vd = __arch_get_timens_vdso_data();
325324

326-
hrtimer_res = READ_ONCE(vd[CS_HRES_COARSE].hrtimer_res);
327325
/*
328326
* Convert the clockid to a bitmask and use it to check which
329327
* clocks are handled in the VDSO directly.
@@ -333,7 +331,7 @@ int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res)
333331
/*
334332
* Preserves the behaviour of posix_get_hrtimer_res().
335333
*/
336-
ns = hrtimer_res;
334+
ns = READ_ONCE(vd[CS_HRES_COARSE].hrtimer_res);
337335
} else if (msk & VDSO_COARSE) {
338336
/*
339337
* Preserves the behaviour of posix_get_coarse_res().

0 commit comments

Comments
 (0)