From: Peter Zijlstra <peterz@infradead.org>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: mingo@redhat.com, juri.lelli@redhat.com,
dietmar.eggemann@arm.com, rostedt@goodmis.org,
bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
kprateek.nayak@amd.com, linux-kernel@vger.kernel.org,
qyousef@layalina.io
Subject: Re: [PATCH 6/6 v2] sched/eevdf: Speedup short slice task scheduling
Date: Tue, 16 Jun 2026 12:57:51 +0200 [thread overview]
Message-ID: <20260616105751.GK42921@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20260615162420.420957-7-vincent.guittot@linaro.org>
On Mon, Jun 15, 2026 at 06:24:20PM +0200, Vincent Guittot wrote:
> When a task with a shorter slice is enqueued, we protect the running
> task which has a longer slice until it becomes ineligible instead of a
> full slice in order to speedup the switch to other tasks until the task
> with the shortest slice is scheduled. This helps to the task to not wait
> too many full slices before running.
>
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
> kernel/sched/fair.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 601c67cff185..994fcf3ea702 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -1091,7 +1091,10 @@ static inline void set_protect_slice(struct cfs_rq *cfs_rq, struct sched_entity
> slice = cfs_rq_min_slice(cfs_rq);
>
> slice = min(slice, se->slice);
> - if (vruntime != se->vruntime || slice != se->slice)
> +
> + if (sched_feat(PREEMPT_SHORT) && slice < se->slice)
> + vprot = avg_vruntime(cfs_rq);
> + else if ((vruntime != se->vruntime) || (slice != se->slice))
> vprot = min_vruntime(vprot, vruntime + calc_delta_fair(slice, se));
>
> se->vprot = vprot;
I am not entirely sure I understand this one.
avg_vruntime() could be ahead of se->deadline, esp for very short
slices. This would then extend protection beyond the one slice..
Aside from that, there are but two protect_slice() callers that matter:
- pick_eevdf(): this already has a hard limit on avg_vruntime()
- update_curr(): this will trigger preemption when reaching either
->deadline or ->vprot.
Also, the purpose of vprot is similar to the old min_gran, ensure any
task gets *some* time and avoid the degenerate case of endlessly
scheduling without 'any' real progress.
For EEVDF this happens when tasks get arbitrarily close to
avg_vruntime(). Eg, you have the two tasks A,B with A a virtual ns
before avg (and per necessity the other 1 ns after). You run A until its
just past B, find its not longer eligible, switch to B and do the same.
This then results in max frequency context switches and minimal actual
progress.
The thing that was supposed to stop this is vprot, but if you
consistently set vprot at avg_vruntime, this is effectively disabling
vprot. No?
Now, the conditions for this are such that this only happens for all
tasks not of the minimal slice length in the tree. So in order words,
you get spikes of high frequency scheduling just to burn vtime in order
to achieve eligibility for the earliest min_slice task, right?
So what you really want is not avg_vruntime() but the actual
se->vruntime of this earliest min_slice entity. Then we can simply run
whatever task and not get hit with high frequency scheduling, and still
achieve minimal latency for the waiting task.
Now, we don't actually have a convenient way to get this specific task,
but would something like so work?
if (sched_feat(PREEMPT_SHORT) && slice != se->slice)
vprot = min_vruntime(vprot, __pick_root_entity(cfs_rq)->vruntime);
That is, we protect until the next earliest task becomes eligible.
Or did I go off the rails somewhere?
next prev parent reply other threads:[~2026-06-16 10:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-15 16:24 [PATCH 0/6 v2] sched/eevdf: Improve scheduling latency of short slice task Vincent Guittot
2026-06-15 16:24 ` [PATCH 1/6 v2] sched/fair: Set next buddy for preempt short Vincent Guittot
2026-06-16 8:51 ` Peter Zijlstra
2026-06-16 13:52 ` Vincent Guittot
2026-06-15 16:24 ` [PATCH 2/6 v2] sched/eevdf: Take into account current's lag when updating slice protection Vincent Guittot
2026-06-16 3:52 ` K Prateek Nayak
2026-06-16 12:11 ` Vincent Guittot
2026-06-16 9:29 ` Peter Zijlstra
2026-06-16 12:49 ` Vincent Guittot
2026-06-15 16:24 ` [PATCH 3/6 v2] sched/eevdf: Update slice protection even when resched is already set Vincent Guittot
2026-06-16 9:37 ` Peter Zijlstra
2026-06-16 13:57 ` Vincent Guittot
2026-06-15 16:24 ` [PATCH 4/6 v2] sched/eevdf: Cancel slice protection if short slice task is eligible Vincent Guittot
2026-06-16 5:34 ` K Prateek Nayak
2026-06-16 12:51 ` Vincent Guittot
2026-06-15 16:24 ` [PATCH 5/6 v2] sched/eevdf: Always update slice protection Vincent Guittot
2026-06-15 16:24 ` [PATCH 6/6 v2] sched/eevdf: Speedup short slice task scheduling Vincent Guittot
2026-06-16 10:57 ` Peter Zijlstra [this message]
2026-06-16 15:18 ` Vincent Guittot
2026-06-17 16:01 ` Vincent Guittot
2026-06-16 7:43 ` [PATCH 0/6 v2] sched/eevdf: Improve scheduling latency of short slice task K Prateek Nayak
2026-06-16 13:58 ` Vincent Guittot
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=20260616105751.GK42921@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=qyousef@layalina.io \
--cc=rostedt@goodmis.org \
--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®