Message ID | 20230621071605.3853119-1-linmiaohe@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp4184725vqr; Wed, 21 Jun 2023 00:34:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6S8EQhg3y+C46kP/beKXKthHoxR/p/hXSPB1lSWv1VB7yCzU0v6Wauv3/zk4k4fPjMBQQw X-Received: by 2002:a17:90a:fe8d:b0:255:b1d9:a206 with SMTP id co13-20020a17090afe8d00b00255b1d9a206mr8019809pjb.22.1687332879364; Wed, 21 Jun 2023 00:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687332879; cv=none; d=google.com; s=arc-20160816; b=HLAZ/xJtpD3n4vbOWyW9oC5Jwyc1ty039snQWVP5cP/SaFTHYO54dyTKKExOK4RXbE QBWLRAAqoXadPaNnmZd/rn8BGWnmIGXT8gtmXkFVZkciDC3Y36O+DTaYYszkAM831MKR iQPTrKI3Blu+G5NqTO534/mDegkH+BvDL0yCqyFK2qqYkG9R/HgmQKcqoAuloHtcDK3F UgKwzF/abATwnyEICkkfypSiizRWkhT6dd0eFViIo9gxr2kQcno2o6QcUadWeEgr/qLm usutvZjRrpDsBGME/B/1Qkv+cEg1+uwdBV2f/8uUpxsG1yhxcM+btde7UkOTpoyR3oyp g3jQ== 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=Nhiv7cjnxD1o75d0QvkM2EuOvcjZeQOK1rRNhsxYNNo=; b=ybl/2alWWMRUfYBaH/j3gqQXpKuRqhLEL9HNcrrPzS5P90sATdQXJaVevbr/hcjln0 o0j9XaV21lCz7ODlby8GJG17aj3rzHXZxucD4rGnhBMkz5Pfcj+wGd6ZQbnHyzkSC98C 8b/NxD78o/j8x5/azuq3x3tcBxT3xSOPNbpsCBuP2saytynYhAzkjbrwK4z+zaA0hMd/ q2alOnYrwTBfBwZe6TcDwCRs558ITjzbiXDBy6lPhT+tJjTqEQ0LQ//vqO/Y35kOk/0f aTXoTArmmBrafYxv8URf40bRnodWX1p/kWHHtUW27V1BpdWJCc/0oYKIe395zy/SOdZp 2EWA== 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 jx20-20020a17090b46d400b0025de453ee4csi3593362pjb.168.2023.06.21.00.34.26; Wed, 21 Jun 2023 00:34:39 -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 S231234AbjFUHQr (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Wed, 21 Jun 2023 03:16:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbjFUHQo (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 21 Jun 2023 03:16:44 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 249531703 for <linux-kernel@vger.kernel.org>; Wed, 21 Jun 2023 00:16:43 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4QmFDK6X21z1FDds; Wed, 21 Jun 2023 15:16:33 +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 15:16:40 +0800 From: Miaohe Lin <linmiaohe@huawei.com> To: <mingo@redhat.com>, <peterz@infradead.org>, <juri.lelli@redhat.com>, <vincent.guittot@linaro.org> CC: <dietmar.eggemann@arm.com>, <rostedt@goodmis.org>, <bsegall@google.com>, <mgorman@suse.de>, <bristot@redhat.com>, <vschneid@redhat.com>, <linux-kernel@vger.kernel.org>, <linmiaohe@huawei.com> Subject: [PATCH] sched/fair: fix returning possible non-optimal candidate Date: Wed, 21 Jun 2023 15:16:05 +0800 Message-ID: <20230621071605.3853119-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: dggems704-chm.china.huawei.com (10.3.19.181) 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769296760920017883?= X-GMAIL-MSGID: =?utf-8?q?1769296760920017883?= |
Series |
sched/fair: fix returning possible non-optimal candidate
|
|
Commit Message
Miaohe Lin
June 21, 2023, 7:16 a.m. UTC
In best_fits < 0 case, best_thermal_cap > prev_thermal_cap is checked to
determine whether best_energy_cpu should be returned. But prev_fits can
be > 0 in this case and it should be preferred.
Fixes: e5ed0550c04c ("sched/fair: unlink misfit task from cpu overutilized")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
kernel/sched/fair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Wed, 21 Jun 2023 at 09:16, Miaohe Lin <linmiaohe@huawei.com> wrote: > > In best_fits < 0 case, best_thermal_cap > prev_thermal_cap is checked to > determine whether best_energy_cpu should be returned. But prev_fits can > be > 0 in this case and it should be preferred. IIRC, (best_thermal_cap > prev_thermal_cap) makes the condition (prev_fits < 0) useless Do you have a use case where (best_fits < 0) && (prev_fits > 0) && (best_thermal_cap > prev_thermal_cap) ? > > Fixes: e5ed0550c04c ("sched/fair: unlink misfit task from cpu overutilized") > Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> > --- > kernel/sched/fair.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 28ff831ee847..a4e300fc44be 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -7684,7 +7684,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) > > if ((best_fits > prev_fits) || > ((best_fits > 0) && (best_delta < prev_delta)) || > - ((best_fits < 0) && (best_thermal_cap > prev_thermal_cap))) > + ((best_fits < 0) && (prev_fits < 0) && (best_thermal_cap > prev_thermal_cap))) > target = best_energy_cpu; > > return target; > -- > 2.27.0 >
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 28ff831ee847..a4e300fc44be 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7684,7 +7684,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu) if ((best_fits > prev_fits) || ((best_fits > 0) && (best_delta < prev_delta)) || - ((best_fits < 0) && (best_thermal_cap > prev_thermal_cap))) + ((best_fits < 0) && (prev_fits < 0) && (best_thermal_cap > prev_thermal_cap))) target = best_energy_cpu; return target;