From: Kayra Cizmeci <kayracizmeci@gmail.com>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: peterz@infradead.org, Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
christian.loehle@arm.com, elif.topuz@arm.com,
linux-kernel@vger.kernel.org, mingo@kernel.org, sh@gentwo.org
Subject: Re: [PATCH v3] sched/eevdf: Fix vprot across reweighting
Date: Fri, 16 Oct 2026 13:51:01 +0300 [thread overview]
Message-ID: <atH-Rf-yL7ewRTgD@scheduler.schedules> (raw)
In-Reply-To: <atH8BI9jCf2gqjTb@vingu-cube>
On Fri, Oct 16, 2026 at 12:27:16PM +0200, Vincent Guittot wrote:
> Le vendredi 16 oct. 2026 à 12:45:45 (+0300), Kayra Cizmeci a écrit :
> > > se != curr so why is this needed?
> >
> > sched_change_begin() sets .running as task_current_donor(), then if
> > .running is true calls put_prev_task(). put_prev_task_fair() sets
> > cfs_rq->curr to NULL. While the task still is the donor. Then we enter
> > sched_change_end(), we call enqueue_task() with cfs_rq->curr == NULL but
> > the donor is still p. There is set_next_task() call afterwards, but it
> > does not sets protection since its called with SNT_NORMAL.
>
> okay, but we don't want to spread this all over the code.
> reweight_eevdf/scale_entity is doing this already.
>
> The below should do the stuff while keeping the computation in reweight_eevdf:
>
> ---
> kernel/sched/fair.c | 26 ++++++++++++++++++--------
> 1 file changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 0feec172fd37..c212c6aa9691 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -4863,10 +4863,11 @@ rescale_entity(struct sched_entity *se, unsigned long weight, bool rel_vprot)
> }
>
> static void reweight_eevdf(struct cfs_rq *cfs_rq, struct sched_entity *se,
> - unsigned long weight, bool on_rq)
> + unsigned long weight, bool update_vprot)
> {
> bool curr = cfs_rq->curr == se;
> bool rel_vprot = false;
> + bool on_rq = se->on_rq;
> u64 avruntime = 0;
>
> if (se->h_load.weight == weight)
> @@ -4878,22 +4879,25 @@ static void reweight_eevdf(struct cfs_rq *cfs_rq, struct sched_entity *se,
> se->deadline -= avruntime;
> se->rel_deadline = 1;
> if (curr && protect_slice(se)) {
> - se->vprot -= avruntime;
> rel_vprot = true;
> }
>
> cfs_rq->h_nr_queued--;
> if (!curr)
> __dequeue_entity(cfs_rq, se);
> + } else if (update_vprot) {
> + avruntime = se->vruntime;
> + rel_vprot = true;
> }
>
> + if (rel_vprot)
> + se->vprot -= avruntime;
> +
> rescale_entity(se, weight, rel_vprot);
>
> update_load_set(&se->h_load, weight);
>
> if (on_rq) {
> - if (rel_vprot)
> - se->vprot += avruntime;
> se->deadline += avruntime;
> se->rel_deadline = 0;
> se->vruntime = avruntime - se->vlag;
> @@ -4902,6 +4906,12 @@ static void reweight_eevdf(struct cfs_rq *cfs_rq, struct sched_entity *se,
> __enqueue_entity(cfs_rq, se);
> cfs_rq->h_nr_queued++;
> }
> +
> + if (rel_vprot)
> + se->vprot += avruntime;
> + else if (curr || update_vprot)
> + se->vprot = se->vruntime;
> +
> }
>
> static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
> @@ -4965,7 +4975,7 @@ static void reweight_task_fair(struct rq *rq, struct task_struct *p,
> for_each_sched_entity(se)
> weight = __calc_prop_weight(cfs_rq_of(se), se, weight);
>
> - reweight_eevdf(&rq->cfs, &p->se, weight, p->se.on_rq);
> + reweight_eevdf(&rq->cfs, &p->se, weight, false);
> }
>
> static inline int throttled_hierarchy(struct cfs_rq *cfs_rq);
> @@ -8200,7 +8210,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
> weight = enqueue_hierarchy(p, flags);
>
> if (!curr) {
> - reweight_eevdf(cfs_rq, se, weight, false);
> + reweight_eevdf(cfs_rq, se, weight, task_current_donor(rq, p));
> place_entity(cfs_rq, se, flags | ENQUEUE_QUEUED);
> __enqueue_entity(cfs_rq, se);
> }
On the old code on_rq was always false. But because enqueue_hierarchy(),
se->on_rq is always true. So this just goes to the other path in
reweight_eevdf().
Also, vruntime can move in place_entity() too.
Thanks!
Kayra
next prev parent reply other threads:[~2026-10-16 10:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 8:46 Kayra Cizmeci
2026-10-16 9:15 ` Vincent Guittot
2026-10-16 9:45 ` Kayra Cizmeci
2026-10-16 10:27 ` Vincent Guittot
2026-10-16 10:51 ` Kayra Cizmeci [this message]
2026-10-16 14:06 ` Vincent Guittot
2026-10-16 14:22 ` Kayra Cizmeci
2026-10-16 14:36 ` 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=atH-Rf-yL7ewRTgD@scheduler.schedules \
--to=kayracizmeci@gmail.com \
--cc=bsegall@google.com \
--cc=christian.loehle@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=elif.topuz@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sh@gentwo.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®