Re: [PATCH] next_timer_interrupt: simpler overflow handling

From: Zachary Amsden
Date: Thu Jul 13 2006 - 13:00:42 EST


Keir Fraser wrote:
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.

Even simpler would be to just make MAX_JIFFY_OFFSET be (LONG_MAX >> 1) and use this for both. In fact, it appears it used to be, judging by the comment in jiffies.h:

* The maximum jiffie value is (MAX_INT >> 1). Here we translate that

But seeing as this could have unanticipated side effects, I like this fix better.

Acked-By: Zachary Amsden <zach@xxxxxxxxxx>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/