[PATCH 7/9] sched/fair: Do not try to migrate delayed dequeue task

Vincent Guittot posted 9 patches 1 year, 2 months ago
There is a newer version of this series
[PATCH 7/9] sched/fair: Do not try to migrate delayed dequeue task
Posted by Vincent Guittot 1 year, 2 months ago
Migrating a delayed dequeued task doesn't help in balancing the number
of runnable tasks in the system.

Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
---
 kernel/sched/fair.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 1b4f1b610543..9d80f3a61082 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -9405,11 +9405,15 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
 
 	/*
 	 * We do not migrate tasks that are:
-	 * 1) throttled_lb_pair, or
-	 * 2) cannot be migrated to this CPU due to cpus_ptr, or
-	 * 3) running (obviously), or
-	 * 4) are cache-hot on their current CPU.
+	 * 1) delayed dequeued, or
+	 * 2) throttled_lb_pair, or
+	 * 3) cannot be migrated to this CPU due to cpus_ptr, or
+	 * 4) running (obviously), or
+	 * 5) are cache-hot on their current CPU.
 	 */
+	if (p->se.sched_delayed)
+		return 0;
+
 	if (throttled_lb_pair(task_group(p), env->src_cpu, env->dst_cpu))
 		return 0;
 
-- 
2.43.0
Re: [PATCH 7/9] sched/fair: Do not try to migrate delayed dequeue task
Posted by Peter Zijlstra 1 year, 2 months ago
On Thu, Nov 28, 2024 at 10:27:48AM +0100, Vincent Guittot wrote:
> Migrating a delayed dequeued task doesn't help in balancing the number
> of runnable tasks in the system.

But it can help balance the weight; furthermore, by moving them to a
lighter queue, they'll get picked sooner and disappear sooner.

Perhaps make it: p->se.sched_delayed && !env->sd->nr_balance_failed ?

> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
>  kernel/sched/fair.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 1b4f1b610543..9d80f3a61082 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -9405,11 +9405,15 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
>  
>  	/*
>  	 * We do not migrate tasks that are:
> -	 * 1) throttled_lb_pair, or
> -	 * 2) cannot be migrated to this CPU due to cpus_ptr, or
> -	 * 3) running (obviously), or
> -	 * 4) are cache-hot on their current CPU.
> +	 * 1) delayed dequeued, or
> +	 * 2) throttled_lb_pair, or
> +	 * 3) cannot be migrated to this CPU due to cpus_ptr, or
> +	 * 4) running (obviously), or
> +	 * 5) are cache-hot on their current CPU.
>  	 */
> +	if (p->se.sched_delayed)
> +		return 0;
> +
>  	if (throttled_lb_pair(task_group(p), env->src_cpu, env->dst_cpu))
>  		return 0;
>  
> -- 
> 2.43.0
>
Re: [PATCH 7/9] sched/fair: Do not try to migrate delayed dequeue task
Posted by Vincent Guittot 1 year, 2 months ago
On Thu, 28 Nov 2024 at 10:49, Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Thu, Nov 28, 2024 at 10:27:48AM +0100, Vincent Guittot wrote:
> > Migrating a delayed dequeued task doesn't help in balancing the number
> > of runnable tasks in the system.
>
> But it can help balance the weight; furthermore, by moving them to a
> lighter queue, they'll get picked sooner and disappear sooner.

When groups are not overloaded, we don't compare load but only running
tasks t balance them across cpus

It's only when both src and dst groups are overloaded that we look at
the load and the weight

>
> Perhaps make it: p->se.sched_delayed && !env->sd->nr_balance_failed ?

So we could take into account which type of migration with
env->migration_type == migrate_load

In this case, migrating a delayed dequeue task would help

>
> > Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> > ---
> >  kernel/sched/fair.c | 12 ++++++++----
> >  1 file changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 1b4f1b610543..9d80f3a61082 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -9405,11 +9405,15 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
> >
> >       /*
> >        * We do not migrate tasks that are:
> > -      * 1) throttled_lb_pair, or
> > -      * 2) cannot be migrated to this CPU due to cpus_ptr, or
> > -      * 3) running (obviously), or
> > -      * 4) are cache-hot on their current CPU.
> > +      * 1) delayed dequeued, or
> > +      * 2) throttled_lb_pair, or
> > +      * 3) cannot be migrated to this CPU due to cpus_ptr, or
> > +      * 4) running (obviously), or
> > +      * 5) are cache-hot on their current CPU.
> >        */
> > +     if (p->se.sched_delayed)
> > +             return 0;
> > +
> >       if (throttled_lb_pair(task_group(p), env->src_cpu, env->dst_cpu))
> >               return 0;
> >
> > --
> > 2.43.0
> >
Re: [PATCH 7/9] sched/fair: Do not try to migrate delayed dequeue task
Posted by Peter Zijlstra 1 year, 2 months ago
On Thu, Nov 28, 2024 at 11:03:44AM +0100, Vincent Guittot wrote:
> On Thu, 28 Nov 2024 at 10:49, Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > On Thu, Nov 28, 2024 at 10:27:48AM +0100, Vincent Guittot wrote:
> > > Migrating a delayed dequeued task doesn't help in balancing the number
> > > of runnable tasks in the system.
> >
> > But it can help balance the weight; furthermore, by moving them to a
> > lighter queue, they'll get picked sooner and disappear sooner.
> 
> When groups are not overloaded, we don't compare load but only running
> tasks t balance them across cpus
> 
> It's only when both src and dst groups are overloaded that we look at
> the load and the weight
> 
> >
> > Perhaps make it: p->se.sched_delayed && !env->sd->nr_balance_failed ?
> 
> So we could take into account which type of migration with
> env->migration_type == migrate_load

Yeah that makes sense.