[PATCH] next_timer_interrupt: simpler overflow handling
From: Keir Fraser
Date: Thu Jul 13 2006 - 04:52:51 EST
Having seen the patch applied to 2.6.17 to fix the overflowing
comparison in next_timer_interrupt() it occurred to me that a much
simpler fix is to not set hr_expires to MAX_JIFFY_OFFSET. It's way
further out from jiffies than necessary, which is why it's caused
problems. I instead propose that we initialise it to LONG_MAX>>1, just
as we already do for the non-hr expires variable. This will allow safe
comparison with any timer value in the range jiffies+/-(LONG_MAX>>1)
which is plenty of range around jiffies (+/- 12 days if HZ=1000 and
long is 32 bits).
The advantages are simpler code, and uniform initialisation of expires
and hr_expires variables.
-- Keir
Replace a fix for a comparison overflow in next_timer_interrupt() with
a simpler alternative. We can be sure that the interesting range of
timer values around jiffies is safe to compare with
jiffies+(LONG_MAX>>1), unlike jiffies+MAX_JIFFY_OFFSET.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
Attachment:
fix-next-timer-interrupt.patch
Description: Binary data