]> git.baikalelectronics.ru Git - kernel.git/commit
workqueue: re-add lockdep dependencies for flushing
authorJohannes Berg <johannes.berg@intel.com>
Wed, 22 Aug 2018 09:49:04 +0000 (11:49 +0200)
committerTejun Heo <tj@kernel.org>
Wed, 22 Aug 2018 15:31:38 +0000 (08:31 -0700)
commitad1fbae7f71a93fab80d234e2a62ea710eb75444
treecce568b654b2bb6e7d893655c9693b370dcd98bd
parentb2ba491a2f8fd55304427d6c2b9c1a75d108a96d
workqueue: re-add lockdep dependencies for flushing

In flush_work(), we need to create a lockdep dependency so that
the following scenario is appropriately tagged as a problem:

  work_function()
  {
    mutex_lock(&mutex);
    ...
  }

  other_function()
  {
    mutex_lock(&mutex);
    flush_work(&work); // or cancel_work_sync(&work);
  }

This is a problem since the work might be running and be blocked
on trying to acquire the mutex.

Similarly, in flush_workqueue().

These were removed after cross-release partially caught these
problems, but now cross-release was reverted anyway. IMHO the
removal was erroneous anyway though, since lockdep should be
able to catch potential problems, not just actual ones, and
cross-release would only have caught the problem when actually
invoking wait_for_completion().

Fixes: ead1792cd2e9 ("workqueue: Remove now redundant lock acquisitions wrt. workqueue flushes")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/workqueue.c