Re: [PATCH 4.19 28/37] dmaengine: dmatest: Fix iteration non-stop logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 05, 2020 at 05:05:37PM +0300, Andy Shevchenko wrote:
On Tue, May 5, 2020 at 4:37 PM Pavel Machek <pavel@xxxxxxx> wrote:
On Tue 2020-05-05 16:19:11, Andy Shevchenko wrote:
> On Tue, May 5, 2020 at 3:58 PM Pavel Machek <pavel@xxxxxxx> wrote:
> > On Tue 2020-05-05 15:51:16, Andy Shevchenko wrote:
> > > On Tue, May 5, 2020 at 3:37 PM Pavel Machek <pavel@xxxxxxx> wrote:
> > Yeah, I pointed that out above. Both && and || permit short
> > execution. But that does not matter, as neither "params->iterations"
> > nor "total_tests >= params->iterations" have side effects.
> >
> > Where is the runtime difference?
>
> We have to check *both* conditions. If we don't check iterations, we
> just wait indefinitely until somebody tells us to stop.
> Everything in the commit message and mentioned there commit IDs which
> you may check.

No.

Yes. Please, read carefully the commit message (for your convenience I
emphasized above). I don't want to spend time on this basics stuff
anymore.

I'm a bit confused about this too. Maybe it's too early in the morning,
so I wrote this little test program:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
       int a = atoi(argv[1]);
       int b = atoi(argv[2]);

       if (!a && !b)
               printf("A");
       else
               printf("B");

       if (!(a || b))
               printf("A");
       else
               printf("B");

       printf("\n");

       return 0;
}

Andy, could you give an example of two values which will print something
other than "AA" or "BB"?

Heck, gcc even compiles these two conditions the same way:

       if (!a && !b)
   11a8:       83 7d f8 00             cmpl   $0x0,-0x8(%rbp)
   11ac:       75 12                   jne    11c0 <main+0x57>
   11ae:       83 7d fc 00             cmpl   $0x0,-0x4(%rbp)
   11b2:       75 0c                   jne    11c0 <main+0x57>
               printf("A");
   11b4:       bf 41 00 00 00          mov    $0x41,%edi
   11b9:       e8 a2 fe ff ff          callq  1060 <putchar@plt>
   11be:       eb 0a                   jmp    11ca <main+0x61>
       else
               printf("B");
   11c0:       bf 42 00 00 00          mov    $0x42,%edi
   11c5:       e8 96 fe ff ff          callq  1060 <putchar@plt>

       if (!(a || b))
   11ca:       83 7d f8 00             cmpl   $0x0,-0x8(%rbp)
   11ce:       75 12                   jne    11e2 <main+0x79>
   11d0:       83 7d fc 00             cmpl   $0x0,-0x4(%rbp)
   11d4:       75 0c                   jne    11e2 <main+0x79>
               printf("A");
   11d6:       bf 41 00 00 00          mov    $0x41,%edi
   11db:       e8 80 fe ff ff          callq  1060 <putchar@plt>
   11e0:       eb 0a                   jmp    11ec <main+0x83>
       else
               printf("B");
   11e2:       bf 42 00 00 00          mov    $0x42,%edi
   11e7:       e8 74 fe ff ff          callq  1060 <putchar@plt>

--
Thanks,
Sasha



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux