提交 544ecf31 编写于 作者: T Tejun Heo

workqueue: skip nr_running sanity check in worker_enter_idle() if trustee is active

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: NTejun Heo <tj@kernel.org>
Reported-by: N"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: stable@vger.kernel.org
上级 0976dfc1
...@@ -1213,8 +1213,13 @@ static void worker_enter_idle(struct worker *worker) ...@@ -1213,8 +1213,13 @@ static void worker_enter_idle(struct worker *worker)
} else } else
wake_up_all(&gcwq->trustee_wait); wake_up_all(&gcwq->trustee_wait);
/* sanity check nr_running */ /*
WARN_ON_ONCE(gcwq->nr_workers == gcwq->nr_idle && * Sanity check nr_running. Because trustee releases gcwq->lock
* between setting %WORKER_ROGUE and zapping nr_running, the
* warning may trigger spuriously. Check iff trustee is idle.
*/
WARN_ON_ONCE(gcwq->trustee_state == TRUSTEE_DONE &&
gcwq->nr_workers == gcwq->nr_idle &&
atomic_read(get_gcwq_nr_running(gcwq->cpu))); atomic_read(get_gcwq_nr_running(gcwq->cpu)));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册