diff options
author | Tejun Heo <tj@kernel.org> | 2012-05-14 18:04:50 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-06-01 03:12:56 -0400 |
commit | 935055856458a05c43f518bf9ed406f67c090f0a (patch) | |
tree | 3cde458e723b77008d8dc041de6632458f4cba58 | |
parent | bfd6d6af769c5cd62aa9ed75b038ea3d234b090b (diff) |
workqueue: skip nr_running sanity check in worker_enter_idle() if trustee is active
commit 544ecf310f0e7f51fa057ac2a295fc1b3b35a9d3 upstream.
worker_enter_idle() has WARN_ON_ONCE() which triggers if nr_running
isn't zero when every worker is idle. This can trigger spuriously
while a cpu is going down due to the way trustee sets %WORKER_ROGUE
and zaps nr_running.
It first sets %WORKER_ROGUE on all workers without updating
nr_running, releases gcwq->lock, schedules, regrabs gcwq->lock and
then zaps nr_running. If the last running worker enters idle
inbetween, it would see stale nr_running which hasn't been zapped yet
and trigger the WARN_ON_ONCE().
Fix it by performing the sanity check iff the trustee is idle.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | kernel/workqueue.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 1456daba9a0..ee1845b8d69 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -1214,8 +1214,13 @@ static void worker_enter_idle(struct worker *worker) | |||
1214 | } else | 1214 | } else |
1215 | wake_up_all(&gcwq->trustee_wait); | 1215 | wake_up_all(&gcwq->trustee_wait); |
1216 | 1216 | ||
1217 | /* sanity check nr_running */ | 1217 | /* |
1218 | WARN_ON_ONCE(gcwq->nr_workers == gcwq->nr_idle && | 1218 | * Sanity check nr_running. Because trustee releases gcwq->lock |
1219 | * between setting %WORKER_ROGUE and zapping nr_running, the | ||
1220 | * warning may trigger spuriously. Check iff trustee is idle. | ||
1221 | */ | ||
1222 | WARN_ON_ONCE(gcwq->trustee_state == TRUSTEE_DONE && | ||
1223 | gcwq->nr_workers == gcwq->nr_idle && | ||
1219 | atomic_read(get_gcwq_nr_running(gcwq->cpu))); | 1224 | atomic_read(get_gcwq_nr_running(gcwq->cpu))); |
1220 | } | 1225 | } |
1221 | 1226 | ||