[PATCH 7/7 v2] sched/fair: Update overutilized detection

Vincent Guittot posted 7 patches 1 year ago
There is a newer version of this series
[PATCH 7/7 v2] sched/fair: Update overutilized detection
Posted by Vincent Guittot 1 year ago
Checking uclamp_min is useless and counterproductive for overutilized state
as misfit can now happen without being in overutilized state

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

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9bddb094ee21..9eb4c4946ddc 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6870,16 +6870,15 @@ static inline void hrtick_update(struct rq *rq)
 #ifdef CONFIG_SMP
 static inline bool cpu_overutilized(int cpu)
 {
-	unsigned long  rq_util_min, rq_util_max;
+	unsigned long rq_util_max;
 
 	if (!sched_energy_enabled())
 		return false;
 
-	rq_util_min = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MIN);
 	rq_util_max = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MAX);
 
 	/* Return true only if the utilization doesn't fit CPU's capacity */
-	return !util_fits_cpu(cpu_util_cfs(cpu), rq_util_min, rq_util_max, cpu);
+	return !util_fits_cpu(cpu_util_cfs(cpu), 0, rq_util_max, cpu);
 }
 
 /*
-- 
2.43.0
Re: [PATCH 7/7 v2] sched/fair: Update overutilized detection
Posted by Pierre Gondois 11 months ago
Hello Vincent,

On 12/17/24 17:07, Vincent Guittot wrote:
> Checking uclamp_min is useless and counterproductive for overutilized state
> as misfit can now happen without being in overutilized state

Before this patch a task was misfit if:
   !task_fits_cpu(p, cpu)
This is, if either:
- task_util > 80% * CPU_capacity
- task_UCLAMP_MIN > get_actual_cpu_capacity(cpu)

A CPU was OU if:
   !util_fits_cpu(cpu_util_cfs(cpu), rq_util_min, rq_util_max, cpu)
This is:
- CPU_util > 80% * CPU_capacity

This should be the same after this patch. Just to be sure I understand correctly,
this patch has no functional change and is independent from this serie right ?

> 
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
>   kernel/sched/fair.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 9bddb094ee21..9eb4c4946ddc 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -6870,16 +6870,15 @@ static inline void hrtick_update(struct rq *rq)
>   #ifdef CONFIG_SMP
>   static inline bool cpu_overutilized(int cpu)
>   {
> -	unsigned long  rq_util_min, rq_util_max;
> +	unsigned long rq_util_max;
>   
>   	if (!sched_energy_enabled())
>   		return false;
>   
> -	rq_util_min = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MIN);
>   	rq_util_max = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MAX);
>   
>   	/* Return true only if the utilization doesn't fit CPU's capacity */
> -	return !util_fits_cpu(cpu_util_cfs(cpu), rq_util_min, rq_util_max, cpu);
> +	return !util_fits_cpu(cpu_util_cfs(cpu), 0, rq_util_max, cpu);
>   }
>   
>   /*
Re: [PATCH 7/7 v2] sched/fair: Update overutilized detection
Posted by Vincent Guittot 11 months ago
On Fri, 17 Jan 2025 at 11:27, Pierre Gondois <pierre.gondois@arm.com> wrote:
>
> Hello Vincent,
>
> On 12/17/24 17:07, Vincent Guittot wrote:
> > Checking uclamp_min is useless and counterproductive for overutilized state
> > as misfit can now happen without being in overutilized state
>
> Before this patch a task was misfit if:
>    !task_fits_cpu(p, cpu)
> This is, if either:
> - task_util > 80% * CPU_capacity
> - task_UCLAMP_MIN > get_actual_cpu_capacity(cpu)
>
> A CPU was OU if:
>    !util_fits_cpu(cpu_util_cfs(cpu), rq_util_min, rq_util_max, cpu)
> This is:
> - CPU_util > 80% * CPU_capacity
>
> This should be the same after this patch. Just to be sure I understand correctly,
> this patch has no functional change and is independent from this serie right ?

yeah, I find it while running some functional tests on the patchset



>
> >
> > Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> > ---
> >   kernel/sched/fair.c | 5 ++---
> >   1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 9bddb094ee21..9eb4c4946ddc 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -6870,16 +6870,15 @@ static inline void hrtick_update(struct rq *rq)
> >   #ifdef CONFIG_SMP
> >   static inline bool cpu_overutilized(int cpu)
> >   {
> > -     unsigned long  rq_util_min, rq_util_max;
> > +     unsigned long rq_util_max;
> >
> >       if (!sched_energy_enabled())
> >               return false;
> >
> > -     rq_util_min = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MIN);
> >       rq_util_max = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MAX);
> >
> >       /* Return true only if the utilization doesn't fit CPU's capacity */
> > -     return !util_fits_cpu(cpu_util_cfs(cpu), rq_util_min, rq_util_max, cpu);
> > +     return !util_fits_cpu(cpu_util_cfs(cpu), 0, rq_util_max, cpu);
> >   }
> >
> >   /*