From 6ffc787a4492ac627315aaeafdfdc0a5c3028582 Mon Sep 17 00:00:00 2001 From: David Fries Date: Wed, 6 Feb 2008 01:38:04 -0800 Subject: system timer: fix crash in <100Hz system timer The kernel has a divide by zero crash when trying to run the system timer less than 100Hz. The problem is x/(HZ/USER_HZ) and related. Now x*(USER_HZ/HZ) will be used if HZ Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/acct.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/linux/acct.h') diff --git a/include/linux/acct.h b/include/linux/acct.h index 302eb727ecb8..e8cae54e8d88 100644 --- a/include/linux/acct.h +++ b/include/linux/acct.h @@ -173,7 +173,11 @@ typedef struct acct acct_t; static inline u32 jiffies_to_AHZ(unsigned long x) { #if (TICK_NSEC % (NSEC_PER_SEC / AHZ)) == 0 +# if HZ < AHZ + return x * (AHZ / HZ); +# else return x / (HZ / AHZ); +# endif #else u64 tmp = (u64)x * TICK_NSEC; do_div(tmp, (NSEC_PER_SEC / AHZ)); -- cgit v1.2.3-59-g8ed1b