mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: K Prateek Nayak <kprateek.nayak@amd.com>
To: Francesco Nigro <nigro.fra@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Valentin Schneider <vschneid@redhat.com>,
	"Mike Galbraith" <efault@gmx.de>,
	Mario Limonciello <mario.limonciello@amd.com>,
	Huang Rui <ray.huang@amd.com>, <linux-kernel@vger.kernel.org>,
	<linux-pm@vger.kernel.org>
Subject: Re: [REPORT] sched: ITMT + DELAY_DEQUEUE: woken task waits ~1 ms behind another task on the preferred CPU while allowed CPUs are idle
Date: Thu, 5 Nov 2026 14:04:27 +0530	[thread overview]
Message-ID: <99366157-08b9-411f-b180-fa61bc5f5002@amd.com> (raw)
In-Reply-To: <20261105081245.81773-1-nigro.fra@gmail.com>

Hello Francesco,

On 11/5/2026 1:42 PM, Francesco Nigro wrote:
> [You don't often get email from nigro.fra@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> On Thu, 2026-11-05 at 09:41 +0530, K Prateek Nayak wrote:
>> Hello Francesco,
> 
> Hi Prateek,
> 
> thanks a lot for looking into this, and for the patch.
> 
> This is a corporate machine, so I can't promise I will be able to boot
> a patched kernel on it, but I will try.

No worries I'll try it on my end over the coming weekend.
 
>> Since you say ITMT disabled actually solves this issue, I suspect there is a
>> race between the idle balancer moving the delayed task to a preferred CPU vs
>> a wakeup that also lands on the same CPU.
> 
> perf sched shows a race like that, but the task moved is the running
> one, by active balance. One example (perf sched timehist, trimmed; ms):
> 
>     .654334  [6]  worker 482   awakened: migration/7
>     .654337  [6]  worker 482   blocks

I'm having a hard time understanding why asym_active_balance() would
trigger before worker 482 blocks - also I'm assuming at this point
482 is the only task on the CPU so it shouldn't get delayed since
single task on CPU is always eligible.

>     .654338  [7]  worker 481   preempted while running
>     .654341  [7]  migration/7  migrated: worker 481 cpu 7 => 6
>     .654341  [2]  waker        awakened: worker 482
>     .655572  [6]  worker 482   ran 1.006 after 0.224 sch delay
> 
> Does your change cover the active balance path too?

I think I was missing the other part of allowing a delayed task to
migrate with the following diff:

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index b8c26a6ca82d..71dd82394006 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -11133,14 +11133,16 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
 
 	/*
 	 * We do not migrate tasks that are:
-	 * 1) delayed dequeued unless we migrate load, or
+	 * 1) delayed dequeued unless we migrate load / migration to idle CPU, or
 	 * 2) target cfs_rq is in throttled hierarchy, or
 	 * 3) cannot be migrated to this CPU due to cpus_ptr, or
 	 * 4) running (obviously), or
 	 * 5) are cache-hot on their current CPU, or
 	 * 6) are blocked on mutexes (if SCHED_PROXY_EXEC is enabled)
 	 */
-	if ((p->se.sched_delayed) && (env->migration_type != migrate_load))
+	if ((p->se.sched_delayed) &&
+	    (!(env->flags & LBF_FIRST_MIGRATION) &&
+	     env->migration_type != migrate_load))
 		return 0;
 
 	if (lb_throttled_hierarchy(p, env->dst_cpu))
---

This should allow for an idle CPU to see a delayed task and block it
even if it is has not yet hit the "migrate_load" threshold but it
still doesn't explain why the active balance gets triggered before
blocking.


>> So at this point, I would have expected B to have already been
>> moved by a newidle / idle balance.
> 
> Not here: in 270 of 286 waits of 0.5 ms or more, neither worker left
> CPU 6, and CPUs 4, 5 and 7 were idle for at least 98 % of the wait.
> 
> Trace summary and excerpt:
> https://github.com/franz1981/itmt-delay-dequeue-repro/tree/827b6b2

Thank you! Give me a wee bit more time to trace this path and I'll get
back to you by next week. Thank you again for all the data.

-- 
Thanks and Regards,
Prateek


      reply	other threads:[~2026-11-05  8:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 15:46 Francesco Nigro
2026-11-03 17:27 ` Mike Galbraith
2026-11-03 23:33   ` Francesco Nigro
2026-11-04  3:13     ` Mike Galbraith
2026-11-04 22:06       ` Francesco Nigro
2026-11-05  4:11 ` K Prateek Nayak
2026-11-05  8:12   ` Francesco Nigro
2026-11-05  8:34     ` K Prateek Nayak [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=99366157-08b9-411f-b180-fa61bc5f5002@amd.com \
    --to=kprateek.nayak@amd.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=efault@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=mingo@redhat.com \
    --cc=nigro.fra@gmail.com \
    --cc=peterz@infradead.org \
    --cc=ray.huang@amd.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /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®