From patchwork Wed Jun 21 06:53:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 110819 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4170238vqr; Wed, 21 Jun 2023 00:02:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Rk2ZdRht13FTyUzxteDNtetaxTC+IsCfzavEOS1n7UGyD5d6iuh6h5xsno7HCVDWCdzmD X-Received: by 2002:a17:90a:188:b0:258:c4b5:c6b4 with SMTP id 8-20020a17090a018800b00258c4b5c6b4mr10720423pjc.12.1687330966127; Wed, 21 Jun 2023 00:02:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687330966; cv=none; d=google.com; s=arc-20160816; b=D3eYVEXCgipNPT7pRyXbpFLozqWOqevmJswz7asCMtOaaL/07+FPbPV0oacHiKG/eb uddRzHc/LU33dIxXx6FbqnO49qY6cBPtru9rXDUbdriHMtIo4pDmYjVhZWPcAvUTULvl yXzYb3y1XuH9fCofmlyhi9xNvkiOY9pY+nJNYg/DflBR9ZCaS/zGnnTYIqL56cR+9Fbh sMzEIgZTc0oh+i1tbSZaIPbZXO1xP2vzCBBdf2KDf6gxKB/9fkjAAIHZTNEY4lJP4V5a QXj7OBv7bJZw90EmbC9JyL2i8z3me68iK8O8k3URO7eXwevux128iGn7e/7sH0jmYQ8g BKvA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p27-20020a637f5b000000b00553d074198fsi3271075pgn.137.2023.06.21.00.02.33; Wed, 21 Jun 2023 00:02:46 -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 S230237AbjFUGyN (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769294755125584166?= X-GMAIL-MSGID: =?utf-8?q?1769294755125584166?= 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);