Skip to content

Commit ffbfb5e

Browse files
bebarinojohnstultz-work
authored andcommitted
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>
1 parent 5a9b585 commit ffbfb5e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎arch/arm/kernel/sched_clock.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ static unsigned long long notrace cyc_to_sched_clock(u32 cyc, u32 mask)
5555
u64 epoch_ns;
5656
u32 epoch_cyc;
5757

58-
if (cd.suspended)
59-
return cd.epoch_ns;
60-
6158
/*
6259
* Load the epoch_cyc and epoch_ns atomically. We do this by
6360
* ensuring that we always write epoch_cyc, epoch_ns and
@@ -174,6 +171,9 @@ unsigned long long __read_mostly (*sched_clock_func)(void) = sched_clock_32;
174171

175172
unsigned long long notrace sched_clock(void)
176173
{
174+
if (cd.suspended)
175+
return cd.epoch_ns;
176+
177177
return sched_clock_func();
178178
}
179179

0 commit comments

Comments
 (0)