From: K Prateek Nayak <kprateek.nayak@amd.com>
To: Peter Zijlstra <peterz@infradead.org>,
Vincent Guittot <vincent.guittot@linaro.org>
Cc: "wangtao (EQ)" <wangtao554@huawei.com>, <mingo@redhat.com>,
<juri.lelli@redhat.com>, <dietmar.eggemann@arm.com>,
<rostedt@goodmis.org>, <bsegall@google.com>, <mgorman@suse.de>,
<vschneid@redhat.com>, <tanghui20@huawei.com>,
<zhangqiao22@huawei.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sched/eevdf: Update se->vprot in reweight_entity()
Date: Fri, 23 Jan 2026 22:09:05 +0530 [thread overview]
Message-ID: <44c45e82-25e7-4d70-a46d-fb34e6aacbd6@amd.com> (raw)
In-Reply-To: <20260123153854.GU166857@noisy.programming.kicks-ass.net>
Hello Peter,
On 1/23/2026 9:08 PM, Peter Zijlstra wrote:
> On Wed, Jan 21, 2026 at 06:00:15PM +0100, Vincent Guittot wrote:
>
>> Why not use update_protect_slice() like when a new task with a shorter
>> slice is added ?
>
> That seems wrong too...
>
> I was going over this, and should we not limit set_protect_slice() to
> the first set_next_entity(). That is, AFAICT we'll re-set it on
> sched_change -- which sounds wrong to me.
That makes sense.
>
> Anyway, I ended up with something like so (should probably be split in
> two patches).
>
> ---
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index eca642295c4b..bab51da3d179 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -3790,6 +3790,7 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
> unsigned long weight)
> {
> bool curr = cfs_rq->curr == se;
> + u64 vprot = 0;
>
> if (se->on_rq) {
> /* commit outstanding execution time */
> @@ -3797,6 +3798,9 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
> update_entity_lag(cfs_rq, se);
> se->deadline -= se->vruntime;
> se->rel_deadline = 1;
> + if (curr && protect_slice(se))
> + vprot = se->vprot - se->vruntime;
> +
> cfs_rq->nr_queued--;
> if (!curr)
> __dequeue_entity(cfs_rq, se);
> @@ -3812,6 +3816,9 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
> if (se->rel_deadline)
> se->deadline = div_s64(se->deadline * se->load.weight, weight);
>
> + if (vprot)
> + vprot = div_s64(vprot * se->load.weight, weight);
> +
> update_load_set(&se->load, weight);
>
> do {
> @@ -3823,6 +3830,8 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
> enqueue_load_avg(cfs_rq, se);
> if (se->on_rq) {
> place_entity(cfs_rq, se, 0);
> + if (vprot)
> + se->vprot = se->vruntime + vprot;
Scaling vprot makes sense too. Can there be a problem where "vprot"
turns to zero on scaling (weight > (vprot * se->load.weight)) but we
don't end up updating "se->vprot"?
Probably rare but a higher weight implies it might take a tad bit
longer to hit that old "vprot" but since we are losing the precision,
can the pending "se->vprot" be big enough to cause any issue?
Since we are looking at these bits, can you also please take a look at
https://lore.kernel.org/lkml/20251226001731.3730586-1-quzicheng@huawei.com/
which I feel might be a genuine issue when we are reweight the curr's
vruntime.
> update_load_add(&cfs_rq->load, se->load.weight);
> if (!curr)
> __enqueue_entity(cfs_rq, se);
--
Thanks and Regards,
Prateek
next prev parent reply other threads:[~2026-01-23 16:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-20 12:31 Wang Tao
2026-01-21 4:21 ` K Prateek Nayak
2026-01-21 9:33 ` wangtao (EQ)
2026-01-21 17:00 ` Vincent Guittot
2026-01-22 4:38 ` K Prateek Nayak
2026-01-23 16:38 ` Vincent Guittot
2026-01-22 7:52 ` wangtao (EQ)
2026-01-23 17:32 ` Vincent Guittot
2026-01-23 15:38 ` Peter Zijlstra
2026-01-23 16:39 ` K Prateek Nayak [this message]
2026-01-23 21:31 ` Peter Zijlstra
2026-01-23 17:37 ` Vincent Guittot
2026-02-23 10:25 ` [tip: sched/urgent] " tip-bot2 for 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=44c45e82-25e7-4d70-a46d-fb34e6aacbd6@amd.com \
--to=kprateek.nayak@amd.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tanghui20@huawei.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=wangtao554@huawei.com \
--cc=zhangqiao22@huawei.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®