Skip to contentSkip to conversation

sched/deadline: do not try to push tasks if pinned task switches to dl

PATCH In review Wanpeng Li 6 participants 6 messages Oct 22, 2014 – Mar 30, 2016 Scheduler

lore
Share & tools
lore

Wanpeng Li

author
#0 lore raw

PATCH v3 1/1 sched/deadline: do not try to push tasks if pinned task switches to dl

As Kirill mentioned(https://lkml.org/lkml/2013/1/29/118):
| If rq has already had 2 or more pushable tasks and we try to add a | pinned task then call of push_rt_task will just waste a time.

Just switched pinned task is not able to be pushed. If the rq has had several dl tasks before they have already been considered as candidates to be pushed (or pulled). This patch implements the same behavior as rt class which introduced by commit 10447917551e ("sched/rt: Do not try to push tasks if pinned task switches to RT").

---
v2 -> v3:
* cleanup patch description
* align && to p->nr_cpus_allowed
v1 -> v2:
* use 12 or more chars for the git commit ID

 kernel/sched/deadline.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/deadline.c +2 -1
index abfaf3d..bd5e479 100644
@@ -1603,7 +1603,8 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
 
 	if (task_on_rq_queued(p) && rq->curr != p) {
 #ifdef CONFIG_SMP
-		if (rq->dl.overloaded && push_dl_task(rq) && rq != task_rq(p))
+		if (p->nr_cpus_allowed > 1 && rq->dl.overloaded &&
+			push_dl_task(rq) && rq != task_rq(p))
 			/* Only reschedule if pushing failed */
 			check_resched = 0;
 #endif /* CONFIG_SMP */
Signature · 1 line
1.9.1
#1 lore raw
Quoted 27 lines · Wanpeng Li

As Kirill mentioned(https://lkml.org/lkml/2013/1/29/118):
| If rq has already had 2 or more pushable tasks and we try to add a | pinned task then call of push_rt_task will just waste a time.

Just switched pinned task is not able to be pushed. If the rq has had several dl tasks before they have already been considered as candidates to be pushed (or pulled). This patch implements the same behavior as rt class which introduced by commit 10447917551e ("sched/rt: Do not try to push tasks if pinned task switches to RT").

---
v2 -> v3:
* cleanup patch description
* align && to p->nr_cpus_allowed
v1 -> v2:
* use 12 or more chars for the git commit ID

 kernel/sched/deadline.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/deadline.c +0 -0
index abfaf3d..bd5e479 100644

kernel/sched/deadline.c static void switched_to_dl(struct rq *rq, struct task_struct *p) · line 1610

Quoted 9 lines
kernel/sched/deadline.c +2 -1
@@ -1603,7 +1603,8 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
 
 	if (task_on_rq_queued(p) && rq->curr != p) {
 #ifdef CONFIG_SMP
-		if (rq->dl.overloaded && push_dl_task(rq) && rq != task_rq(p))
+		if (p->nr_cpus_allowed > 1 && rq->dl.overloaded &&
+			push_dl_task(rq) && rq != task_rq(p))
 			/* Only reschedule if pushing failed */
 			check_resched = 0;
 #endif /* CONFIG_SMP */

Looks good. Thanks!

Best,

- Juri

#2 lore raw
Quoted 28 lines · On Wed, 22 Oct 2014 10:33:05 +0100 Juri Lelli <[email protected]> wrote:
Quoted 27 lines · Wanpeng Li

As Kirill mentioned(https://lkml.org/lkml/2013/1/29/118):
| If rq has already had 2 or more pushable tasks and we try to add a | pinned task then call of push_rt_task will just waste a time.

Just switched pinned task is not able to be pushed. If the rq has had several dl tasks before they have already been considered as candidates to be pushed (or pulled). This patch implements the same behavior as rt class which introduced by commit 10447917551e ("sched/rt: Do not try to push tasks if pinned task switches to RT").

---
v2 -> v3:
* cleanup patch description
* align && to p->nr_cpus_allowed
v1 -> v2:
* use 12 or more chars for the git commit ID

 kernel/sched/deadline.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/deadline.c +0 -0
index abfaf3d..bd5e479 100644
@@ -1603,7 +1603,8 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
 
Quoted 10 lines

kernel/sched/deadline.c static void switched_to_dl(struct rq *rq, struct task_struct *p) · line 1610

Quoted 9 lines
kernel/sched/deadline.c +2 -1
 	if (task_on_rq_queued(p) && rq->curr != p) {
 #ifdef CONFIG_SMP
-		if (rq->dl.overloaded && push_dl_task(rq) && rq != task_rq(p))
+		if (p->nr_cpus_allowed > 1 && rq->dl.overloaded &&
+			push_dl_task(rq) && rq != task_rq(p))
 			/* Only reschedule if pushing failed */
 			check_resched = 0;
 #endif /* CONFIG_SMP */

I'm looking at some old changes for sched-deadline, and I stumbled across this. As I'm working on sched deadline tests, I've discovered that they can't have cpu affinity. They are limited to their sched domains. That is, sched deadline tasks have whatever affinity that the domain they happen to be in has.

Is there a condition where rq != task_rq(p) and p->nr_cpus_allowed > 1 isn't true?

Now maybe this will help with -rt when a task hits a migrate disable?

Just asking.

-- Steve

maintainer
#3 lore raw
Quoted 8 lines · Steven Rostedt

I'm looking at some old changes for sched-deadline, and I stumbled across this. As I'm working on sched deadline tests, I've discovered that they can't have cpu affinity. They are limited to their sched domains. That is, sched deadline tasks have whatever affinity that the domain they happen to be in has.

Is there a condition where rq != task_rq(p) and p->nr_cpus_allowed > 1 isn't true?

When holding rq->lock, no. I suppose the patch was just to mirror rt and someone 'forgot' about the extra constraints on dl tasks.

#4 lore raw

2016-03-30 14:44 GMT+08:00 Peter Zijlstra <[email protected]>:

Quoted 5 lines · Steven Rostedt
Quoted 4 lines

I'm looking at some old changes for sched-deadline, and I stumbled across this. As I'm working on sched deadline tests, I've discovered that they can't have cpu affinity. They are limited to their sched domains. That is, sched deadline tasks have whatever affinity that the

root domain I think.

Quoted 8 lines
Quoted 4 lines

domain they happen to be in has.

Is there a condition where rq != task_rq(p) and p->nr_cpus_allowed > 1 isn't true?

When holding rq->lock, no. I suppose the patch was just to mirror rt and someone 'forgot' about the extra constraints on dl tasks.

sched_class::switched_from() methods can drop rq->lock before your great balance_callback patchset. :-)

Regards,
Wanpeng Li

#5 lore raw

[tip:sched/core] sched/deadline: Do not try to push tasks if pinned task switches to dl

In reply to Wanpeng Li
sched/deadline: Do not try to push tasks if pinned task switches to dl
Commit-ID:  d9aade7ae1d283097a3f626790e7c325a5c69007
Gitweb:     http://git.kernel.org/tip/d9aade7ae1d283097a3f626790e7c325a5c69007
Author:     Wanpeng Li <[email protected]>
AuthorDate: Wed, 22 Oct 2014 08:36:43 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 28 Oct 2014 10:47:57 +0100

sched/deadline: Do not try to push tasks if pinned task switches to dl

As Kirill mentioned (https://lkml.org/lkml/2013/1/29/118):

| If rq has already had 2 or more pushable tasks and we try to add a | pinned task then call of push_rt_task will just waste a time.

Just switched pinned task is not able to be pushed. If the rq has had several dl tasks before they have already been considered as candidates to be pushed (or pulled). This patch implements the same behavior as rt class which introduced by commit 10447917551e ("sched/rt: Do not try to push tasks if pinned task switches to RT").

---
 kernel/sched/deadline.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/deadline.c +2 -1
index 5285332..9d1e76a 100644
@@ -1622,7 +1622,8 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
 
 	if (task_on_rq_queued(p) && rq->curr != p) {
 #ifdef CONFIG_SMP
-		if (rq->dl.overloaded && push_dl_task(rq) && rq != task_rq(p))
+		if (p->nr_cpus_allowed > 1 && rq->dl.overloaded &&
+			push_dl_task(rq) && rq != task_rq(p))
 			/* Only reschedule if pushing failed */
 			check_resched = 0;
 #endif /* CONFIG_SMP */