Skip to content

Commit 54a58a7

Browse files
author
Peter Zijlstra
committed
sched/fair: Implement DELAY_ZERO
'Extend' DELAY_DEQUEUE by noting that since we wanted to dequeued them at the 0-lag point, truncate lag (eg. don't let them earn positive lag). Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Valentin Schneider <[email protected]> Tested-by: Valentin Schneider <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 152e11f commit 54a58a7

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

kernel/sched/fair.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5447,8 +5447,11 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
54475447
if ((flags & (DEQUEUE_SAVE | DEQUEUE_MOVE)) != DEQUEUE_SAVE)
54485448
update_min_vruntime(cfs_rq);
54495449

5450-
if (flags & DEQUEUE_DELAYED)
5450+
if (flags & DEQUEUE_DELAYED) {
54515451
se->sched_delayed = 0;
5452+
if (sched_feat(DELAY_ZERO) && se->vlag > 0)
5453+
se->vlag = 0;
5454+
}
54525455

54535456
if (cfs_rq->nr_running == 0)
54545457
update_idle_cfs_rq_clock_pelt(cfs_rq);
@@ -5527,7 +5530,6 @@ pick_next_entity(struct rq *rq, struct cfs_rq *cfs_rq)
55275530
dequeue_entities(rq, se, DEQUEUE_SLEEP | DEQUEUE_DELAYED);
55285531
SCHED_WARN_ON(se->sched_delayed);
55295532
SCHED_WARN_ON(se->on_rq);
5530-
55315533
return NULL;
55325534
}
55335535
return se;
@@ -6825,6 +6827,20 @@ requeue_delayed_entity(struct sched_entity *se)
68256827
SCHED_WARN_ON(!se->sched_delayed);
68266828
SCHED_WARN_ON(!se->on_rq);
68276829

6830+
if (sched_feat(DELAY_ZERO)) {
6831+
update_entity_lag(cfs_rq, se);
6832+
if (se->vlag > 0) {
6833+
cfs_rq->nr_running--;
6834+
if (se != cfs_rq->curr)
6835+
__dequeue_entity(cfs_rq, se);
6836+
se->vlag = 0;
6837+
place_entity(cfs_rq, se, 0);
6838+
if (se != cfs_rq->curr)
6839+
__enqueue_entity(cfs_rq, se);
6840+
cfs_rq->nr_running++;
6841+
}
6842+
}
6843+
68286844
se->sched_delayed = 0;
68296845
}
68306846

kernel/sched/features.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ SCHED_FEAT(CACHE_HOT_BUDDY, true)
3434
* By delaying the dequeue for non-eligible tasks, they remain in the
3535
* competition and can burn off their negative lag. When they get selected
3636
* they'll have positive lag by definition.
37+
*
38+
* DELAY_ZERO clips the lag on dequeue (or wakeup) to 0.
3739
*/
3840
SCHED_FEAT(DELAY_DEQUEUE, true)
41+
SCHED_FEAT(DELAY_ZERO, true)
3942

4043
/*
4144
* Allow wakeup-time preemption of the current task:

0 commit comments

Comments
 (0)