mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 4/8] sched/eevdf: Decay positive lag of sleeping entities
Date: Tue, 22 Sep 2026 12:02:33 +0200	[thread overview]
Message-ID: <20260922100233.GP776954@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20260921152238.3804392-5-vincent.guittot@linaro.org>

On Mon, Sep 21, 2026 at 05:22:34PM +0200, Vincent Guittot wrote:
> Similarly to delayed dequeue that enables an entity to decay its negative
> lag while sleeping, a task should not keep a positive lag forever.
> 
> The sleep duration and the weight of the entity is used to decay the
> positive lag at wakeup.
> 
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
>  kernel/sched/fair.c | 33 +++++++++++++++++++++++++++++++--
>  1 file changed, 31 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index e6eb9a4c03be..4230954d10d0 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -896,6 +896,32 @@ bool update_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se)
>  	return avruntime - vlag != se->vruntime;
>  }
>  
> +static __always_inline
> +void decay_entity_lag(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
> +{
> +	s64 vlag = se->vlag;
> +	s64 delta_exec;
> +
> +	WARN_ON_ONCE(se->on_rq);
> +
> +	/* Negative lag implies delayed dequeue */
> +	if (vlag <= 0)
> +		return;
> +
> +	if (flags & ENQUEUE_MIGRATED)
> +		return;

Is not this a rather prevalent case?

> +
> +	/* Compute the sleep time */
> +	delta_exec = rq_clock_task(rq_of(cfs_rq)) - se->exec_start;
> +	if (unlikely(delta_exec <= 0))
> +		return;

Urgh, are we going to try and bring back all that sleep time stuff
again? ;-)

> +
> +	vlag -= calc_delta_fair(delta_exec, se);

Should this not be 'W+w' at the very least?, ideally it would be the
complete sum of all decaying weight rather than just 'w', but that might
be a tad tricky. 

> +
> +	/* vlag can't become negative while sleeping */
> +	se->vlag = max(0, vlag);
> +}

Anyway, the basic observation is that were this thing runnable, it would
have only a w/W share of runtime, not a w/w share.

Using the full fraction of sleep time like this will make the decay too
fast.

And dealing with that MIGRATED case is somewhat important; in which case
I suppose we can try and approximate by doing something like '(W1+W2)/2
+ w'.



  reply	other threads:[~2026-09-22 10:02 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21 15:22 [PATCH 0/8] Improving latency of short slice tasks Vincent Guittot
2026-09-21 15:22 ` [PATCH 1/8] sched/eevdf: Ensure that vprot will never go above a min slice Vincent Guittot
2026-09-21 15:22 ` [PATCH 2/8] sched/eevdf: Align update_protect_slice to set_protect_slice Vincent Guittot
2026-09-21 15:22 ` [PATCH 3/8] sched/eevdf: Handle more short slice waking cases Vincent Guittot
2026-09-21 15:22 ` [PATCH 4/8] sched/eevdf: Decay positive lag of sleeping entities Vincent Guittot
2026-09-22 10:02   ` Peter Zijlstra [this message]
2026-09-22 10:40     ` Peter Zijlstra
2026-09-22 12:56     ` Vincent Guittot
2026-09-22 13:28       ` Peter Zijlstra
2026-09-22 14:21         ` Vincent Guittot
2026-09-21 15:22 ` [PATCH 5/8] sched/eevdf: Reset lag when waking up on idle cpu Vincent Guittot
2026-09-21 16:06   ` Kayra Cizmeci
2026-09-22  5:56     ` Vincent Guittot
2026-09-22 10:13   ` Peter Zijlstra
2026-09-22 14:20     ` Vincent Guittot
2026-09-22 14:32     ` Kayra Cizmeci
2026-09-21 15:22 ` [PATCH 6/8] sched/eevdf: Add per cpu cached min_slice Vincent Guittot
2026-09-22 10:17   ` Peter Zijlstra
2026-09-22 14:19     ` Vincent Guittot
2026-09-21 15:22 ` [PATCH 7/8] sched/eevdf: Compare min slice during wake_affine Vincent Guittot
2026-09-21 15:22 ` [PATCH 8/8] sched/eevdf: Add min slice check when selecting CPU Vincent Guittot
2026-09-22 10:46   ` Peter Zijlstra
2026-09-22 12:31     ` 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=20260922100233.GP776954@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®