On Fri, 8 Nov 2024 15:18:38 +0100 Christian König <ckoenig.leichtzumerken@xxxxxxxxx> wrote: > > } > > } > > > > dma_fence_array_clear_pending_error(array); > > return true; > > } > > > > Or if the optimisation to not walk the array when signalling is > > already enabled is deemed important, perhaps a less thinking inducing > > way would be this: > ... > > Decrementing locally cached num_pending in the loop I think does not > > bring anything since when signalling is not enabled it will be stuck > > at num_fences. So the loop walks the whole array versus bail on first > > unsignalled, so latter even more efficient. > > That is not for optimization but for correctness. > > What the patch basically does is the following: > 1. Grab the current value of num_pending. > > 2. Test if num_pending was potentially already modified because > signaling is already enabled, if yes just test it and return the result. > > 3. If it wasn't modified go over the fences and see if we already have > at least num_pending signaled. > > I should probably add a code comment explaining that. Sorry, I didn't sync my inbox before replying. Looks like we're on the same page here: the code clearly needs comments to explain what's going on.