aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-08-03 13:30:45 -0400
committerTejun Heo <tj@kernel.org>2012-08-03 13:30:45 -0400
commit959d1af8cffc8fd38ed53e8be1cf4ab8782f9c00 (patch)
tree04ca9a7c88fe42f21fa4a6a209a2c16236615f45 /kernel
parentd4283e9378619c14dc3826a6b0527eb5d967ffde (diff)
workqueue: add missing smp_wmb() in process_one_work()
WORK_STRUCT_PENDING is used to claim ownership of a work item and process_one_work() releases it before starting execution. When someone else grabs PENDING, all pre-release updates to the work item should be visible and all updates made by the new owner should happen afterwards. Grabbing PENDING uses test_and_set_bit() and thus has a full barrier; however, clearing doesn't have a matching wmb. Given the preceding spin_unlock and use of clear_bit, I don't believe this can be a problem on an actual machine and there hasn't been any related report but it still is theretically possible for clear_pending to permeate upwards and happen before work->entry update. Add an explicit smp_wmb() before work_clear_pending(). Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: stable@vger.kernel.org
Diffstat (limited to 'kernel')
-rw-r--r--kernel/workqueue.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 70f95ab28f3d..5c26d36146b7 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1997,7 +1997,9 @@ __acquires(&gcwq->lock)
1997 1997
1998 spin_unlock_irq(&gcwq->lock); 1998 spin_unlock_irq(&gcwq->lock);
1999 1999
2000 smp_wmb(); /* paired with test_and_set_bit(PENDING) */
2000 work_clear_pending(work); 2001 work_clear_pending(work);
2002
2001 lock_map_acquire_read(&cwq->wq->lockdep_map); 2003 lock_map_acquire_read(&cwq->wq->lockdep_map);
2002 lock_map_acquire(&lockdep_map); 2004 lock_map_acquire(&lockdep_map);
2003 trace_workqueue_execute_start(work); 2005 trace_workqueue_execute_start(work);