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

From: Tejun Heo
Date: Wed Oct 18 2023 - 05:53:19 EST


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.

Thanks.

--
tejun