summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2013-03-18 15:12:49 -0400
committerSteven Rostedt <rostedt@goodmis.org>2013-10-24 11:06:32 -0400
commit386d4256ba670dacfcf523862601e64b7e63b254 (patch)
tree2c7f3b5601ea90c6f9738bc11c169a19bd08e223
parent344b93efce99afe65425a5645beb1e38b16c04b2 (diff)
downloadlinux-rt-386d4256ba670dacfcf523862601e64b7e63b254.tar.gz
sched/workqueue: Only wake up idle workers if not blocked on sleeping spin lock
In -rt, most spin_locks() turn into mutexes. One of these spin_lock conversions is performed on the workqueue gcwq->lock. When the idle worker is worken, the first thing it will do is grab that same lock and it too will block, possibly jumping into the same code, but because nr_running would already be decremented it prevents an infinite loop. But this is still a waste of CPU cycles, and it doesn't follow the method of mainline, as new workers should only be woken when a worker thread is truly going to sleep, and not just blocked on a spin_lock(). Check the saved_state too before waking up new workers. Cc: stable-rt@vger.kernel.org Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
-rw-r--r--kernel/sched.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 96dd9c2f9581..59bb8bcf34de 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4436,8 +4436,10 @@ static inline void sched_submit_work(struct task_struct *tsk)
/*
* If a worker went to sleep, notify and ask workqueue whether
* it wants to wake up a task to maintain concurrency.
+ * Only call wake up if prev isn't blocked on a sleeping
+ * spin lock.
*/
- if (tsk->flags & PF_WQ_WORKER)
+ if (tsk->flags & PF_WQ_WORKER && !tsk->saved_state)
wq_worker_sleeping(tsk);
/*