Re: [PATCH 4/4] lockdep: Fix workqueue crossrelease annotation

From: Byungchul Park
Date: Fri Sep 01 2017 - 06:16:39 EST


On Fri, Sep 01, 2017 at 11:47:47AM +0200, Peter Zijlstra wrote:
> On Fri, Sep 01, 2017 at 11:05:12AM +0900, Byungchul Park wrote:
> > On Thu, Aug 31, 2017 at 10:34:53AM +0200, Peter Zijlstra wrote:
> > > On Thu, Aug 31, 2017 at 05:15:01PM +0900, Byungchul Park wrote:
> > > > It's not important. Ok, check the following, instead:
> > > >
> > > > context X context Y
> > > > --------- ---------
> > > > wait_for_completion(C)
> > > > acquire(A)
> > > > release(A)
> > > > process_one_work()
> > > > acquire(B)
> > > > release(B)
> > > > work->fn()
> > > > complete(C)
> > > >
> > > > We don't need to lose C->A and C->B dependencies unnecessarily.
> > >
> > > I really can't be arsed about them. Its really only the first few works
> > > that will retain that dependency anyway, even if you were to retain
> > > them.
> >
> > Wrong.
> >
> > Every 'work' doing complete() for different classes of completion
> > variable suffers from losing valuable dependencies, every time, not
> > first few ones.
>
> The moment you overrun the history array its gone. So yes, only the

It would be gone _only_ at the time the history overrun, and then it
will be built again. So, you are wrong.

Let me show you an example: (I hope you also show examples.)

context X context Y
--------- ---------
wait_for_completion(D)
while (true)
acquire(A)
release(A)
process_one_work()
acquire(B)
release(B)
work->fn()
complete(C)
acquire(D)
release(D)

When happening an overrun in a 'work', 'A' and 'B' will be gone _only_
at the time, and then 'D', 'A' and 'B' will be queued into the xhlock
*again* from the next loop on, and they can be used to generate useful
dependencies again.

You are being confused now. Acquisitions we are focusing now are not
_stacked_ like hlocks, but _accumulated_ continuously onto the ring
buffer e.i. xhlock array.