All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RT] sched/workqueue: Only wake up idle workers if not blocked on sleeping spin lock
@ 2013-03-18 19:12 Steven Rostedt
  2013-05-03 15:53 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2013-03-18 19:12 UTC (permalink / raw)
  To: LKML, RT; +Cc: Tejun Heo, Thomas Gleixner, Peter Zijlstra

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.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index ff34113..b25bfec 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3630,8 +3630,10 @@ need_resched:
 			 * 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 (prev->flags & PF_WQ_WORKER) {
+			if (prev->flags & PF_WQ_WORKER && !prev->saved_state) {
 				struct task_struct *to_wakeup;
 
 				to_wakeup = wq_worker_sleeping(prev, cpu);



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH RT] sched/workqueue: Only wake up idle workers if not blocked on sleeping spin lock
  2013-03-18 19:12 [PATCH RT] sched/workqueue: Only wake up idle workers if not blocked on sleeping spin lock Steven Rostedt
@ 2013-05-03 15:53 ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Andrzej Siewior @ 2013-05-03 15:53 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: LKML, RT, Tejun Heo, Thomas Gleixner, Peter Zijlstra

* Steven Rostedt | 2013-03-18 15:12:49 [-0400]:

>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.
>
>Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Taking for v3.8-rt.

Sebastian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-05-03 15:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-18 19:12 [PATCH RT] sched/workqueue: Only wake up idle workers if not blocked on sleeping spin lock Steven Rostedt
2013-05-03 15:53 ` Sebastian Andrzej Siewior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.