From: "tip-bot2 for John Stultz" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: peter-yc.chang@mediatek.com, John Stultz <jstultz@google.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
K Prateek Nayak <kprateek.nayak@amd.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: sched/core] sched/core: Tweak wait_task_inactive() to force dequeue sched_delayed tasks
Date: Thu, 08 May 2025 10:43:43 -0000 [thread overview]
Message-ID: <174670102367.406.15930935491833687192.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20250429150736.3778580-1-jstultz@google.com>
The following commit has been merged into the sched/core branch of tip:
Commit-ID: b7ca5743a2604156d6083b88cefacef983f3a3a6
Gitweb: https://git.kernel.org/tip/b7ca5743a2604156d6083b88cefacef983f3a3a6
Author: John Stultz <jstultz@google.com>
AuthorDate: Tue, 29 Apr 2025 08:07:26 -07:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Wed, 30 Apr 2025 14:45:41 +02:00
sched/core: Tweak wait_task_inactive() to force dequeue sched_delayed tasks
It was reported that in 6.12, smpboot_create_threads() was
taking much longer then in 6.6.
I narrowed down the call path to:
smpboot_create_threads()
-> kthread_create_on_cpu()
-> kthread_bind()
-> __kthread_bind_mask()
->wait_task_inactive()
Where in wait_task_inactive() we were regularly hitting the
queued case, which sets a 1 tick timeout, which when called
multiple times in a row, accumulates quickly into a long
delay.
I noticed disabling the DELAY_DEQUEUE sched feature recovered
the performance, and it seems the newly create tasks are usually
sched_delayed and left on the runqueue.
So in wait_task_inactive() when we see the task
p->se.sched_delayed, manually dequeue the sched_delayed task
with DEQUEUE_DELAYED, so we don't have to constantly wait a
tick.
Fixes: 152e11f6df29 ("sched/fair: Implement delayed dequeue")
Reported-by: peter-yc.chang@mediatek.com
Signed-off-by: John Stultz <jstultz@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Link: https://lkml.kernel.org/r/20250429150736.3778580-1-jstultz@google.com
---
kernel/sched/core.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 79692f8..a3507ed 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2283,6 +2283,12 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
* just go back and repeat.
*/
rq = task_rq_lock(p, &rf);
+ /*
+ * If task is sched_delayed, force dequeue it, to avoid always
+ * hitting the tick timeout in the queued case
+ */
+ if (p->se.sched_delayed)
+ dequeue_task(rq, p, DEQUEUE_SLEEP | DEQUEUE_DELAYED);
trace_sched_wait_task(p);
running = task_on_cpu(rq, p);
queued = task_on_rq_queued(p);
prev parent reply other threads:[~2025-05-08 10:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 15:07 [PATCH v3] " John Stultz
2025-04-29 15:36 ` Phil Auld
2025-04-30 12:44 ` Peter Zijlstra
2025-04-30 13:45 ` Phil Auld
2025-04-30 12:43 ` Peter Zijlstra
2025-04-30 22:04 ` John Stultz
2025-05-08 10:43 ` tip-bot2 for John Stultz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=174670102367.406.15930935491833687192.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=jstultz@google.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=peter-yc.chang@mediatek.com \
--cc=peterz@infradead.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®