Skip to content

Commit

Permalink
ARM: sched_clock: Return suspended count earlier
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stephen Boyd authored and John Stultz committed Jun 12, 2013
1 parent 5a9b585 commit ffbfb5e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arch/arm/kernel/sched_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ static unsigned long long notrace cyc_to_sched_clock(u32 cyc, u32 mask)
u64 epoch_ns;
u32 epoch_cyc;

if (cd.suspended)
return cd.epoch_ns;

/*
* Load the epoch_cyc and epoch_ns atomically. We do this by
* ensuring that we always write epoch_cyc, epoch_ns and
Expand Down Expand Up @@ -174,6 +171,9 @@ unsigned long long __read_mostly (*sched_clock_func)(void) = sched_clock_32;

unsigned long long notrace sched_clock(void)
{
if (cd.suspended)
return cd.epoch_ns;

return sched_clock_func();
}

Expand Down

0 comments on commit ffbfb5e

Please sign in to comment.