2014-10-22 00:37:09

by Wanpeng Li

[permalink] [raw]
Subject: [PATCH v3] 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").

Signed-off-by: Wanpeng Li <[email protected]>
---
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(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index abfaf3d..bd5e479 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -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 */
--
1.9.1


2014-10-22 09:33:10

by Juri Lelli

[permalink] [raw]
Subject: Re: [PATCH v3] sched/deadline: do not try to push tasks if pinned task switches to dl

On 22/10/14 01:36, Wanpeng Li wrote:
> 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").
>
> Signed-off-by: Wanpeng Li <[email protected]>
> ---
> 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(-)
>
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index abfaf3d..bd5e479 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -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

Subject: [tip:sched/core] 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").

Suggested-by: Kirill V Tkhai <[email protected]>
Acked-by: Juri Lelli <[email protected]>
Signed-off-by: Wanpeng Li <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Linus Torvalds <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
kernel/sched/deadline.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 5285332..9d1e76a 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -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 */

2016-03-29 22:47:26

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH v3] sched/deadline: do not try to push tasks if pinned task switches to dl

On Wed, 22 Oct 2014 10:33:05 +0100
Juri Lelli <[email protected]> wrote:

> On 22/10/14 01:36, Wanpeng Li wrote:
> > 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").
> >
> > Signed-off-by: Wanpeng Li <[email protected]>
> > ---
> > 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(-)
> >
> > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> > index abfaf3d..bd5e479 100644
> > --- a/kernel/sched/deadline.c
> > +++ b/kernel/sched/deadline.c
> > @@ -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 */
> >
>

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

2016-03-30 06:45:03

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH v3] sched/deadline: do not try to push tasks if pinned task switches to dl

On Tue, Mar 29, 2016 at 06:47:22PM -0400, Steven Rostedt wrote:
> 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.

2016-03-30 07:59:22

by Wanpeng Li

[permalink] [raw]
Subject: Re: [PATCH v3] sched/deadline: do not try to push tasks if pinned task switches to dl

2016-03-30 14:44 GMT+08:00 Peter Zijlstra <[email protected]>:
> On Tue, Mar 29, 2016 at 06:47:22PM -0400, Steven Rostedt wrote:
>> 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.

>> 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