Re: [PATCH] workqueue: Provide one lock class key per work_on_cpu() callsite

From: Frederic Weisbecker
Date: Wed Oct 18 2023 - 08:13:59 EST


Le Tue, Oct 17, 2023 at 11:53:12PM -1000, Tejun Heo a écrit :
> On Sun, Sep 24, 2023 at 05:07:02PM +0200, Frederic Weisbecker wrote:
> > All callers of work_on_cpu() share the same lock class key for all the
> > functions queued. As a result the workqueue related locking scenario for
> > a function A may be spuriously accounted as an inversion against the
> > locking scenario of function B such as in the following model:
> >
> > long A(void *arg)
> > {
> > mutex_lock(&mutex);
> > mutex_unlock(&mutex);
> > }
> >
> > long B(void *arg)
> > {
> > }
> >
> > void launchA(void)
> > {
> > work_on_cpu(0, A, NULL);
> > }
> >
> > void launchB(void)
> > {
> > mutex_lock(&mutex);
> > work_on_cpu(1, B, NULL);
> > mutex_unlock(&mutex);
> > }
> >
> > launchA and launchB running concurrently have no chance to deadlock.
> > However the above can be reported by lockdep as a possible locking
> > inversion because the works containing A() and B() are treated as
> > belonging to the same locking class.
>
> Sorry about the delay. I missed this one. Applied to wq/for-6.7.

No problem, thanks a lot!

>
> Thanks.
>
> --
> tejun