[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e63e6fc511d9d515fcb8501f48f218192f36afd3.camel@redhat.com>
Date: Thu, 28 Jul 2022 15:11:04 +0200
From: Paolo Abeni <pabeni@...hat.com>
To: Yu Zhe <yuzhe@...china.com>, davem@...emloft.net, kuba@...nel.org
Cc: linux-decnet-user@...ts.sourceforge.net, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
liqiong@...china.com
Subject: Re: [PATCH] dn_route: use time_is_before_jiffies(a) to replace
"jiffies - a > 0"
On Wed, 2022-07-27 at 10:46 +0800, Yu Zhe wrote:
> time_is_before_jiffies deals with timer wrapping correctly.
>
> Signed-off-by: Yu Zhe <yuzhe@...china.com>
> ---
> net/decnet/dn_route.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
> index 552a53f1d5d0..0a4bed0bc2e3 100644
> --- a/net/decnet/dn_route.c
> +++ b/net/decnet/dn_route.c
> @@ -201,7 +201,7 @@ static void dn_dst_check_expire(struct timer_list *unused)
> }
> spin_unlock(&dn_rt_hash_table[i].lock);
>
> - if ((jiffies - now) > 0)
> + if (time_is_before_jiffies(now))
Uhmm... it looks like the wrap-around condition can happen only in
theory: 'now' is initialized just before entering this loop, and we
will break as soon as jiffies increment. The wrap-around could happen
only if a single iteration of the loop takes more than LONG_MAX
jiffies.
If that happens, we have a completely different kind of much more
serious problem, I think ;)
So this change is mostly for core readability's sake. I personally find
more readable:
if (jiffies != now)
Cheers,
Paolo
p.s. given the above I guess this is for the net-next tree, right?
Powered by blists - more mailing lists