mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yu Zhe <yuzhe@nfschina.com>
To: Paolo Abeni <pabeni@redhat.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: Fri, 29 Jul 2022 13:49:09 +0800	[thread overview]
Message-ID: <98b5da7e-74d2-0350-e0fc-a98ca3cb944c@nfschina.com> (raw)
In-Reply-To: <e63e6fc511d9d515fcb8501f48f218192f36afd3.camel@redhat.com>

在 2022年07月28日 21:11, Paolo Abeni 写道:

> 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)

I agree and I will send a v2 patch later.

>
> Cheers,
>
> Paolo
>
> p.s. given the above I guess this is for the net-next tree, right?
>
yes

>

  reply	other threads:[~2022-07-29  5:49 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
2022-07-29  5:49   ` Yu Zhe [this message]
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=98b5da7e-74d2-0350-e0fc-a98ca3cb944c@nfschina.com \
    --to=yuzhe@nfschina.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=pabeni@redhat.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

all inboxes | Powered by JetHome®