Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 147f3ef

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
sched/fair: Implement an EEVDF-like scheduling policy
Where CFS is currently a WFQ based scheduler with only a single knob, the weight. The addition of a second, latency oriented parameter, makes something like WF2Q or EEVDF based a much better fit. Specifically, EEVDF does EDF like scheduling in the left half of the tree -- those entities that are owed service. Except because this is a virtual time scheduler, the deadlines are in virtual time as well, which is what allows over-subscription. EEVDF has two parameters: - weight, or time-slope: which is mapped to nice just as before - request size, or slice length: which is used to compute the virtual deadline as: vd_i = ve_i + r_i/w_i Basically, by setting a smaller slice, the deadline will be earlier and the task will be more eligible and ran earlier. Tick driven preemption is driven by request/slice completion; while wakeup preemption is driven by the deadline. Because the tree is now effectively an interval tree, and the selection is no longer 'leftmost', over-scheduling is less of a problem. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 99d4d26 commit 147f3ef

File tree

6 files changed

+308
-48
lines changed

6 files changed

+308
-48
lines changed

include/linux/sched.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,9 @@ struct sched_entity {
549549
/* For load-balancing: */
550550
struct load_weight load;
551551
struct rb_node run_node;
552+
u64 deadline;
553+
u64 min_deadline;
554+
552555
struct list_head group_node;
553556
unsigned int on_rq;
554557

@@ -557,6 +560,7 @@ struct sched_entity {
557560
u64 prev_sum_exec_runtime;
558561
u64 vruntime;
559562
s64 vlag;
563+
u64 slice;
560564

561565
u64 nr_migrations;
562566

kernel/sched/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4502,6 +4502,7 @@ static void __sched_fork(unsigned long clone_flags, struct task_struct *p)
45024502
p->se.nr_migrations = 0;
45034503
p->se.vruntime = 0;
45044504
p->se.vlag = 0;
4505+
p->se.slice = sysctl_sched_min_granularity;
45054506
INIT_LIST_HEAD(&p->se.group_node);
45064507

45074508
#ifdef CONFIG_FAIR_GROUP_SCHED

kernel/sched/debug.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,13 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p)
582582
else
583583
SEQ_printf(m, " %c", task_state_to_char(p));
584584

585-
SEQ_printf(m, " %15s %5d %9Ld.%06ld %9Ld %5d ",
585+
SEQ_printf(m, "%15s %5d %9Ld.%06ld %c %9Ld.%06ld %9Ld.%06ld %9Ld.%06ld %9Ld %5d ",
586586
p->comm, task_pid_nr(p),
587587
SPLIT_NS(p->se.vruntime),
588+
entity_eligible(cfs_rq_of(&p->se), &p->se) ? 'E' : 'N',
589+
SPLIT_NS(p->se.deadline),
590+
SPLIT_NS(p->se.slice),
591+
SPLIT_NS(p->se.sum_exec_runtime),
588592
(long long)(p->nvcsw + p->nivcsw),
589593
p->prio);
590594

0 commit comments

Comments
 (0)