Re: [PATCH] ARM: sched_clock: Load cycle count after epoch stabilizes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2014/11/28 0:15, Greg KH wrote:
On Thu, Nov 27, 2014 at 11:15:36AM +0000, xiaofeng.yan wrote:
From: Stephen Boyd <sboyd@xxxxxxxxxxxxxx>

There is a small race between when the cycle count is read from
the hardware and when the epoch stabilizes. Consider this
scenario:

  CPU0                           CPU1
  ----                           ----
  cyc = read_sched_clock()
  cyc_to_sched_clock()
                                  update_sched_clock()
                                   ...
                                   cd.epoch_cyc = cyc;
   epoch_cyc = cd.epoch_cyc;
   ...
   epoch_ns + cyc_to_ns((cyc - epoch_cyc)

The cyc on cpu0 was read before the epoch changed. But we
calculate the nanoseconds based on the new epoch by subtracting
the new epoch from the old cycle count. Since epoch is most likely
larger than the old cycle count we calculate a large number that
will be converted to nanoseconds and added to epoch_ns, causing
time to jump forward too much.

Fix this problem by reading the hardware after the epoch has
stabilized.

Cc: Russell King <linux@xxxxxxxxxxxxxxxx>
Signed-off-by: Stephen Boyd <sboyd@xxxxxxxxxxxxxx>
Signed-off-by: John Stultz <john.stultz@xxxxxxxxxx>
---
  kernel/time/sched_clock.c |   19 ++++++++-----------
  1 file changed, 8 insertions(+), 11 deletions(-)
What is the git commit id of this patch in Linus's tree?
yes
And what stable tree(s) do you want it applied to?
Thanks for your reminder, I will add stable tree information.
thanks,

greg k-h

.



--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]