linux/arch
Russell King 112f38a4a3 ARM: sched_clock: provide common infrastructure for sched_clock()
Provide common sched_clock() infrastructure for platforms to use to
create a 64-bit ns based sched_clock() implementation from a counter
running at a non-variable clock rate.

This implementation is based upon maintaining an epoch for the counter
and an epoch for the nanosecond time.  When we desire a sched_clock()
time, we calculate the number of counter ticks since the last epoch
update, convert this to nanoseconds and add to the epoch nanoseconds.

We regularly refresh these epochs within the counter wrap interval.
We perform a similar calculation as above, and store the new epochs.

We read and write the epochs in such a way that sched_clock() can easily
(and locklessly) detect when an update is in progress, and repeat the
loading of these constants when they're known not to be stable.  The
one caveat is that sched_clock() is not called in the middle of an
update.  We achieve that by disabling IRQs.

Finally, if the clock rate is known at compile time, the counter to ns
conversion factors can be specified, allowing sched_clock() to be tightly
optimized.  We ensure that these factors are correct by providing an
initialization function which performs a run-time check.

Acked-by: Peter Zijlstra <peterz@infradead.org>
Tested-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Tested-by: Will Deacon <will.deacon@arm.com>
Tested-by: Mikael Pettersson <mikpe@it.uu.se>
Tested-by: Eric Miao <eric.y.miao@gmail.com>
Tested-by: Olof Johansson <olof@lixom.net>
Tested-by: Jamie Iles <jamie@jamieiles.com>
Reviewed-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2010-12-22 22:44:43 +00:00
..
alpha Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2010-10-28 16:16:39 -07:00
arm ARM: sched_clock: provide common infrastructure for sched_clock() 2010-12-22 22:44:43 +00:00
avr32 Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2010-10-28 16:16:39 -07:00
blackfin BKL: remove extraneous #include <smp_lock.h> 2010-11-17 08:59:32 -08:00
cris Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2010-10-28 16:16:39 -07:00
frv BKL: remove extraneous #include <smp_lock.h> 2010-11-17 08:59:32 -08:00
h8300 BKL: remove extraneous #include <smp_lock.h> 2010-11-17 08:59:32 -08:00
ia64 SCSI host lock push-down 2010-11-16 13:33:23 -08:00
m32r Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2010-10-28 16:16:39 -07:00
m68k BKL: remove extraneous #include <smp_lock.h> 2010-11-17 08:59:32 -08:00
m68knommu BKL: remove extraneous #include <smp_lock.h> 2010-11-17 08:59:32 -08:00
microblaze Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2010-10-28 16:16:39 -07:00
mips Merge git://git.infradead.org/mtd-2.6 2010-10-30 08:31:35 -07:00
mn10300 BKL: remove extraneous #include <smp_lock.h> 2010-11-17 08:59:32 -08:00
parisc BKL: remove extraneous #include <smp_lock.h> 2010-11-17 08:59:32 -08:00
powerpc Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/linux-2.6-kgdb 2010-11-18 08:24:58 -08:00
s390 BKL: remove extraneous #include <smp_lock.h> 2010-11-17 08:59:32 -08:00
score Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2010-10-28 16:16:39 -07:00
sh sh: Use GCC __builtin_prefetch() to implement prefetch(). 2010-11-18 14:53:18 +09:00
sparc BKL: remove extraneous #include <smp_lock.h> 2010-11-17 08:59:32 -08:00
tile Merge git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile 2010-11-25 07:42:32 +09:00
um uml: disable winch irq before freeing handler data 2010-11-25 06:50:39 +09:00
x86 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen 2010-11-25 08:35:53 +09:00
xtensa Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6 2010-10-28 16:16:39 -07:00
.gitignore
Kconfig jump label: Add work around to i386 gcc asm goto bug 2010-10-29 14:45:29 -04:00