Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit b73e9bf

Browse files
FROMGIT: 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: 152e11f ("sched/fair: Implement delayed dequeue") Reported-by: [email protected] Signed-off-by: John Stultz <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: K Prateek Nayak <[email protected]> Link: https://lkml.kernel.org/r/[email protected] (cherry picked from commit b7ca574 git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git sched/core) Change-Id: I4e464ab3415d1ad3a9c502d4be42e10088d93d05 Bug: 410435899 Signed-off-by: John Stultz <[email protected]>
1 parent 6cf7b79 commit b73e9bf

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

kernel/sched/core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,6 +2311,12 @@ unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
23112311
* just go back and repeat.
23122312
*/
23132313
rq = task_rq_lock(p, &rf);
2314+
/*
2315+
* If task is sched_delayed, force dequeue it, to avoid always
2316+
* hitting the tick timeout in the queued case
2317+
*/
2318+
if (p->se.sched_delayed)
2319+
dequeue_task(rq, p, DEQUEUE_SLEEP | DEQUEUE_DELAYED);
23142320
trace_sched_wait_task(p);
23152321
running = task_on_cpu(rq, p);
23162322
queued = task_on_rq_queued(p);

0 commit comments

Comments
 (0)