[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090220083935.GA18673@gondor.apana.org.au>
Date: Fri, 20 Feb 2009 16:39:35 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: David Miller <davem@...emloft.net>
Cc: yjwei@...fujitsu.com, netdev@...r.kernel.org
Subject: Re: [PATCH 1/3] gre: used time_before for comparing jiffies
David Miller <davem@...emloft.net> wrote:
>
> There is some history of this in the networking code.
>
> If you inspect carefully, the open-coded versions of
> time comparisons in the networking have a larger window
> of acceptance.
Hmm, it looks like the macro version is actually better in this
case.
- if (jiffies - t->err_time < IPTUNNEL_ERR_TIMEO)
This wraps at jiffies = LONG_MAX + t->err_time + 1
+ if (time_before(jiffies, t->err_time + IPTUNNEL_ERR_TIMEO))
This expands to
(long)jiffies - (long)(t->err_time + IPTUNNEL_ERR_TIMEO) < 0
which wraps at jiffies = LONG_MAX + t->err_time + IPTUNNEL_ERR_TIMEO + 1
So assuming that IPTUNNEL_ERR_TIMEO > 0, then the macro version
wraps around after the open-coded version, which would seem to
mean that it's better, no?
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists