[PATCH] sched/deadline: cleanup prio_changed_dl()

From: Juri Lelli
Date: Tue Mar 03 2015 - 02:51:56 EST


rq->curr task can't be in "dequeued" state in prio_changed_dl()
(The only place we can have that is __schedule()), but it can
be throttled, in which case we shouldn't do balancing.

Also modify the "else" branch, which is dead code (switched_to_dl()
is not interested in dequeued tasks and we are not interested
in balancing in this case), to take into account updates to not
running tasks.

Signed-off-by: Juri Lelli <juri.lelli@xxxxxxx>
Suggested-by: Kirill Tkhai <ktkhai@xxxxxxxxxxxxx>
Suggested-by: Wanpeng Li <wanpeng.li@xxxxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Juri Lelli <juri.lelli@xxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
kernel/sched/deadline.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index cfa45c1..9d83748 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1759,7 +1759,10 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
static void prio_changed_dl(struct rq *rq, struct task_struct *p,
int oldprio)
{
- if (task_on_rq_queued(p) || rq->curr == p) {
+ if (!on_dl_rq(&p->dl))
+ return;
+
+ if (rq->curr == p) {
#ifdef CONFIG_SMP
/*
* This might be too much, but unfortunately
@@ -1786,8 +1789,15 @@ static void prio_changed_dl(struct rq *rq, struct task_struct *p,
*/
resched_curr(rq);
#endif /* CONFIG_SMP */
- } else
- switched_to_dl(rq, p);
+ } else {
+ /*
+ * This task is not running, so if its deadline is
+ * now more imminent than that of the current running
+ * task then reschedule.
+ */
+ if (dl_time_before(p->dl.deadline, rq->curr->dl.deadline))
+ resched_curr(rq);
+ }
}

const struct sched_class dl_sched_class = {
--
2.3.0

> Signed-off-by: Wanpeng Li <wanpeng.li@xxxxxxxxxxxxxxx>
> ---
> kernel/sched/deadline.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 49f92c8..ca391c0 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -1728,7 +1728,10 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
> static void prio_changed_dl(struct rq *rq, struct task_struct *p,
> int oldprio)
> {
> - if (task_on_rq_queued(p) || rq->curr == p) {
> + if (!task_on_rq_queued(p))
> + return;
> +
> + if (rq->curr == p) {
> #ifdef CONFIG_SMP
> /*
> * This might be too much, but unfortunately
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/