Re: Bug in internal_add_timer()?

David S. Miller (davem@jenolan.rutgers.edu)
Tue, 7 Oct 1997 14:21:07 -0400


Date: Tue, 7 Oct 1997 13:31:16 +0200
From: Jan Echternach <jec@DInet.de>

I think the test whether the timer value is in the past doesn't work
when jiffies overflow (i.e. expires = ULONG_MAX - 5, jiffies = expires
+ 10), but I'm not sure if I really understood what the code is
expected to do.

> ...
> } else if (expires < timer_jiffies) {

Yes I think you're right, it will act incorrectly when jiffies
overflows. Probably a fix is to go:

} else if (((long)expires - (long)timer_jiffies) < 0) {

This is an old trick stolen from the TCP stack. We'd have to do
something similar to this in a whole bunch of other places. I also
bet there are a lot of assumptions which would make this technique not
quite work in a few places.

Anyone want to work on this, test it, and send me patches for the CVS
tree?

Later,
David "Sparc" Miller
davem@caip.rutgers.edu