From: K Prateek Nayak <kprateek.nayak@amd.com>
To: Pierre Gondois <pierre.gondois@arm.com>, <linux-kernel@vger.kernel.org>
Cc: Christian Loehle <christian.loehle@arm.com>,
<stable@vger.kernel.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
Rik van Riel <riel@surriel.com>
Subject: Re: [PATCH 1/2] sched/fair: Fix integer underflow
Date: Mon, 9 Feb 2026 09:43:39 +0530 [thread overview]
Message-ID: <64ebef1d-5f22-44ed-a1f3-2f7cb432e10b@amd.com> (raw)
In-Reply-To: <20260205150846.1242134-2-pierre.gondois@arm.com>
Hello Pierre,
On 2/5/2026 8:38 PM, 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")
Should this be commit 0b0695f2b34a ("sched/fair: Rework load_balance()")
since I could spot the max_t usage all the way back to to it?
Apart from that, feel free to include:
Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com>
> 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 da46c31645378..aa14a9982b9f1 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -11249,8 +11249,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
--
Thanks and Regards,
Prateek
next prev parent reply other threads:[~2026-02-09 4:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-05 15:08 [PATCH 0/2] sched/fair: Load balance improvements Pierre Gondois
2026-02-05 15:08 ` [PATCH 1/2] sched/fair: Fix integer underflow Pierre Gondois
2026-02-09 4:13 ` K Prateek Nayak [this message]
2026-02-05 15:08 ` [PATCH 2/2] sched/fair: Balance #Tasks/#CPUs if busiest group has no idle CPU Pierre Gondois
2026-02-06 9:41 ` K Prateek Nayak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=64ebef1d-5f22-44ed-a1f3-2f7cb432e10b@amd.com \
--to=kprateek.nayak@amd.com \
--cc=bsegall@google.com \
--cc=christian.loehle@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=pierre.gondois@arm.com \
--cc=riel@surriel.com \
--cc=rostedt@goodmis.org \
--cc=stable@vger.kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®