From: Kayra Cizmeci <kayracizmeci@gmail.com>
To: peterz@infradead.org, vincent.guittot@linaro.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>
Cc: christian.loehle@arm.com, elif.topuz@arm.com,
linux-kernel@vger.kernel.org, mingo@kernel.org, sh@gentwo.org,
Kayra Cizmeci <kayracizmeci@gmail.com>
Subject: [PATCH v3] sched/eevdf: Fix vprot across reweighting
Date: Fri, 16 Oct 2026 11:46:04 +0300 [thread overview]
Message-ID: <20261016084604.17999-1-kayracizmeci@gmail.com> (raw)
Currently in reweighting, while a tasks vruntime changes dead protection
could go alive, or alive protection could decrease, increase and go dead.
Fix it.
Fixes: 80390ead2080 ("sched/fair: Separate se->vlag from se->vprot")
Fixes: bcd74b2ffdd0 ("sched/fair: Only set slice protection at pick time")
Suggested-by: Vincent Guittot <vincent.guittot@linaro.org>
Signed-off-by: Kayra Cizmeci <kayracizmeci@gmail.com>
---
Changes v2->v3:
* Rebase and move the enqueue_task_fair() block to if (!curr) block.
Not tested at all :-(. But I think
This should'a cover the shced_change_begin() path same,
since curr == NULL, so we always enter if (!curr) block.
kernel/sched/fair.c | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 0feec172fd37..4593d0122d66 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4892,12 +4892,15 @@ static void reweight_eevdf(struct cfs_rq *cfs_rq, struct sched_entity *se,
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;
+ if (rel_vprot)
+ se->vprot += avruntime;
+ else if (curr)
+ se->vprot = se->vruntime;
+
if (!curr)
__enqueue_entity(cfs_rq, se);
cfs_rq->h_nr_queued++;
@@ -8155,8 +8158,9 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
int task_new = !(flags & ENQUEUE_WAKEUP);
struct sched_entity *se = &p->se;
struct cfs_rq *cfs_rq = &rq->cfs;
- unsigned long weight;
- bool curr;
+ unsigned long weight, old_weight;
+ bool curr, live, running;
+ s64 dist;
if (task_is_throttled(p) && enqueue_throttled_task(p))
return;
@@ -8200,8 +8204,24 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags)
weight = enqueue_hierarchy(p, flags);
if (!curr) {
+ running = task_current_donor(rq, p);
+ live = running && protect_slice(se);
+
+ if (live) {
+ old_weight = se->h_load.weight;
+ dist = se->vprot - se->vruntime;
+ }
reweight_eevdf(cfs_rq, se, weight, false);
place_entity(cfs_rq, se, flags | ENQUEUE_QUEUED);
+
+ if (live) {
+ if (weight != old_weight)
+ dist = div64_long(dist * old_weight, weight);
+ se->vprot = se->vruntime + dist;
+ } else if (running) {
+ cancel_protect_slice(se);
+ }
+
__enqueue_entity(cfs_rq, se);
}
--
2.53.0
next reply other threads:[~2026-10-16 8:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 8:46 Kayra Cizmeci [this message]
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
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=20261016084604.17999-1-kayracizmeci@gmail.com \
--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®