netdev
[Top] [All Lists]

Re: [PATCH] net/ipv4/*, net/core/neighbour.c jiffies cleanup

To: Krishna Kumar <kumarkr@xxxxxxxxxx>
Subject: Re: [PATCH] net/ipv4/*, net/core/neighbour.c jiffies cleanup
From: Vino Thomas <jvt@xxxxxxxxxxxxxxxx>
Date: Fri, 9 Nov 2001 10:43:48 +0000 (/etc/localtime)
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxx>, Andreas Dilger <adilger@xxxxxxxxxxxxx>, ak@xxxxxx, andrewm@xxxxxxxxxx, "David S. Miller" <davem@xxxxxxxxxx>, jgarzik@xxxxxxxxxxxxxxxx, kuznet@xxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, IPV6 Mailing List <netdev@xxxxxxxxxxx>, owner-netdev@xxxxxxxxxxx, tim@xxxxxxxxxxxxxxxxxxxxxx
In-reply-to: <OFE014018A.D6D3430D-ON88256AFE.005C057D@xxxxxxxxxxxxxxx>
Sender: owner-netdev@xxxxxxxxxxx
Hello Krishna,

In 'Case 3' Change the line

        jiffies = start + HZ - 1;
to
        jiffies = start + HZ - 91;

and see the difference.

Regards,
Vino.

On Thu, 8 Nov 2001, Krishna Kumar wrote:

> 
> Hi Linus,
> 
> > >
> > > In short: It is wrong to do
> > >
> > >          if (jiffies <= start+HZ)
> > >
> > > and it is _right_ to do
> > >
> > >          if (jiffies - start <= HZ)
> >
> > Actually this last part is wrong, isn't it ? jiffies <= start + HZ is
> also
> > a correct way to do it, since start+HZ will overflow to the current value
> > of jiffies when HZ time elapses. So the above two statements are
> IDENTICAL.
> >
> > No.
> >
> > Try it out with a few examples. You'll see.
> >
> >                    Linus
> 
> I am sorry, but I still don't see the difference. I wrote a small program
> with different
> cases, but the values still come same irrespective of the input arguments
> to the
> checks. Could you tell under what conditions the checks wuold fail ? The
> 2's
> complement  works the same for addition and subtraction. I have included
> the
> test program below.
> 
> Thanks,
> 
> - KK
> 
> ---------------------------------------------------------------------------------------------
> /*
>      if (jiffies <= start+HZ)
>      if (jiffies - start <= HZ)
> */
> 
> #define HZ 100
> 
> main()
> {
>      unsigned long start, jiffies;
> 
>      /* Case 1 */
>      start = ((unsigned long) -1);
>      jiffies = start + HZ;
>      if (jiffies <= start + HZ) {
>            printf("Less Case 1\n");
>      }
>      if (jiffies - start <= HZ) {
>            printf("Less Case 2\n");
>      }
> 
>      /* Case 2 */
>      start = ((unsigned long) -10);
>      jiffies = start + HZ + 1;
>      if (jiffies <= start + HZ) {
>            printf("Less Case 3\n");
>      }
>      if (jiffies - start <= HZ) {
>            printf("Less Case 4\n");
>      }
> 
>      /* Case 3 */
>      start = ((unsigned long) -10);
>      jiffies = start + HZ - 1;
>      if (jiffies <= start + HZ) {
>            printf("Less Case 5\n");
>      }
>      if (jiffies - start <= HZ) {
>            printf("Less Case 6\n");
>      }
> }
> 
> 
> 


<Prev in Thread] Current Thread [Next in Thread>