sched/deadline: fix try to pull pinned dl tasks in pull algorithm
PATCH 1/3 sched/deadline: fix try to pull pinned dl tasks in pull algorithm
Function pick_next_earliest_dl_task is used to pick earliest and pushable dl task from overloaded cpus in pull algorithm, however, it traverses runqueue rbtree instead of pushable task rbtree which is also ordered by tasks' deadlines. This will result in getting no candidates from overloaded cpus if all the dl tasks on the overloaded cpus are pinned. This patch fix it by traversing pushable task rbtree which is also ordered by tasks' deadlines.
--- kernel/sched/deadline.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
kernel/sched/deadline.c +28 -1
@@ -1230,6 +1230,33 @@ next_node:return NULL ; } +/* +* Return the earliest pushable rq's task, which is suitable to be executed +* on the cpu, NULL otherwse +*/ +static struct task_struct *pick_earliest_pushable_dl_task (struct rq *rq, +int cpu) +{ +struct rb_node *next_node = rq->dl.pushable_dl_tasks_leftmost; +struct task_struct *p =NULL ; + +if (!has_pushable_dl_tasks (rq)) +return NULL ; + +next_node: +if (next_node) { + p = rb_entry(next_node, struct task_struct, pushable_dl_tasks); + +if (pick_dl_task (rq, p, cpu)) +return p; + + next_node =rb_next (next_node); + goto next_node; + } + +return NULL ; +} + static DEFINE_PER_CPU(cpumask_var_t, local_cpu_mask_dl);static int find_later_rq (struct task_struct *task)
@@ -1514,7 +1541,7 @@ static int pull_dl_task(struct rq *this_rq)if (src_rq->dl.dl_nr_running <=1 ) goto skip; - p =pick_next_earliest_dl_task (src_rq, this_cpu); + p =pick_earliest_pushable_dl_task (src_rq, this_cpu);/* * We found a task to be pulled if:
Signature · 1 line
1.9.1
PATCH 2/3 sched/deadline: make init_sched_dl_class() __init
It's a bootstrap function, make init_sched_dl_class() __init.
--- kernel/sched/deadline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/deadline.c +1 -1
@@ -1685,7 +1685,7 @@ static void rq_offline_dl(struct rq *rq)cpudl_clear_freecpu (&rq->rd->cpudl, rq->cpu); } -void init_sched_dl_class (void ) +void __init init_sched_dl_class (void ) {unsigned int i;
Signature · 1 line
1.9.1
PATCH 3/3 sched/deadline: reduce rq lock contention by eliminating locking of non-feasible target
In reply to Wanpeng LiThis patch adds check that prevents futile attempts to move dl tasks to a CPU with active tasks of equal or earlier deadline. The same behavior as commit 80e3d87b2c55 ("sched/rt: Reduce rq lock contention by eliminating locking of non-feasible target") for rt class.
--- kernel/sched/deadline.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/sched/deadline.c +3 -1
@@ -1012,7 +1012,9 @@ select_task_rq_dl(struct task_struct *p, int cpu, int sd_flag, int flags) (p->nr_cpus_allowed > 1)) {int target =find_later_rq (p); -if (target !=-1 ) +if (target !=-1 && +dl_time_before (p->dl.deadline, +cpu_rq (target)->dl.earliest_dl.curr)) cpu = target; }rcu_read_unlock ();
Signature · 1 line
1.9.1