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: > > > > > > So, to the point, the conditional of checking the thread to be stopped being > > > > > > first part of conjunction logic prevents to check iterations. Thus, we have to > > > > > > always check both conditions vvv >>>>>> to be able to stop after given iterations. ^^^ ... > > > 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. > If kthread_should_stop() is true, we break the loop. Both old code and > new code does that. Neither old nor new code checks the > "params->iterations && total_tests >=dparams->iterations" condition, > as both && and || do short execution). > > If you wanted both conditions to always evaluate, you'd have to do > > # while (!kthread_should_stop() > # & !(params->iterations && total_tests >= > # params->iterations)) { > > (note && -> &). But, again, there's no reason to do that, as second > part of expression does not have side effects. It fixes a bug in the code, try with and without this change. (I can reproduce it here) -- With Best Regards, Andy Shevchenko