From patchwork Fri Dec 16 06:24:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Jia X-Patchwork-Id: 33874 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp806594wrn; Thu, 15 Dec 2022 22:47:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf6DkG+l8lyTV9a34PWerlj2JEdBc2wypBsh45iDFGLkeZZpkyTi/uj7EyrPHwzho50IA1Z9 X-Received: by 2002:a17:906:face:b0:7c0:e98d:b27 with SMTP id lu14-20020a170906face00b007c0e98d0b27mr30154895ejb.58.1671173239777; Thu, 15 Dec 2022 22:47:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671173239; cv=none; d=google.com; s=arc-20160816; b=wmgcRKh+1UXj2bFOlnDstRtHIyoO987KdVygrtx+khb6OwBg64RW/R4VMwMZ22K0oR Sjm3HOxJErDCGHy5a1sPSTjNLxTeHEofsbc6hvkD5scwZZH0VSNbAzLRrICJXFmIC2Lw ZAsWdyAMxu0hN4HZK24QL8O7aKIxhIGp8MhujInqx4D9ffGVYWezFfUzUxUflMOS1Kbe DrLxFA9jBV2gHuZ847LXCB2vl8wW3W2c+pRfr1qaDJnGOxYONv0L7qi2P6VxJLWb18QY NE2tFT5uGc9mJb+bVjnCSyHuuPGe6MER4hwJg0UONurh7WhtCVWh8UbFPh3nIDtiRUyx O2BQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rEBn3rIORKhKVuqIN/cMMOVkHVPj5Ym5EqGWb/wIQVk=; b=KnfEE6Jf1T9lV/3tvyR4g5afRl7+rqze8J2w9SYT9xyr2Jozn7jM+f23a2WMKVhT2f ERxhfLnJ9IwVOJAXFhLOTXbftUkv7sMRx7fT+HWBoJZi4TJJdtDSfhSpIMo/o71yeYUJ 5r91X4RN8ZkMFKIWH9HKPHfSedqs0Vz/TOBZUWsKyxrbBoPThRdYVyA9rB1KyqQuoybm cMxuWkRncQ06+6FwtVNBCF9CbYjl98IbmKjekoZDfX2XYFT7wcCBp7/P1k7/C2dLZAPZ n/6I+Q+2GH59kOQpVbUnKHghF/0FdiYCpwSgvlClJEfeaI6wXc1SJFSsmit1ovnehgja VPxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="Ypv/XyC6"; 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=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c10-20020a170906528a00b007adeb7f8e5bsi1133620ejm.913.2022.12.15.22.46.52; Thu, 15 Dec 2022 22:47:19 -0800 (PST) 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; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="Ypv/XyC6"; 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=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229852AbiLPGYd (ORCPT + 99 others); Fri, 16 Dec 2022 01:24:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229704AbiLPGY3 (ORCPT ); Fri, 16 Dec 2022 01:24:29 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9F9B654EE for ; Thu, 15 Dec 2022 22:24:28 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id z8-20020a17090abd8800b00219ed30ce47so5057569pjr.3 for ; Thu, 15 Dec 2022 22:24:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rEBn3rIORKhKVuqIN/cMMOVkHVPj5Ym5EqGWb/wIQVk=; b=Ypv/XyC62kjv9HAqqcaPhJIxQx9wsgVqq+EI46a3l1IPfn4ashDi1YifxmVQ9zyaVC eBEhkkfSiP8xNDVkbyUl3xH1CVEX52HhFHVd4G7xLceGkNjgFcCaXQWHwKCM3zBwsIUi 25xJqTAxwVt9ldwxBU+/D5pDGqu+ChU2VKqsX153LKLtbJWRn7DBxXxWZ9hIqnKQgXci f6Ux1Ik5ExddTVYC2P9rIb1U/xqR/h6z9WzbCRlj6TiHa61/dgMSifzrF7E3QUO/C9CF yTlM/2U3oP5rqQZGkg3kywwY12EduCyBixeyp+wa88kSG40utoaAdeIJVNkrCGVhWhcW DQUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rEBn3rIORKhKVuqIN/cMMOVkHVPj5Ym5EqGWb/wIQVk=; b=WJZpGZHEOrRTolN9Tvvvd8IvQko0WLVSHEellmueZt454ssu2JL5TKJ58dWe+BEGHB 5j3+0Dv6ECMOHnCGYHCgBSfmOxwTmr5MGLsG54rX5vA7w2MXhXdukbrHdTv+U3ycBBMS AtRWCS2zBTvbUpyoCWzxWe1cZJML60w5dUAh7vZ7G03L0r4a64e7mwDmD+bPGlIvZjNp tneJoDBpp5HdIIvbFSlRTBrOaNiA89H4f3ZOutMqsxLRjn3SSBjEP+7Kzi1fIXdRm3iC 8kUu0RsQHfCrOxvba85G4PWyM3RLRU1Q3LFPjAjyxE5+tdYYosJrBOSdeYgKyCCWSLKP l/Hg== X-Gm-Message-State: ANoB5plffaC/hhex7/PlA0jzlglX2vMFUJ1m3rFm8ppax66ZQtJWtlrE ts3v1rqOjwZ8vTYD7BEYKW+ajQ== X-Received: by 2002:a05:6a20:bf17:b0:ac:6543:d515 with SMTP id gc23-20020a056a20bf1700b000ac6543d515mr34111225pzb.42.1671171868243; Thu, 15 Dec 2022 22:24:28 -0800 (PST) Received: from C02G87K0MD6R.bytedance.net ([139.177.225.228]) by smtp.gmail.com with ESMTPSA id s5-20020a656445000000b0046feca0883fsm681819pgv.64.2022.12.15.22.24.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 22:24:27 -0800 (PST) From: Hao Jia To: mingo@redhat.com, peterz@infradead.org, mingo@kernel.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, mgorman@techsingularity.net Cc: linux-kernel@vger.kernel.org, Hao Jia Subject: [PATCH v3 1/2] sched/numa: Stop an exhastive search if an idle core is found Date: Fri, 16 Dec 2022 14:24:05 +0800 Message-Id: <20221216062406.7812-2-jiahao.os@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20221216062406.7812-1-jiahao.os@bytedance.com> References: <20221216062406.7812-1-jiahao.os@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1752352150658384187?= X-GMAIL-MSGID: =?utf-8?q?1752352150658384187?= In update_numa_stats() we try to find an idle cpu on the NUMA node, preferably an idle core. we can stop looking for the next idle core or idle cpu after finding an idle core. But we can't stop the whole loop of scanning the CPU, because we need to calculate approximate NUMA stats at a point in time. For example, the src and dst nr_running is needed by task_numa_find_cpu(). Signed-off-by: Hao Jia Acked-by: Mel Gorman --- 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 c36aa54ae071..643cbcb61b49 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1804,7 +1804,7 @@ static void update_numa_stats(struct task_numa_env *env, ns->nr_running += rq->cfs.h_nr_running; ns->compute_capacity += capacity_of(cpu); - if (find_idle && !rq->nr_running && idle_cpu(cpu)) { + if (find_idle && idle_core < 0 && !rq->nr_running && idle_cpu(cpu)) { if (READ_ONCE(rq->numa_migrate_on) || !cpumask_test_cpu(cpu, env->p->cpus_ptr)) continue;