提交 9dbafa53 编写于 作者: J Jan Glauber 提交者: Linus Torvalds

[PATCH] s390: overflow in sched_clock

The least significant bit of the TOD clock value returned by get_clock
is the 4096th part of a microsecond. To get to nanoseconds the value
needs to be divided by 4096 and multiplied with 1000.

The current method multiplies first and then shifts the value to make the
result as precise as possible.  The disadvantage is that the multiplication
with 1000 will overflow shortly after 52 days.  sched_clock is used by the
scheduler for time stamp deltas, if an overflow occurs between two time stamps
the scheduler will get confused.

With the patch the problem occurs only after approx.  one year, so the chance
to run into this overflow is extremly low.
Signed-off-by: NJan Glauber <jan.glauber@de.ibm.com>
Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 e018ba1f
......@@ -61,7 +61,7 @@ extern unsigned long wall_jiffies;
*/
unsigned long long sched_clock(void)
{
return ((get_clock() - jiffies_timer_cc) * 1000) >> 12;
return ((get_clock() - jiffies_timer_cc) * 125) >> 9;
}
void tod_to_timeval(__u64 todval, struct timespec *xtime)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册