Skip to contentSkip to conversation

sched/deadline: fix pull if dl task who's prio changed is not on queue

PATCH RESEND In review Wanpeng Li 2 participants 4 messages Feb 26, 2015 – Mar 5, 2015 Scheduler

lore
Share & tools
lore

Wanpeng Li

author
#0 lore raw

PATCH RESEND 1/1 sched/deadline: fix pull if dl task who's prio changed is not on queue

Dl task who is not on queue and it is also the curr task simultaneously can not happen. In addition, pull since the priority of a not on queue dl task doesn't make any sense.

This patch fix it by don't pull if dl task who's prio changed is not on queue.

---
 kernel/sched/deadline.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/sched/deadline.c +4 -1
index 49f92c8..ca391c0 100644
@@ -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
Signature · 1 line
1.9.1
#1 lore raw

Hi,

[+Kirill]

Quoted 7 lines · Wanpeng Li

Dl task who is not on queue and it is also the curr task simultaneously can not happen. In addition, pull since the priority of a not on queue dl task doesn't make any sense.

This patch fix it by don't pull if dl task who's prio changed is not on queue.

So, this is something that was already raised by Kirill, but I always forgot to fix :/. Thanks for reminding me!

I have this fix:

Quoted 1 line

From 8fcb04eee2d76042970e9561d253d1bc1fe4cc2b Mon Sep 17 00:00:00 2001

From: Juri Lelli <[email protected]>
Date: Tue, 3 Mar 2015 07:51:56 +0000
Subject: [PATCH] sched/deadline: cleanup prio_changed_dl()

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.

---
 kernel/sched/deadline.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
kernel/sched/deadline.c +13 -3
index cfa45c1..9d83748 100644
@@ -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 = {
Signature · 1 line
2.3.0
Quoted 22 lines
---
 kernel/sched/deadline.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/sched/deadline.c +4 -1
index 49f92c8..ca391c0 100644
@@ -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
author
#2 lore raw

Hi Juri,

Quoted 9 lines · Juri Lelli

Hi,

[+Kirill]

Quoted 4 lines · Wanpeng Li

Dl task who is not on queue and it is also the curr task simultaneously can not happen. In addition, pull since the priority of a not on queue dl task doesn't make any sense.

Quoted 8 lines
Quoted 3 lines

This patch fix it by don't pull if dl task who's prio changed is not on queue.

So, this is something that was already raised by Kirill, but I always forgot to fix :/. Thanks for reminding me!

I have this fix:

Cool, your patch looks good to me.

Regards,
Wanpeng Li

Quoted 85 lines
Quoted 2 lines

From 8fcb04eee2d76042970e9561d253d1bc1fe4cc2b Mon Sep 17 00:00:00 2001

From: Juri Lelli <[email protected]>
Date: Tue, 3 Mar 2015 07:51:56 +0000
Subject: [PATCH] sched/deadline: cleanup prio_changed_dl()

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.

---
kernel/sched/deadline.c | 16 +++++++++++++---

1 file changed, 13 insertions(+), 3 deletions(-)
kernel/sched/deadline.c +13 -3
index cfa45c1..9d83748 100644
@@ -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 = {
Signature · 1 line
2.3.0
Quoted 22 lines
---
 kernel/sched/deadline.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/sched/deadline.c +4 -1
index 49f92c8..ca391c0 100644
@@ -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
author
#3 lore raw
In reply to Juri Lelli
Quoted 9 lines · Juri Lelli

Hi,

[+Kirill]

Quoted 4 lines · Wanpeng Li

Dl task who is not on queue and it is also the curr task simultaneously can not happen. In addition, pull since the priority of a not on queue dl task doesn't make any sense.

Quoted 8 lines
Quoted 3 lines

This patch fix it by don't pull if dl task who's prio changed is not on queue.

So, this is something that was already raised by Kirill, but I always forgot to fix :/. Thanks for reminding me!

I have this fix:

Cool, your patch looks good to me.

Regards,
Wanpeng Li

Quoted 85 lines
Quoted 2 lines

From 8fcb04eee2d76042970e9561d253d1bc1fe4cc2b Mon Sep 17 00:00:00 2001

From: Juri Lelli <[email protected]>
Date: Tue, 3 Mar 2015 07:51:56 +0000
Subject: [PATCH] sched/deadline: cleanup prio_changed_dl()

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.

---
kernel/sched/deadline.c | 16 +++++++++++++---

1 file changed, 13 insertions(+), 3 deletions(-)
kernel/sched/deadline.c +13 -3
index cfa45c1..9d83748 100644
@@ -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 = {
Signature · 1 line
2.3.0
Quoted 22 lines
---
 kernel/sched/deadline.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/sched/deadline.c +4 -1
index 49f92c8..ca391c0 100644
@@ -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