linux/arch/arm/kernel
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
..
.gitignore
armksyms.c ARM: 6314/1: ftrace: allow build without frame pointers on ARM 2010-09-02 15:24:53 +01:00
arthur.c
asm-offsets.c arm: remove machine_desc.io_pg_offst and .phys_io 2010-10-20 00:27:46 -04:00
atags.c
atags.h
bios32.c ARM: 6058/1: Add support for PCI domains 2010-04-22 21:38:11 +01:00
calls.S ARM: 6343/1: wire up fanotify and prlimit64 syscalls on ARM 2010-09-01 10:06:08 +01:00
compat.c ARM: deprecate support for old way to pass kernel parameters 2010-07-07 16:38:36 +02:00
compat.h ARM: deprecate support for old way to pass kernel parameters 2010-07-07 16:38:36 +02:00
crash_dump.c ARM: 6120/1: kdump: implement copy_oldmem_page() 2010-07-09 15:00:53 +01:00
crunch-bits.S
crunch.c
debug.S arm: return both physical and virtual addresses from addruart 2010-10-20 00:27:33 -04:00
dma-isa.c
dma.c ARM: dma: add /proc/dma support to arch/arm/kernel/dma.c 2010-04-14 13:13:30 +01:00
early_printk.c
ecard.c
ecard.h
elf.c
entry-armv.S ARM: Allow SMP kernels to boot on UP systems 2010-10-04 20:23:36 +01:00
entry-common.S ARM: ftrace: graph tracer + dynamic ftrace 2010-11-19 21:43:27 +05:30
entry-header.S ARM: 5991/1: Fix regression in restore_user_regs macro 2010-03-15 17:20:08 +00:00
etm.c Merge branch 'llseek' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl 2010-10-22 10:52:56 -07:00
fiq.c
ftrace.c ARM: ftrace: graph tracer + dynamic ftrace 2010-11-19 21:43:27 +05:30
head-common.S Merge branch 'hotplug' into devel 2010-10-18 22:34:47 +01:00
head-nommu.S ARM: no need for nommu to jump through the hoops that mmu does 2010-10-08 10:07:27 +01:00
head.S arm: use addruart macro to establish debug mappings 2010-10-20 00:27:34 -04:00
hw_breakpoint.c ARM: arch/arm/kernel/hw_breakpoint.c: Convert WARN_ON to WARN 2010-11-07 17:58:39 +00:00
init_task.c
io.c
irq.c ARM: place C irq handlers in IRQ_ENTRY for ftrace 2010-11-19 21:43:26 +05:30
isa.c
iwmmxt.S
kgdb.c kgdb,arm: fix register dump 2010-10-29 13:14:40 -05:00
kprobes-decode.c ARM: 6412/1: kprobes-decode: add support for MOVW instruction 2010-10-04 19:21:37 +01:00
kprobes.c Merge branch 'master' into export-slabh 2010-04-05 11:37:28 +09:00
leds.c
machine_kexec.c arm: Disable outer (L2) cache in kexec 2010-10-26 11:39:56 +05:30
Makefile ARM: sched_clock: provide common infrastructure for sched_clock() 2010-12-22 22:44:43 +00:00
module.c ARM: 6340/1: module - additional unwind tables for exit/devexit sections 2010-09-02 15:31:35 +01:00
perf_event.c ARM: perf: separate PMU backends into multiple files 2010-11-25 16:52:08 +00:00
perf_event_v6.c ARM: perf: separate PMU backends into multiple files 2010-11-25 16:52:08 +00:00
perf_event_v7.c ARM: perf: separate PMU backends into multiple files 2010-11-25 16:52:08 +00:00
perf_event_xscale.c ARM: perf: separate PMU backends into multiple files 2010-11-25 16:52:08 +00:00
pmu.c ARM: 6064/1: pmu: register IRQs at runtime 2010-05-17 11:53:57 +01:00
process.c Merge branch 'devel-stable' into devel 2010-10-19 22:06:36 +01:00
ptrace.c ptrace: cleanup arch_ptrace() on ARM 2010-10-27 18:03:10 -07:00
ptrace.h arm: use generic ptrace_resume code 2010-03-12 15:52:38 -08:00
relocate_kernel.S ARM: 6119/1: kdump: skip indirection page when crashing 2010-07-09 15:00:52 +01:00
return_address.c
sched_clock.c ARM: sched_clock: provide common infrastructure for sched_clock() 2010-12-22 22:44:43 +00:00
setup.c Merge branches 'at91', 'dcache', 'ftrace', 'hwbpt', 'misc', 'mmci', 's3c', 'st-ux' and 'unwind' into devel 2010-10-18 22:34:25 +01:00
signal.c ARM: 6051/1: VFP: preserve the HW context when calling signal handlers 2010-04-14 11:11:30 +01:00
signal.h
smp.c ARM: place C irq handlers in IRQ_ENTRY for ftrace 2010-11-19 21:43:26 +05:30
smp_scu.c
smp_twd.c ARM: SMP: Always enable clock event broadcast support 2010-07-27 10:48:42 +01:00
stacktrace.c ARM: 6468/1: backtrace: fix calculation of thread stack base 2010-11-07 16:12:37 +00:00
sys_arm.c Make do_execve() take a const filename pointer 2010-08-17 18:07:43 -07:00
sys_oabi-compat.c Mark arguments to certain syscalls as being const 2010-08-13 16:53:13 -07:00
tcm.c ARM: 6225/1: make TCM allocation static and common for all archs 2010-07-27 10:42:38 +01:00
tcm.h
thumbee.c
time.c ARM: convert arm to arch_gettimeoffset() 2010-03-24 08:08:58 +00:00
traps.c ARM: arch/arm/kernel/traps.c: Convert sprintf_symbol to %pS 2010-11-07 17:58:40 +00:00
unwind.c ARM: 6468/1: backtrace: fix calculation of thread stack base 2010-11-07 16:12:37 +00:00
vmlinux.lds.S ARM: place C irq handlers in IRQ_ENTRY for ftrace 2010-11-19 21:43:26 +05:30
xscale-cp0.c