android_kernel_google_msm/arch
Stephen Boyd 068766520e ARM: sched_clock: Load cycle count after epoch stabilizes
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.

Change-Id: I995133b229b2c2fedd5091406d1dc366d8bfff7b
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Git-commit: 336ae1180d
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[sboyd: reworked for file movement kernel/time -> arm/kernel]
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
2016-10-29 23:12:17 +08:00
..
alpha
arm ARM: sched_clock: Load cycle count after epoch stabilizes 2016-10-29 23:12:17 +08:00
avr32
blackfin
c6x
cris
frv
h8300
hexagon Update copyright to The Linux Foundation 2013-03-15 17:07:39 -07:00
ia64 random: remove rand_initialize_irq() 2013-09-09 17:01:42 -07:00
m32r
m68k
microblaze seccomp: ignore secure_computing return values 2014-10-31 19:46:19 -07:00
mips seccomp: ignore secure_computing return values 2014-10-31 19:46:19 -07:00
mn10300
openrisc
parisc
powerpc seccomp: ignore secure_computing return values 2014-10-31 19:46:19 -07:00
s390 seccomp: ignore secure_computing return values 2014-10-31 19:46:19 -07:00
score
sh seccomp: ignore secure_computing return values 2014-10-31 19:46:19 -07:00
sparc seccomp: ignore secure_computing return values 2014-10-31 19:46:19 -07:00
tile
um um: add missing declaration of 'getrlimit()' and friends 2015-05-20 15:22:06 +09:00
unicore32
x86 seccomp: add "seccomp" syscall 2014-10-31 19:46:27 -07:00
xtensa
.gitignore
Kconfig seccomp: add "seccomp" syscall 2014-10-31 19:46:27 -07:00