From: Paolo Abeni <pabeni@redhat.com>
To: Yu Zhe <yuzhe@nfschina.com>, davem@davemloft.net, kuba@kernel.org
Cc: linux-decnet-user@lists.sourceforge.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
liqiong@nfschina.com
Subject: Re: [PATCH] dn_route: use time_is_before_jiffies(a) to replace "jiffies - a > 0"
Date: Thu, 28 Jul 2022 15:11:04 +0200 [thread overview]
Message-ID: <e63e6fc511d9d515fcb8501f48f218192f36afd3.camel@redhat.com> (raw)
In-Reply-To: <20220727024600.18413-1-yuzhe@nfschina.com>
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@nfschina.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?
next prev parent reply other threads:[~2022-07-28 13:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-27 2:46 Yu Zhe
2022-07-28 13:11 ` Paolo Abeni [this message]
2022-07-29 5:49 ` Yu Zhe
2022-07-29 6:17 ` [PATCH v2] dn_route: replace "jiffies-now>0" with "jiffies!=now" Yu Zhe
2022-07-30 3:20 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e63e6fc511d9d515fcb8501f48f218192f36afd3.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-decnet-user@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=liqiong@nfschina.com \
--cc=netdev@vger.kernel.org \
--cc=yuzhe@nfschina.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome