aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid Fries <david@fries.net>2008-02-06 04:38:04 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-06 13:41:10 -0500
commit6ffc787a4492ac627315aaeafdfdc0a5c3028582 (patch)
treebb557076ead94695cd148c4b7b065d44e77e62a3 /include
parent82f560874e88bd1fd8c98a6254d65a1dffab3876 (diff)
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<USER_HZ. I'm running the Linux kernel under qemu and went to run a slower system timer to take less CPU (and battery) on the host. I found that the kernel paniced under emulation because of a divide by zero in three places. Here is the patch. The base git was updated today 01-05-2008. I went for a 20Hz system time by adding config HZ_20 etc to kernel/Kconfig.hz. With this patch I verified the system timer by looking at /proc/interrupts. [akpm@linux-foundation.org: partially clean up the macro maze] Signed-off-by: David Fries <david@fries.net> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/acct.h4
1 files changed, 4 insertions, 0 deletions
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;
173static inline u32 jiffies_to_AHZ(unsigned long x) 173static inline u32 jiffies_to_AHZ(unsigned long x)
174{ 174{
175#if (TICK_NSEC % (NSEC_PER_SEC / AHZ)) == 0 175#if (TICK_NSEC % (NSEC_PER_SEC / AHZ)) == 0
176# if HZ < AHZ
177 return x * (AHZ / HZ);
178# else
176 return x / (HZ / AHZ); 179 return x / (HZ / AHZ);
180# endif
177#else 181#else
178 u64 tmp = (u64)x * TICK_NSEC; 182 u64 tmp = (u64)x * TICK_NSEC;
179 do_div(tmp, (NSEC_PER_SEC / AHZ)); 183 do_div(tmp, (NSEC_PER_SEC / AHZ));