From: Mike Galbraith <efault@gmx.de>
To: Vincent Guittot <vincent.guittot@linaro.org>,
Chengfeng Lin <lin2530632123@gmail.com>
Cc: Tianchen Ding <dtcccc@linux.alibaba.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 7/7] sched/eevdf: Move to a single runqueue
Date: Sat, 07 Nov 2026 05:17:52 +0100 [thread overview]
Message-ID: <f2623ff14205adfb92518ef3b7aca053384f4cf7.camel@gmx.de> (raw)
In-Reply-To: <CAKfTPtCJVBpZNm7bVUSQZ01Q-iStNZvdz6BiNw1NN9+7y0+=mA@mail.gmail.com>
On Fri, 2026-11-06 at 17:43 +0100, Vincent Guittot wrote:
>
> 333238da9a19 ("sched: Update time before requeueing delayed entities")
> fixes a bug in how the lag of a delayed dequeued task is accounted.
>
> Let take the example of 2 tasks TA and TB running on root
...
Thanks a bunch for posting this. Correctness trumps all else is a rare
speed bump. The changelog didn't help discern correctness first from
booboo, the more common variety of speed bump. This does. I haven't
looked for sleepers surviving for tick scale distances and doing evil
deeds, will almost certainly now do so to at least get a peek at the
bug that also wants to be rendered flat.
> Without 333238da9a19:
>
> - task TA starts to sleep and is delayed dequeued with a negative lag
> of -1 usec
> - task TB becomes the current running task
> - During tick, update_curr() updates TB and moves forward its vruntime
> (and avg_vruntime) but it is still behind deadline/vprot so no
> resched().
> - TA's vruntime is now behind avg_vruntime (i.e. its lag is positive)
> - task TA wakes up just before the next tick so TB has not yet been
> updated for the last ongoing tick (up to 10ms)
> enqueue_task_fair( TA )->requeue_delayed_entity( TA) ->
> update_entity_lag( TA ) -> TA lag is cleared and TA vruntime ==
> avg_vruntime == TB vruntime at tick N-1
> wakeup_preempt_fair() --> update_curr_fair() -> TB vruntime is
> updated with the ongoing tick, avg_vruntime move forward by almost
> half a tick and TA now gained a positive lag of half a tick (up to 5ms
> capped by its slice) whereas it had a neg lag when it slept. This
> positive lag for TA is wrong as well as the negative lag for TB
> - Because of this wrong positive lag, TB is ineligible, and TA preempts TB.
>
> With 333238da9a19, the main difference is that we update TB before
> updating TA lag to make sure that past exec time has been accounted.
> i.e.:
> - task TA starts to sleep and is delayed dequeued with a negative lag
> of -1 usec
> - task TB becomes the current running task
> - During tick, update_curr() updates TB and moves forward its vruntime
> (and avg_vruntime) but it is still behind deadline/vprot so no
> resched().- TA's vruntime is now behind avg_vruntime (i.e. its lag is
> positive)
> - task TA wakes up just before the next tick so TB has not yet been
> updated for the last ongoing tick (up to 10ms)
> enqueue_task_fair( TA )->requeue_delayed_entity( TA) ->
> update_curr() update TB
> tehn update_entity_lag( TA ) -> TA lag is cleared and TA
> vruntime == avg_vruntime == TB vruntime at now
> wakeup_preempt_fair() --> update_curr_fair() -> nothing to do. If
> TB is still protected by its vprot then TA does not preempt TB
>
> That's also why when you disable DELAY_ZERO, you get the past behavior
> because we don't reset this positive lag accumulated during delayed
> dequeue. But this is still unfair... If TA has a null lag when is goes
> to sleep, it will wake with this same zero lag and will not preempt TB
> but with a -1 usec lag, it will gain half a tick of lag (up to 5ms)
> compared to others
next prev parent reply other threads:[~2026-11-07 4:18 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 13:03 Chengfeng Lin
2026-10-30 17:01 ` Mike Galbraith
2026-11-01 14:37 ` Chengfeng Lin
2026-11-01 17:46 ` Mike Galbraith
2026-11-02 7:58 ` Chengfeng Lin
2026-11-03 5:28 ` Mike Galbraith
2026-11-03 7:07 ` Tianchen Ding
2026-11-03 9:46 ` Chengfeng Lin
2026-11-06 16:43 ` Vincent Guittot
2026-11-07 4:17 ` Mike Galbraith [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-06-05 12:40 [PATCH v3 0/7] sched: Flatten the pick Peter Zijlstra
2026-06-05 12:40 ` [PATCH v3 7/7] sched/eevdf: Move to a single runqueue Peter Zijlstra
2026-06-20 3:54 ` Chen, Yu C
2026-06-26 11:40 ` Peter Zijlstra
2026-06-29 14:02 ` Vincent Guittot
2026-10-16 13:18 ` Jakub Okoński
2026-10-18 6:49 ` Mike Galbraith
2026-10-19 17:01 ` Vincent Guittot
2026-10-19 17:35 ` Jakub Okoński
2026-10-19 18:04 ` Vincent Guittot
2026-10-19 18:24 ` Jakub Okoński
2026-10-19 18:26 ` Vincent Guittot
2026-10-21 11:55 ` Vincent Guittot
2026-10-22 12:05 ` Jakub Okoński
2026-10-30 15:48 ` Chengfeng Lin
2026-10-22 2:12 ` Mike Galbraith
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=f2623ff14205adfb92518ef3b7aca053384f4cf7.camel@gmx.de \
--to=efault@gmx.de \
--cc=dtcccc@linux.alibaba.com \
--cc=juri.lelli@redhat.com \
--cc=lin2530632123@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--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
all inboxes | Powered by JetHome®