Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp8981285rwd; Wed, 21 Jun 2023 01:09:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7usMHtdBDzRg445ARBO1/xX2JaoUfG4UU3CzLSH5lB+qc2wjNlsrBzeCBJLi5GA5MRYHfV X-Received: by 2002:a17:902:ed13:b0:1af:fd3a:2b7d with SMTP id b19-20020a170902ed1300b001affd3a2b7dmr12631913pld.48.1687334966835; Wed, 21 Jun 2023 01:09:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687334966; cv=none; d=google.com; s=arc-20160816; b=Z+vkBgVIIEBIlPERLphk2I2L0eIxnhT5IcIAWKu8vBuN0lVjBaXex5nZVxNaPfun+q w664rWyennrZDIUhPTc+l7nx6r93OalfkvmfJzjOlft3YLTJHU+L9zCldYM4iRWBTsMq EZFNevh9HgMkaXtJGcRlMm1Ndtnw/7zPkx3h04UCULSJ3M36+f30qD6qFWYuV6GZr6zo We+tZ8rtU9jrXGTk1mU9yjDQi7Y8FdoHHaUfrCJp/qxAsDONmWkbZ94I48o7E/SylexR En4DdgwXNYopC5l5pXQWkjMQxdmyPh2UQ7f4xXclgPKYQ7wlXB/9q/Tc0P2wmha/GpnC VIOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=UVnXacVnExDWpWzt7CAwapdteq0yXkKnN27ICuuOFdU=; b=NgEHR4gwRj9Fw7lvjkKw1+0R7Utmy3LMjmQX8Yqm0Uvp0++tqjzYnyfxj++FjYdqsg Gptxc7Als5R2WGJu/62MMoGsiZKCiRKMCN3FjlqgyfhHVIRjboz+nfYsudVoaRfV/sJd x+5WzJE4FlSQURQk8uPjIBwaqJ8FS6h4r/XKxTgcNWxfyqUtfXoOBQcrnwXVtUzEaPEi neob0rVfmbPcOFl071mz3rxSgaatDSLBarCzGI+msZy9d13WcvBjYcUCHGRokqEXO0M5 i1pnH9HXb2HK8wk8coWGTt/FLI8rPpj1KAo+N9ZIBmvW3SYQiBNMX6BNP6YPlxRazU7w 32Cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u13-20020a170902a60d00b001a9265e6fdasi3499254plq.268.2023.06.21.01.09.14; Wed, 21 Jun 2023 01:09:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230230AbjFUGyN (ORCPT + 99 others); Wed, 21 Jun 2023 02:54:13 -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: 7BIT Content-Type: text/plain; charset=US-ASCII 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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 in 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; } - /* 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 &= ~LBF_ALL_PINNED; /* @@ -10985,7 +10985,7 @@ static int load_balance(int this_cpu, struct rq *this_rq, */ if (!busiest->active_balance) { busiest->active_balance = 1; - busiest->push_cpu = this_cpu; + busiest->push_cpu = env.dst_cpu; active_balance = 1; } raw_spin_rq_unlock_irqrestore(busiest, flags); -- 2.27.0