2020-09-04 20:10:21 +00:00
|
|
|
From 738ced8ceb96a865a03bcec44f511e144282deb6 Mon Sep 17 00:00:00 2001
|
|
|
|
Message-Id: <738ced8ceb96a865a03bcec44f511e144282deb6.1599166690.git.zanussi@kernel.org>
|
|
|
|
In-Reply-To: <56457dc415803c8abc5acb513ada877a79596f05.1599166690.git.zanussi@kernel.org>
|
|
|
|
References: <56457dc415803c8abc5acb513ada877a79596f05.1599166690.git.zanussi@kernel.org>
|
2018-08-27 14:32:32 +00:00
|
|
|
From: Steven Rostedt <rostedt@goodmis.org>
|
|
|
|
Date: Mon, 18 Mar 2013 15:12:49 -0400
|
2020-09-04 20:10:21 +00:00
|
|
|
Subject: [PATCH 113/333] sched/workqueue: Only wake up idle workers if not
|
2019-04-08 23:49:20 +00:00
|
|
|
blocked on sleeping spin lock
|
2020-09-04 20:10:21 +00:00
|
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.142-rt63.tar.xz
|
2018-08-27 14:32:32 +00:00
|
|
|
|
|
|
|
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>
|
|
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
|
|
---
|
2019-04-08 23:49:20 +00:00
|
|
|
kernel/sched/core.c | 4 +++-
|
2018-08-27 14:32:32 +00:00
|
|
|
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
|
|
|
2019-04-08 23:49:20 +00:00
|
|
|
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
|
2020-08-28 04:53:35 +00:00
|
|
|
index 2aa1d2a9ee5e..be048e7066d1 100644
|
2018-08-27 14:32:32 +00:00
|
|
|
--- a/kernel/sched/core.c
|
|
|
|
+++ b/kernel/sched/core.c
|
2020-08-28 04:53:35 +00:00
|
|
|
@@ -3541,8 +3541,10 @@ static void __sched notrace __schedule(bool preempt)
|
2018-08-27 14:32:32 +00:00
|
|
|
* 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);
|
2020-01-03 23:36:11 +00:00
|
|
|
--
|
2020-06-22 13:14:16 +00:00
|
|
|
2.17.1
|
2020-01-03 23:36:11 +00:00
|
|
|
|