* [PATCH v2] sched/fair: Fix integer underflow
@ 2024-10-01 13:46 Pierre Gondois
2025-03-25 15:10 ` Pierre Gondois
0 siblings, 1 reply; 3+ messages in thread
From: Pierre Gondois @ 2024-10-01 13:46 UTC (permalink / raw)
To: linux-kernel
Cc: Pierre Gondois, stable, Vincent Guittot, Ingo Molnar,
Peter Zijlstra, Juri Lelli, Dietmar Eggemann, Steven Rostedt,
Ben Segall, Mel Gorman, Valentin Schneider, Rik van Riel
(struct sg_lb_stats).idle_cpus is of type 'unsigned int'.
(local->idle_cpus - busiest->idle_cpus) can underflow to UINT_MAX
for instance, and max_t(long, 0, UINT_MAX) will output UINT_MAX.
Use lsub_positive() instead of max_t().
Fixes: 16b0a7a1a0af ("sched/fair: Ensure tasks spreading in LLC during LB")
cc: stable@vger.kernel.org
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
---
kernel/sched/fair.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9057584ec06d..6d9124499f52 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -10775,8 +10775,8 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
* idle CPUs.
*/
env->migration_type = migrate_task;
- env->imbalance = max_t(long, 0,
- (local->idle_cpus - busiest->idle_cpus));
+ env->imbalance = local->idle_cpus;
+ lsub_positive(&env->imbalance, busiest->idle_cpus);
}
#ifdef CONFIG_NUMA
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] sched/fair: Fix integer underflow
2024-10-01 13:46 [PATCH v2] sched/fair: Fix integer underflow Pierre Gondois
@ 2025-03-25 15:10 ` Pierre Gondois
2025-03-26 16:43 ` Vincent Guittot
0 siblings, 1 reply; 3+ messages in thread
From: Pierre Gondois @ 2025-03-25 15:10 UTC (permalink / raw)
To: linux-kernel
Cc: stable, Vincent Guittot, Ingo Molnar, Peter Zijlstra, Juri Lelli,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider, Rik van Riel
Hello Vincent,
This patch should still be relevant, would it be possible to pick it ?
Or maybe something is missing ?
Regards,
Pierre
On 10/1/24 15:46, Pierre Gondois wrote:
> (struct sg_lb_stats).idle_cpus is of type 'unsigned int'.
> (local->idle_cpus - busiest->idle_cpus) can underflow to UINT_MAX
> for instance, and max_t(long, 0, UINT_MAX) will output UINT_MAX.
>
> Use lsub_positive() instead of max_t().
>
> Fixes: 16b0a7a1a0af ("sched/fair: Ensure tasks spreading in LLC during LB")
> cc: stable@vger.kernel.org
> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
> Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
> kernel/sched/fair.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 9057584ec06d..6d9124499f52 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -10775,8 +10775,8 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
> * idle CPUs.
> */
> env->migration_type = migrate_task;
> - env->imbalance = max_t(long, 0,
> - (local->idle_cpus - busiest->idle_cpus));
> + env->imbalance = local->idle_cpus;
> + lsub_positive(&env->imbalance, busiest->idle_cpus);
> }
>
> #ifdef CONFIG_NUMA
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] sched/fair: Fix integer underflow
2025-03-25 15:10 ` Pierre Gondois
@ 2025-03-26 16:43 ` Vincent Guittot
0 siblings, 0 replies; 3+ messages in thread
From: Vincent Guittot @ 2025-03-26 16:43 UTC (permalink / raw)
To: Pierre Gondois
Cc: linux-kernel, stable, Ingo Molnar, Peter Zijlstra, Juri Lelli,
Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider, Rik van Riel
Hi Pierre,
On Tue, 25 Mar 2025 at 16:10, Pierre Gondois <pierre.gondois@arm.com> wrote:
>
> Hello Vincent,
>
> This patch should still be relevant, would it be possible to pick it ?
> Or maybe something is missing ?
Nothing is missing, the patch just got lost somewhere.
Ingo, Peter,
Could we take it once rc1 is published ?
Regards,
Vincent
>
> Regards,
> Pierre
>
> On 10/1/24 15:46, Pierre Gondois wrote:
> > (struct sg_lb_stats).idle_cpus is of type 'unsigned int'.
> > (local->idle_cpus - busiest->idle_cpus) can underflow to UINT_MAX
> > for instance, and max_t(long, 0, UINT_MAX) will output UINT_MAX.
> >
> > Use lsub_positive() instead of max_t().
> >
> > Fixes: 16b0a7a1a0af ("sched/fair: Ensure tasks spreading in LLC during LB")
> > cc: stable@vger.kernel.org
> > Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
> > Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
> > ---
> > kernel/sched/fair.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 9057584ec06d..6d9124499f52 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -10775,8 +10775,8 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
> > * idle CPUs.
> > */
> > env->migration_type = migrate_task;
> > - env->imbalance = max_t(long, 0,
> > - (local->idle_cpus - busiest->idle_cpus));
> > + env->imbalance = local->idle_cpus;
> > + lsub_positive(&env->imbalance, busiest->idle_cpus);
> > }
> >
> > #ifdef CONFIG_NUMA
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-26 16:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-01 13:46 [PATCH v2] sched/fair: Fix integer underflow Pierre Gondois
2025-03-25 15:10 ` Pierre Gondois
2025-03-26 16:43 ` Vincent Guittot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®