From: Vincent Guittot Date: Tue, 11 Apr 2023 09:06:11 +0000 (+0200) Subject: sched/fair: Fix imbalance overflow X-Git-Tag: v6.1.37~2158 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=31c5ad43bdd14fd90221f4a93d764a923b0fae5e;p=platform%2Fkernel%2Flinux-starfive.git sched/fair: Fix imbalance overflow [ Upstream commit 91dcf1e8068e9a8823e419a7a34ff4341275fb70 ] When local group is fully busy but its average load is above system load, computing the imbalance will overflow and local group is not the best target for pulling this load. Fixes: 0b0695f2b34a ("sched/fair: Rework load_balance()") Reported-by: Tingjia Cao Signed-off-by: Vincent Guittot Signed-off-by: Peter Zijlstra (Intel) Tested-by: Tingjia Cao Link: https://lore.kernel.org/lkml/CABcWv9_DAhVBOq2=W=2ypKE9dKM5s2DvoV8-U0+GDwwuKZ89jQ@mail.gmail.com/T/ Signed-off-by: Sasha Levin --- diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 88821ab..ec2d913 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10041,6 +10041,16 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s sds->avg_load = (sds->total_load * SCHED_CAPACITY_SCALE) / sds->total_capacity; + + /* + * If the local group is more loaded than the average system + * load, don't try to pull any tasks. + */ + if (local->avg_load >= sds->avg_load) { + env->imbalance = 0; + return; + } + } /*