]> git.baikalelectronics.ru Git - kernel.git/commit
workqueue: skip lockdep wq dependency in cancel_work_sync()
authorJohannes Berg <johannes.berg@intel.com>
Wed, 22 Aug 2018 09:49:03 +0000 (11:49 +0200)
committerTejun Heo <tj@kernel.org>
Wed, 22 Aug 2018 15:31:37 +0000 (08:31 -0700)
commitb2ba491a2f8fd55304427d6c2b9c1a75d108a96d
tree099c38c86ac779dfe984e119370032dc16443247
parentef5556993cb078812f570682b0f0813d5bb4b926
workqueue: skip lockdep wq dependency in cancel_work_sync()

In cancel_work_sync(), we can only have one of two cases, even
with an ordered workqueue:
 * the work isn't running, just cancelled before it started
 * the work is running, but then nothing else can be on the
   workqueue before it

Thus, we need to skip the lockdep workqueue dependency handling,
otherwise we get false positive reports from lockdep saying that
we have a potential deadlock when the workqueue also has other
work items with locking, e.g.

  work1_function() { mutex_lock(&mutex); ... }
  work2_function() { /* nothing */ }

  other_function() {
    queue_work(ordered_wq, &work1);
    queue_work(ordered_wq, &work2);
    mutex_lock(&mutex);
    cancel_work_sync(&work2);
  }

As described above, this isn't a problem, but lockdep will
currently flag it as if cancel_work_sync() was flush_work(),
which *is* a problem.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/workqueue.c