]> git.itanic.dy.fi Git - linux-stable/commit
sched, x86: Avoid unnecessary overflow in sched_clock
authorSalman Qazi <sqazi@google.com>
Tue, 15 Nov 2011 22:12:06 +0000 (14:12 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 9 Dec 2011 16:55:42 +0000 (08:55 -0800)
commit3ef3c3830482a5de31781a5dca2a9bd7ef6d1562
tree11b4bcf5a9a0d647626fdfcbb610b0f52d512549
parentba92f7efc8390db5ed6da4966ef943718eb048b7
sched, x86: Avoid unnecessary overflow in sched_clock

commit 4cecf6d401a01d054afc1e5f605bcbfe553cb9b9 upstream.

(Added the missing signed-off-by line)

In hundreds of days, the __cycles_2_ns calculation in sched_clock
has an overflow.  cyc * per_cpu(cyc2ns, cpu) exceeds 64 bits, causing
the final value to become zero.  We can solve this without losing
any precision.

We can decompose TSC into quotient and remainder of division by the
scale factor, and then use this to convert TSC into nanoseconds.

Signed-off-by: Salman Qazi <sqazi@google.com>
Acked-by: John Stultz <johnstul@us.ibm.com>
Reviewed-by: Paul Turner <pjt@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20111115221121.7262.88871.stgit@dungbeetle.mtv.corp.google.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/include/asm/timer.h