Skip to content

Commit 6330455

Browse files
author
Peter Zijlstra
committed
sched/eevdf: Curb wakeup-preemption
Mike and others noticed that EEVDF does like to over-schedule quite a bit -- which does hurt performance of a number of benchmarks / workloads. In particular, what seems to cause over-scheduling is that when lag is of the same order (or larger) than the request / slice then placement will not only cause the task to be placed left of current, but also with a smaller deadline than current, which causes immediate preemption. [ notably, lag bounds are relative to HZ ] Mike suggested we stick to picking 'current' for as long as it's eligible to run, giving it uninterrupted runtime until it reaches parity with the pack. Augment Mike's suggestion by only allowing it to exhaust it's initial request. One random data point: echo NO_RUN_TO_PARITY > /debug/sched/features perf stat -a -e context-switches --repeat 10 -- perf bench sched messaging -g 20 -t -l 5000 3,723,554 context-switches ( +- 0.56% ) 9.5136 +- 0.0394 seconds time elapsed ( +- 0.41% ) echo RUN_TO_PARITY > /debug/sched/features perf stat -a -e context-switches --repeat 10 -- perf bench sched messaging -g 20 -t -l 5000 2,556,535 context-switches ( +- 0.51% ) 9.2427 +- 0.0302 seconds time elapsed ( +- 0.33% ) Suggested-by: Mike Galbraith <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 7170509 commit 6330455

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

kernel/sched/fair.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,13 @@ static struct sched_entity *pick_eevdf(struct cfs_rq *cfs_rq)
873873
if (curr && (!curr->on_rq || !entity_eligible(cfs_rq, curr)))
874874
curr = NULL;
875875

876+
/*
877+
* Once selected, run a task until it either becomes non-eligible or
878+
* until it gets a new slice. See the HACK in set_next_entity().
879+
*/
880+
if (sched_feat(RUN_TO_PARITY) && curr && curr->vlag == curr->deadline)
881+
return curr;
882+
876883
while (node) {
877884
struct sched_entity *se = __node_2_se(node);
878885

@@ -5167,6 +5174,11 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se)
51675174
update_stats_wait_end_fair(cfs_rq, se);
51685175
__dequeue_entity(cfs_rq, se);
51695176
update_load_avg(cfs_rq, se, UPDATE_TG);
5177+
/*
5178+
* HACK, stash a copy of deadline at the point of pick in vlag,
5179+
* which isn't used until dequeue.
5180+
*/
5181+
se->vlag = se->deadline;
51705182
}
51715183

51725184
update_stats_curr_start(cfs_rq, se);

kernel/sched/features.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
SCHED_FEAT(PLACE_LAG, true)
88
SCHED_FEAT(PLACE_DEADLINE_INITIAL, true)
9+
SCHED_FEAT(RUN_TO_PARITY, true)
910

1011
/*
1112
* Prefer to schedule the task we woke last (assuming it failed

0 commit comments

Comments
 (0)