From: Alexander Graf <graf@amazon.com>
To: Fernand Sieber <sieberf@amazon.com>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
<linux-kernel@vger.kernel.org>, <nh-open-source@amazon.com>,
kvm <kvm@vger.kernel.org>
Subject: Re: [PATCH] sched/fair: Only increment deadline once on yield
Date: Sun, 13 Apr 2025 20:38:00 +0200 [thread overview]
Message-ID: <7eed0c3d-6a78-4724-b204-a3b99764d839@amazon.com> (raw)
In-Reply-To: <20250401123622.584018-1-sieberf@amazon.com>
On 01.04.25 14:36, Fernand Sieber wrote:
> If a task yields, the scheduler may decide to pick it again. The task in
> turn may decide to yield immediately or shortly after, leading to a tight
> loop of yields.
>
> If there's another runnable task as this point, the deadline will be
> increased by the slice at each loop. This can cause the deadline to runaway
> pretty quickly, and subsequent elevated run delays later on as the task
> doesn't get picked again. The reason the scheduler can pick the same task
> again and again despite its deadline increasing is because it may be the
> only eligible task at that point.
>
> Fix this by updating the deadline only to one slice ahead.
>
> Note, we might want to consider iterating on the implementation of yield as
> follow up:
> * the yielding task could be forfeiting its remaining slice by
> incrementing its vruntime correspondingly
> * in case of yield_to the yielding task could be donating its remaining
> slice to the target task
>
> Signed-off-by: Fernand Sieber <sieberf@amazon.com>
IMHO it's worth noting that this is not a theoretical issue. We have
seen this in real life: A KVM virtual machine's vCPU which runs into a
busy guest spin lock calls kvm_vcpu_yield_to() which eventually ends up
in the yield_task_fair() function. We have seen such spin locks due to
guest contention rather than host overcommit, which means we go into a
loop of vCPU execution and spin loop exit, which results in an
undesirable increase in the vCPU thread's deadline.
Given this impacts real workloads and is a bug present since the
introduction of EEVDF, I would say it warrants a
Fixes: 147f3efaa24182 ("sched/fair: Implement an EEVDF-like scheduling
policy")
tag.
Alex
next prev parent reply other threads:[~2025-04-13 18:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 12:36 [PATCH] sched/fair: Only increment deadline once on yield Fernand Sieber
2025-04-13 4:00 ` Madadi Vineeth Reddy
2025-04-13 18:38 ` Alexander Graf [this message]
2025-07-22 11:46 ` [PATCH] " Wang Tao
2025-09-10 1:43 ` Wang Tao
2025-09-11 10:12 ` Fernand Sieber
-- strict thread matches above, loose matches on Subject: below --
2024-06-13 7:13 [PATCH 3/3] sched: Update ->next_balance correctly during newidle balance Joel Fernandes
2025-11-25 13:16 ` [PATCH] sched/fair: Only increment deadline once on yield Wang Tao
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=7eed0c3d-6a78-4724-b204-a3b99764d839@amazon.com \
--to=graf@amazon.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nh-open-source@amazon.com \
--cc=peterz@infradead.org \
--cc=sieberf@amazon.com \
--cc=vincent.guittot@linaro.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