aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel/time.c
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2013-01-14 16:55:55 +0100
committerBen Hutchings <ben@decadent.org.uk>2013-02-06 04:33:35 +0000
commit26d5d5d031a0bc51081fc5e8957dfee69e98b4b3 (patch)
tree4b3324f97869f27fc01edd8e296608ecb238eb55 /arch/s390/kernel/time.c
parent2c27f1d9af77a3842e896b7c0856bad925b3f7d3 (diff)
downloadkernel_samsung_smdk4412-26d5d5d031a0bc51081fc5e8957dfee69e98b4b3.zip
kernel_samsung_smdk4412-26d5d5d031a0bc51081fc5e8957dfee69e98b4b3.tar.gz
kernel_samsung_smdk4412-26d5d5d031a0bc51081fc5e8957dfee69e98b4b3.tar.bz2
s390/time: fix sched_clock() overflow
commit ed4f20943cd4c7b55105c04daedf8d63ab6d499c upstream. Converting a 64 Bit TOD format value to nanoseconds means that the value must be divided by 4.096. In order to achieve that we multiply with 125 and divide by 512. When used within sched_clock() this triggers an overflow after appr. 417 days. Resulting in a sched_clock() return value that is much smaller than previously and therefore may cause all sort of weird things in subsystems that rely on a monotonic sched_clock() behaviour. To fix this implement a tod_to_ns() helper function which converts TOD values without overflow and call this function from both places that open coded the conversion: sched_clock() and kvm_s390_handle_wait(). Reviewed-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'arch/s390/kernel/time.c')
-rw-r--r--arch/s390/kernel/time.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/s390/kernel/time.c b/arch/s390/kernel/time.c
index e03c555..8644366 100644
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -64,7 +64,7 @@ static DEFINE_PER_CPU(struct clock_event_device, comparators);
*/
unsigned long long notrace __kprobes sched_clock(void)
{
- return (get_clock_monotonic() * 125) >> 9;
+ return tod_to_ns(get_clock_monotonic());
}
/*