From 9dbafa5368c2b7467bd2ce034b56c54908ceb39e Mon Sep 17 00:00:00 2001 From: Jan Glauber Date: Wed, 1 Feb 2006 03:06:32 -0800 Subject: [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: Jan Glauber Signed-off-by: Martin Schwidefsky Signed-off-by: Heiko Carstens Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/s390/kernel/time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/s390/kernel/time.c') diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c index 7c0fe152a11..efba91b015b 100644 --- a/arch/s390/kernel/time.c +++ b/arch/s390/kernel/time.c @@ -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) -- cgit v1.2.3 From 32f65f274602b43e8f48314e9769f254da1d8323 Mon Sep 17 00:00:00 2001 From: Jan Glauber Date: Wed, 1 Feb 2006 03:06:33 -0800 Subject: [PATCH] s390: monotonic_clock interface Add monotonic_clock interface, used by the hangcheck-timer. On s390 this is the same as sched_clock(). Signed-off-by: Jan Glauber Signed-off-by: Martin Schwidefsky Signed-off-by: Heiko Carstens Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/s390/kernel/time.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'arch/s390/kernel/time.c') diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c index efba91b015b..fea043b69b9 100644 --- a/arch/s390/kernel/time.c +++ b/arch/s390/kernel/time.c @@ -64,6 +64,15 @@ unsigned long long sched_clock(void) return ((get_clock() - jiffies_timer_cc) * 125) >> 9; } +/* + * Monotonic_clock - returns # of nanoseconds passed since time_init() + */ +unsigned long long monotonic_clock(void) +{ + return sched_clock(); +} +EXPORT_SYMBOL(monotonic_clock); + void tod_to_timeval(__u64 todval, struct timespec *xtime) { unsigned long long sec; -- cgit v1.2.3