On Mon, May 08, 2006 at 06:28:56PM +0000, Stefan Rompf wrote:
> 
> time_after() and friends can handle jiffies wrapping, however they require 
> the 
> difference between compared times to be less than 0x80000000 jiffies (about 
> 24 days on HZ=1000) to work reliably on 32bit architectures. So if the 
> network is stable for 24 days, events generated within days 25-49 will suffer 
> a *huge* false delay.

How about something like this?

[NET] linkwatch: Handle jiffies wrap-around

The test used in the linkwatch does not handle wrap-arounds correctly.
Since the intention of the code is to eliminate bursts of messages we
can afford to delay things up to a second.  Using that fact we can
easily handle wrap-arounds by making sure that we don't delay things
by more than one second.

This is based on diagnosis and a patch by Stefan Rompf.

Signed-off-by: Herbert Xu <[EMAIL PROTECTED]>

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[EMAIL PROTECTED]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
diff --git a/net/core/link_watch.c b/net/core/link_watch.c
index 341de44..646937c 100644
--- a/net/core/link_watch.c
+++ b/net/core/link_watch.c
@@ -170,13 +170,13 @@
                spin_unlock_irqrestore(&lweventlist_lock, flags);
 
                if (!test_and_set_bit(LW_RUNNING, &linkwatch_flags)) {
-                       unsigned long thisevent = jiffies;
+                       unsigned long delay = linkwatch_nextevent - jiffies;
 
-                       if (thisevent >= linkwatch_nextevent) {
+                       /* If we wrap around we'll delay it by at most HZ. */
+                       if (!delay || delay > HZ)
                                schedule_work(&linkwatch_work);
-                       } else {
-                               schedule_delayed_work(&linkwatch_work, 
linkwatch_nextevent - thisevent);
-                       }
+                       else
+                               schedule_delayed_work(&linkwatch_work, delay);
                }
        }
 }

Reply via email to