From nobody Sun Feb 8 07:14:59 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F057EEB64D7 for ; Wed, 21 Jun 2023 06:54:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230221AbjFUGyO (ORCPT ); Wed, 21 Jun 2023 02:54:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229776AbjFUGyM (ORCPT ); Wed, 21 Jun 2023 02:54:12 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 400AB10D5 for ; Tue, 20 Jun 2023 23:54:10 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QmDjd4tYHzTkkX; Wed, 21 Jun 2023 14:53:25 +0800 (CST) Received: from huawei.com (10.175.104.170) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 21 Jun 2023 14:54:06 +0800 From: Miaohe Lin To: , , , CC: , , , , , , , Subject: [PATCH] sched/fair: fix possible active balance misbehavior Date: Wed, 21 Jun 2023 14:53:31 +0800 Message-ID: <20230621065331.3793767-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.104.170] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In LBF_DST_PINNED case, env.dst_cpu won't be equal to this_cpu. So when need_active_balance() returns true, env.dst_cpu should be used to do the active balance stuff instead of this_cpu. Fixes: 88b8dac0a14c ("sched: Improve balance_cpu() to consider other cpus i= n its group as target of (pinned) task") Signed-off-by: Miaohe Lin --- kernel/sched/fair.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 5e90e9658528..28ff831ee847 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10968,14 +10968,14 @@ static int load_balance(int this_cpu, struct rq *= this_rq, /* * Don't kick the active_load_balance_cpu_stop, * if the curr task on busiest CPU can't be - * moved to this_cpu: + * moved to env.dst_cpu: */ - if (!cpumask_test_cpu(this_cpu, busiest->curr->cpus_ptr)) { + if (!cpumask_test_cpu(env.dst_cpu, busiest->curr->cpus_ptr)) { raw_spin_rq_unlock_irqrestore(busiest, flags); goto out_one_pinned; } =20 - /* Record that we found at least one task that could run on this_cpu */ + /* Record that we found at least one task that could run on env.dst_cpu= */ env.flags &=3D ~LBF_ALL_PINNED; =20 /* @@ -10985,7 +10985,7 @@ static int load_balance(int this_cpu, struct rq *th= is_rq, */ if (!busiest->active_balance) { busiest->active_balance =3D 1; - busiest->push_cpu =3D this_cpu; + busiest->push_cpu =3D env.dst_cpu; active_balance =3D 1; } raw_spin_rq_unlock_irqrestore(busiest, flags); --=20 2.27.0