sched/rt: check if curr can be pushed/pulled somewhere else in advance
PATCH v2 1/6 sched/rt: check if curr can be pushed/pulled somewhere else in advance
This patch checks if current can be pushed/pulled somewhere else in advance to make logic clear, the same behavior as rt class.
- If current can't be migrated, useless to reschedule, let's hope task can move out.
- If task is migratable, so let's not schedule it and see if it can be pushed or pulled somewhere else.
--- kernel/sched/rt.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
kernel/sched/rt.c +10 -4
@@ -1351,16 +1351,22 @@ out:static void check_preempt_equal_prio (struct rq *rq,struct task_struct *p) { -if (rq->curr->nr_cpus_allowed ==1 ) +/* +* Current can't be migrated, useless to reschedule, +* let's hope p can move out. +*/ +if (rq->curr->nr_cpus_allowed ==1 || + !cpupri_find (&rq->rd->cpupri, rq->curr,NULL ))return ; +/* +* p is migratable, so let's not schedule it and +* see if it is pushed or pulled somewhere else. +*/ if (p->nr_cpus_allowed !=1 &&cpupri_find (&rq->rd->cpupri, p,NULL ))return ; -if (!cpupri_find (&rq->rd->cpupri, rq->curr,NULL )) -return ; -/* * There appears to be other cpus that can accept * current and none to run 'p', so lets reschedule
Signature · 1 line
1.9.1
PATCH v2 2/6 sched/deadline: fix artificial overrun introduced by yield_task_dl
The yield semantic of deadline class is to reduce remaining runtime to zero, and then update_curr_dl() will stop it. However, comsumed bandwidth is reduced from the budget of yield task again even if it has already been set to zero which leads to artificial overrun. This patch fix it by make sure we don't steal some more time from the task that yielded in update_curr_dl().
---
v1 -> v2:
* make sure we don't steal some more time from the task that yielded in update_curr_dl().
kernel/sched/deadline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/deadline.c +1 -1
@@ -633,7 +633,7 @@ static void update_curr_dl(struct rq *rq)sched_rt_avg_update (rq, delta_exec); - dl_se->runtime -= delta_exec; + dl_se->runtime -= dl_se->dl_yielded ?0 : delta_exec;if (dl_runtime_exceeded (rq, dl_se)) {__dequeue_task_dl (rq, curr,0 );if (likely (start_dl_timer (dl_se, curr->dl.dl_boosted)))
Signature · 1 line
1.9.1
PATCH v2 3/6 sched/dl: add deadline rq status print
In reply to Wanpeng LiThis patch add deadline rq status print.
--- kernel/sched/deadline.c | 9 +++++++++ kernel/sched/debug.c | 7 +++++++ kernel/sched/sched.h | 1 + 3 files changed, 17 insertions(+)
kernel/sched/deadline.c +9 -0
@@ -1727,3 +1727,12 @@ const struct sched_class dl_sched_class = { .switched_from = switched_from_dl, .switched_to = switched_to_dl, }; + +#ifdef CONFIG_SCHED_DEBUG +extern void print_dl_rq (struct seq_file *m,int cpu,struct dl_rq *dl_rq); + +void print_dl_stats (struct seq_file *m,int cpu) +{ +print_dl_rq (m, cpu, &cpu_rq (cpu)->dl); +} +#endif /* CONFIG_SCHED_DEBUG */
kernel/sched/debug.c +7 -0
@@ -261,6 +261,12 @@ void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq)#undef P } +void print_dl_rq (struct seq_file *m,int cpu,struct dl_rq *dl_rq) +{ +SEQ_printf (m,"\ndl_rq[%d]:\n" , cpu); +SEQ_printf (m," .%-30s: %ld\n" ,"dl_nr_running" , dl_rq->dl_nr_running); +} +extern __read_mostly int sched_clock_running;static void print_cpu (struct seq_file *m,int cpu)
@@ -329,6 +335,7 @@ do { \spin_lock_irqsave (&sched_debug_lock, flags);print_cfs_stats (m, cpu);print_rt_stats (m, cpu); +print_dl_stats (m, cpu);print_rq (m, rq, cpu);spin_unlock_irqrestore (&sched_debug_lock, flags);
kernel/sched/sched.h +1 -0
@@ -1532,6 +1532,7 @@ extern struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq);extern struct sched_entity *__pick_last_entity (struct cfs_rq *cfs_rq);extern void print_cfs_stats (struct seq_file *m,int cpu);extern void print_rt_stats (struct seq_file *m,int cpu); +extern void print_dl_stats (struct seq_file *m,int cpu);extern void init_cfs_rq (struct cfs_rq *cfs_rq);extern void init_rt_rq (struct rt_rq *rt_rq,struct rq *rq);
Signature · 1 line
1.9.1
PATCH v2 4/6 sched/dl: push task away if the deadline is equal to curr during wakeup
In reply to Wanpeng LiThis patch pushes task away if the dealine of the task is equal to current during wake up. The same behavior as rt class.
--- kernel/sched/deadline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/deadline.c +1 -1
@@ -1511,7 +1511,7 @@ static void task_woken_dl(struct rq *rq, struct task_struct *p) p->nr_cpus_allowed > 1 && dl_task(rq->curr) && (rq->curr->nr_cpus_allowed < 2 || - dl_entity_preempt(&rq->curr->dl, &p->dl))) { + !dl_entity_preempt(&p->dl, &rq->curr->dl))) {push_dl_tasks (rq); } }
Signature · 1 line
1.9.1
PATCH v2 5/6 sched/deadline: reschedule from switched_from_dl() after a successful pull
In reply to Wanpeng LiIn switched_from_dl() we have to issue a resched if we successfully pulled some task from other cpus. This patch also aligns the behavior with -rt.
---
v1 -> v2:
* align the behaviour with -rt.
kernel/sched/deadline.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
kernel/sched/deadline.c +5 -2
@@ -1623,8 +1623,11 @@ static void switched_from_dl(struct rq *rq, struct task_struct *p)* this is the right place to try to pull some other one * from an overloaded cpu, if any. */ -if (!rq->dl.dl_nr_running) -pull_dl_task (rq); +if (!task_on_rq_queued (p) || rq->dl.dl_nr_running) +return ; + +if (pull_dl_task (rq)) +resched_curr (rq);#endif }
Signature · 1 line
1.9.1
PATCH v2 6/6 sched/dl: don't check CONFIG_SMP in switched_from_dl
In reply to Wanpeng LiThere are both UP and SMP version of pull_dl_task(), so don't need to check CONFIG_SMP in switched_from_dl();
--- kernel/sched/deadline.c | 2 -- 1 file changed, 2 deletions(-)
kernel/sched/deadline.c +0 -2
@@ -1617,7 +1617,6 @@ static void switched_from_dl(struct rq *rq, struct task_struct *p)__dl_clear_params (p); -#ifdef CONFIG_SMP /* * Since this might be the only -deadline task on the rq, * this is the right place to try to pull some other one
@@ -1628,7 +1627,6 @@ static void switched_from_dl(struct rq *rq, struct task_struct *p)if (pull_dl_task (rq))resched_curr (rq); -#endif }/*
Signature · 1 line
1.9.1
Hi,
В Чт, 30/10/2014 в 22:16 +0800, Wanpeng Li пишет:
Quoted 7 lines
This patch checks if current can be pushed/pulled somewhere else in advance to make logic clear, the same behavior as rt class.
- If current can't be migrated, useless to reschedule, let's hope task can move out.
- If task is migratable, so let's not schedule it and see if it can be pushed or pulled somewhere else.
No functional changes, are they? So I'd suggest to change subject on something connected with "cleanup".
Also, the description confuses. Please, write that code was cleaned up, and that comments were added.
Quoted 11 lines
Signed-off-by Wanpeng Li <[email protected]>--- kernel/sched/rt.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)kernel/sched/rt.c +0
-0@@ -1351,16 +1351,22 @@ out:
kernel/sched/rt.c out: · line 1360
Quoted 10 lines
kernel/sched/rt.c +6
-1static void check_preempt_equal_prio (struct rq *rq,struct task_struct *p) { -if (rq->curr->nr_cpus_allowed ==1 ) +/* +* Current can't be migrated, useless to reschedule, +* let's hope p can move out. +*/ +if (rq->curr->nr_cpus_allowed ==1 || + !cpupri_find (&rq->rd->cpupri, rq->curr,NULL ))return ;
All conditions of multi-line if() should be aligned the same:
+ if (rq->curr->nr_cpus_allowed == 1 ||
+ !cpupri_find(&rq->rd->cpupri, rq->curr, NULL))
Quoted 5 lines
kernel/sched/rt.c +4
-0+/* +* p is migratable, so let's not schedule it and +* see if it is pushed or pulled somewhere else. +*/
kernel/sched/rt.c out: · line 1372
Quoted 10 lines
kernel/sched/rt.c +0
-3if (p->nr_cpus_allowed !=1 &&cpupri_find (&rq->rd->cpupri, p,NULL ))return ; -if (!cpupri_find (&rq->rd->cpupri, rq->curr,NULL )) -return ; -/* * There appears to be other cpus that can accept * current and none to run 'p', so lets reschedule
Thanks,
Kirill
Hi Kirill,
Quoted 11 lines · Kirill Tkhai
Hi,
В Чт, 30/10/2014 в 22:16 +0800, Wanpeng Li пишет:
Quoted 7 lines
This patch checks if current can be pushed/pulled somewhere else in advance to make logic clear, the same behavior as rt class.
- If current can't be migrated, useless to reschedule, let's hope task can move out.
- If task is migratable, so let's not schedule it and see if it can be pushed or pulled somewhere else.
Quoted 6 lines
No functional changes, are they? So I'd suggest to change subject on something connected with "cleanup".
Also, the description confuses. Please, write that code was cleaned up, and that comments were added.
Ok.
Quoted 25 lines
Quoted 11 lines
Signed-off-by Wanpeng Li <[email protected]>--- kernel/sched/rt.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)kernel/sched/rt.c +0
-0@@ -1351,16 +1351,22 @@ out:kernel/sched/rt.c out: · line 1360
Quoted 10 lines
kernel/sched/rt.c +6
-1static void check_preempt_equal_prio (struct rq *rq,struct task_struct *p) { -if (rq->curr->nr_cpus_allowed ==1 ) +/* +* Current can't be migrated, useless to reschedule, +* let's hope p can move out. +*/ +if (rq->curr->nr_cpus_allowed ==1 || + !cpupri_find (&rq->rd->cpupri, rq->curr,NULL ))return ;All conditions of multi-line
if()should be aligned the same:
kernel/sched/rt.c out: · line 1359
Quoted 2 lines
kernel/sched/rt.c +2
-0+if (rq->curr->nr_cpus_allowed ==1 || + !cpupri_find (&rq->rd->cpupri, rq->curr,NULL ))
I will update the patch in next version, thanks for your review.
Regards,
Wanpeng Li
Quoted 19 lines
Quoted 5 lines
kernel/sched/rt.c +4
-0+/* +* p is migratable, so let's not schedule it and +* see if it is pushed or pulled somewhere else. +*/ kernel/sched/rt.c out: · line 1372
Quoted 10 lines
kernel/sched/rt.c +0
-3if (p->nr_cpus_allowed !=1 &&cpupri_find (&rq->rd->cpupri, p,NULL ))return ; -if (!cpupri_find (&rq->rd->cpupri, rq->curr,NULL )) -return ; -/* * There appears to be other cpus that can accept * current and none to run 'p', so lets reschedule Thanks,
Kirill