Skip to content

Commit ff38424

Browse files
Wang TaoPeter Zijlstra
authored andcommitted
sched/eevdf: Update se->vprot in reweight_entity()
In the EEVDF framework with Run-to-Parity protection, `se->vprot` is an independent variable defining the virtual protection timestamp. When `reweight_entity()` is called (e.g., via nice/renice), it performs the following actions to preserve Lag consistency: 1. Scales `se->vlag` based on the new weight. 2. Calls `place_entity()`, which recalculates `se->vruntime` based on the new weight and scaled lag. However, the current implementation fails to update `se->vprot`, leading to mismatches between the task's actual runtime and its expected duration. Fixes: 6330455 ("sched/eevdf: Curb wakeup-preemption") Suggested-by: Zhang Qiao <zhangqiao22@huawei.com> Signed-off-by: Wang Tao <wangtao554@huawei.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org> Tested-by: K Prateek Nayak <kprateek.nayak@amd.com> Tested-by: Shubhang Kaushik <shubhang@os.amperecomputing.com> Link: https://patch.msgid.link/20260120123113.3518950-1-wangtao554@huawei.com
1 parent bcd74b2 commit ff38424

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

kernel/sched/fair.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3815,13 +3815,20 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
38153815
unsigned long weight)
38163816
{
38173817
bool curr = cfs_rq->curr == se;
3818+
bool rel_vprot = false;
3819+
u64 vprot;
38183820

38193821
if (se->on_rq) {
38203822
/* commit outstanding execution time */
38213823
update_curr(cfs_rq);
38223824
update_entity_lag(cfs_rq, se);
38233825
se->deadline -= se->vruntime;
38243826
se->rel_deadline = 1;
3827+
if (curr && protect_slice(se)) {
3828+
vprot = se->vprot - se->vruntime;
3829+
rel_vprot = true;
3830+
}
3831+
38253832
cfs_rq->nr_queued--;
38263833
if (!curr)
38273834
__dequeue_entity(cfs_rq, se);
@@ -3837,6 +3844,9 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
38373844
if (se->rel_deadline)
38383845
se->deadline = div_s64(se->deadline * se->load.weight, weight);
38393846

3847+
if (rel_vprot)
3848+
vprot = div_s64(vprot * se->load.weight, weight);
3849+
38403850
update_load_set(&se->load, weight);
38413851

38423852
do {
@@ -3848,6 +3858,8 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se,
38483858
enqueue_load_avg(cfs_rq, se);
38493859
if (se->on_rq) {
38503860
place_entity(cfs_rq, se, 0);
3861+
if (rel_vprot)
3862+
se->vprot = se->vruntime + vprot;
38513863
update_load_add(&cfs_rq->load, se->load.weight);
38523864
if (!curr)
38533865
__enqueue_entity(cfs_rq, se);

0 commit comments

Comments
 (0)