]> git.proxmox.com Git - mirror_ubuntu-bionic-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)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:47:03 +0000 (19:47 -0600)
commit60830a82890f78623c22efe8a5cf34f3c5004944
tree91fd5db1bb4af81155e2e6c0626035e965db4368
parent1dd7762184e3c35474b38d3adea868153c5891c9
workqueue: skip lockdep wq dependency in cancel_work_sync()

BugLink: https://bugs.launchpad.net/bugs/1835972
[ Upstream commit d6e89786bed977f37f55ffca11e563f6d2b1e3b5 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
kernel/workqueue.c