[PATCH v2 3/3] ARM: arch_timer: use full 64-bit counter for sched_clock

Russell King - ARM Linux linux at arm.linux.org.uk
Fri Apr 19 12:27:02 EDT 2013


On Mon, Apr 01, 2013 at 03:58:34PM -0500, Rob Herring wrote:
> From: Rob Herring <rob.herring at calxeda.com>
> 
> Only 32-bits of the arch timer were being used and wrapping was needlessly
> being done in s/w. By using the full counter (56-64 bits), we don't need
> to deal with wrapping and can simplify the implementation when using
> arch timer.

Remember that you _must_ provide the full 64-bit nsec value to the
scheduler.  A 56-bit value will not do, it has to be the full 64-bits
of nsecs.  So:

> +static unsigned long long notrace arch_timer_sched_clock(void)
>  {
> -	return arch_timer_read_counter();
> +	return arch_timer_read_counter() * sched_clock_mult;
...
> +	/* Cache the sched_clock multiplier to save a divide in the hot path. */
> +	sched_clock_mult = NSEC_PER_SEC / arch_timer_rate;

If the counter is 56-bit and the multiplier is not larger than 255,
then you have a potential problem here.  That basically translates
into a clock rate of no more than 3.9MHz for the architected timer
if it is 56-bit.



More information about the linux-arm-kernel mailing list