Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: sched_clock: Return suspended count earlier

If we're suspended and sched_clock() is called we're going to
read the hardware one more time and throw away that value and
return back the cached value we saved during the suspend
callback. This is wasteful. Let's short circuit all that and
return the cached value as early as possible if we're suspended.

Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>

authored by

Stephen Boyd and committed by
John Stultz
ffbfb5e3 5a9b5855

+3 -3
+3 -3
arch/arm/kernel/sched_clock.c
··· 55 55 u64 epoch_ns; 56 56 u32 epoch_cyc; 57 57 58 - if (cd.suspended) 59 - return cd.epoch_ns; 60 - 61 58 /* 62 59 * Load the epoch_cyc and epoch_ns atomically. We do this by 63 60 * ensuring that we always write epoch_cyc, epoch_ns and ··· 171 174 172 175 unsigned long long notrace sched_clock(void) 173 176 { 177 + if (cd.suspended) 178 + return cd.epoch_ns; 179 + 174 180 return sched_clock_func(); 175 181 } 176 182