Skip to content

64-bit sched_clock

Russell King - ARM Linux linux-arm-kernel linux-omap 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest13 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13ARM: sched_clock: provide common infrastructure for sched_clock()arch/arm/Kconfig arch/arm/include/asm/sched_clock.h arch/arm/kernel/Makefile +1 more+189 -00 replies
1/13ARM: sched_clock: provide common infrastructure for sched_clock()arch/arm/Kconfig arch/arm/include/asm/sched_clock.h arch/arm/kernel/Makefile +1 more+188 -00 replies
2/13ARM: ixp4xx: convert sched_clock() to use new infrastructurearch/arm/Kconfig arch/arm/mach-ixp4xx/common.c+21 -110 replies
3/13ARM: mmp: convert sched_clock() to use new infrastructurearch/arm/Kconfig arch/arm/mach-mmp/time.c+12 -210 replies
4/13ARM: pxa: convert sched_clock() to use new infrastructurearch/arm/Kconfig arch/arm/mach-pxa/time.c+10 -201 reply
4/13ARM: pxa: convert sched_clock() to use new infrastructure+0 -00 replies
5/13ARM: sa1100: convert sched_clock() to use new infrastructurearch/arm/Kconfig arch/arm/mach-sa1100/generic.c arch/arm/mach-sa1100/time.c+31 -230 replies
6/13ARM: tegra: convert sched_clock() to use new infrastructurearch/arm/Kconfig arch/arm/mach-tegra/timer.c+21 -20 replies
7/13ARM: u300: convert sched_clock() to use new infrastructurearch/arm/Kconfig arch/arm/mach-u300/timer.c+14 -40 replies
8/13ARM: iop: convert sched_clock() to use new infrastructurearch/arm/Kconfig arch/arm/plat-iop/time.c+12 -30 replies
9/13ARM: nomadik: convert sched_clock() to use new infrastructurearch/arm/plat-nomadik/Kconfig arch/arm/plat-nomadik/timer.c+10 -670 replies
10/13ARM: omap: convert sched_clock() to use new infrastructurearch/arm/Kconfig arch/arm/plat-omap/counter_32k.c+23 -20 replies
11/13ARM: orion: convert sched_clock() to use new infrastructurearch/arm/Kconfig arch/arm/plat-orion/time.c+10 -350 replies
12/13ARM: versatile: convert sched_clock() to use new infrastructurearch/arm/Kconfig arch/arm/mach-realview/core.c arch/arm/mach-versatile/core.c +2 more+54 -220 replies
13/13ARM: vexpress: add sched_clock() for Versatile Expressarch/arm/Kconfig arch/arm/mach-vexpress/v2m.c arch/arm/plat-versatile/Makefile+6 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/13] 64-bit sched_clock

This patch series replaces existing sched_clock() implementations with a version which gives a full 64-bit nanosecond time from counters with less than 33 bits.

This series depends on the prevously posted clocksource patch series, and the notrace sched_clock patch, and the ftrace tree previously merged into my devel-stable branch. It also depends on a fix to the clocksource code to achieve the accuracy quoted below - though it'll build and work without.

We achieve the 64-bit nanosecond time by maintaining a pair of epochs - one for the counter and a corresponding one for the ns value. This allows us to calculate how many counter ticks have happened since the ns epoch was last updated, and therefore how much time has passed.

We use a lockless method to read and update the epoch values, eliminating any locking overhead. The epoch update happens at about 90% of the wrap period, resulting in less maintainence overhead.

Lastly, we allow platforms to provide constants for the counter->ns conversion.

The PXA sched_clock implementation using cnt32_to_63() builds to 72 bytes of code and 12 bytes of data, and provides 54 bits of nanoseconds, with an error of 0.00008%.

The PXA sched_clock implementation using this infrastructure builds to 84 bytes of code and 8 bytes of data, and provides 64 bits of nanoseconds, with an error of 0.00000002%.

The epoch updates in action on Versatile Express (24MHz 32-bit counter):

sched_clock: update 68391420 -> 50e0a246 0ns -> 162637292211ns
sched_clock: update 50e0a246 -> 372c24b7 162637292211ns -> 323625136880ns
sched_clock: update 372c24b7 -> 1d35c46a 323625136880ns -> 484433069633ns
sched_clock: update 1d35c46a -> 0367a736 484433069633ns -> 645350944761ns
...
sched_clock: update f6f7fd55 -> dd2d882e 32669955162290ns -> 32830883021959ns
sched_clock: update dd2d882e -> c36312cd 32830883021959ns -> 32991810879212ns
sched_clock: update c36312cd -> a9989d41 32991810879212ns -> 33152738734673ns
sched_clock: update a9989d41 -> 8fce2781 33152738734673ns -> 33313666587967ns