Re: [PATCH] workqueue: don't skip lockdep wq dependency in cancel_work_sync()

From: Tetsuo Handa
Date: Thu Jul 28 2022 - 22:29:03 EST


Thinking more, I might be confused by difference between

the lockdep "struct work_struct" dependency handling

and

the lockdep "struct work" dependency handling

. In an example that

work3_function() { /* nothing */ }
work4_function() { mutex_lock(&mutex); ... }

other_function() {
queue_work(ordered_wq, &work3);
queue_work(ordered_wq, &work4);
mutex_lock(&mutex);
cancel_work_sync(&work4);
}

, possibility of deadlock must be reported by lockdep via
the lockdep "struct work" dependency handling.

Then, prior to commit d6e89786bed977f3, lockdep flagging

the lockdep "struct work_struct" dependency handling

as if cancel_work_sync() was flush_work() is a problem, and
lockdep not flagging

the lockdep "struct work" dependency handling

from cancel_work_sync() as if flush_work() is also a problem.

Then, commit d6e89786bed977f3 might be OK, but commit 87915adc3f0acdf0
was wrong in that it preserved lockdep not flagging

the lockdep "struct work" dependency handling

from cancel_work_sync() as if flush_work().