Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4095087imw; Tue, 12 Jul 2022 01:27:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uNJ3IXj++GGz3VySgqFrA6CrAHIMSRgLboCISZPASmtyH+//hO/FEooI6khpAr98YFG0/h X-Received: by 2002:a17:907:87b0:b0:72a:a14e:106d with SMTP id qv48-20020a17090787b000b0072aa14e106dmr22825628ejc.167.1657614458810; Tue, 12 Jul 2022 01:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657614458; cv=none; d=google.com; s=arc-20160816; b=jmbh97x4yM8Su9TfmpzTV2yWTFynzVzOHe3JRwOMIui8OZ8H3Ikhx/x2+UcYKwtHJF QuDWOa7Wt30IXjrnIwcfEPy15iVqe+NfnqSr9z9H4P2XPQs7lCbko5nMO6WYSwAzHZTv Gx80MroKilhSz/CbhGWnJy/ZiLeE+G3iYkY0BJNSPaLDyuPQdkbC7mjTngDl0HTPctj2 O0/mSW7DX9KNDOQZJRaf40RoXB24toJ7ETkYq6sSGrfwgXH1cODGJfkWIx7NIxIEN2ye WVoXdkF9Hhg9i83YVmeIjVhs17K0EBxqj5cqTgKWkUBXr8IONzrMJc171JbCzMP9Otou Q6ZQ== 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=0oHBDiwaFsGTBwRGBiV75qzptiCX6BQhcdK4hyouxqo=; b=CvlBQDO2P+arAQeu3HNWq/m0xCAsd+MbXzz/ILld50q7uroXZdDHfwmHGLiAwuqX38 nSbzoSwe4sF5RHm7DEglXkMb8eZhNjQgP97fFUwAzUBH3oHR98rKNSTk7unUdLK0AVwb t/XKhNL7BDe2n3Mu5Pjz+OrYnNqQpOaVykyAZTwB6IAhWthEc7ZevLEHR6FZlnPvAV/k 5U6G7rgjDVufTN7jvdoHBSlCxZxy0xJrliMNszpiv5gU4vmZq5CrfbDq5JWAxuwBO+sV UDbFe2TeE2K4zP17mKmv1n2Y1cTMXwXd58YaVxVGGJBdpNVCiyZTBnb8pCq8Qj5547Ti BRsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=JmFoNoax; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kz12-20020a17090777cc00b00710e9e0a239si13051184ejc.919.2022.07.12.01.27.13; Tue, 12 Jul 2022 01:27:38 -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; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=JmFoNoax; 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 S232738AbiGLIWU (ORCPT + 99 others); Tue, 12 Jul 2022 04:22:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232349AbiGLIVw (ORCPT ); Tue, 12 Jul 2022 04:21:52 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0936FA2EFE for ; Tue, 12 Jul 2022 01:21:19 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id bh13so6927630pgb.4 for ; Tue, 12 Jul 2022 01:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0oHBDiwaFsGTBwRGBiV75qzptiCX6BQhcdK4hyouxqo=; b=JmFoNoaxkrmQg1VmI1FYollmz7uAzIk5FB7LmTNJZ3rj6zFPoPEnpvwvtjuVK0toVk EmjlqkHM1YmiubjPJx6Z78aVjnM4HdmK/C3Sa4z3cxVd80tcOQuCwH9VgaEGDc7BtXge 0oRTwhDY7heEYD2mNgtCUBn8Ynfmsba/x2jDLEDSNfNu27dfjRSt+FzMw8fU+mWtQGy/ 7E7198I3My97XR8j/a8whvC+b2oI3HgX7128TpCWF4Oc24R71HEkMXfhsQVjTEOFxoS6 hXylAIRBUh+yFvdHwObcXxmySKCwvaaohPUJjd9E/AJY0UeHmNINzG2t/aSCrFY53VUs IiBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0oHBDiwaFsGTBwRGBiV75qzptiCX6BQhcdK4hyouxqo=; b=Vt9u0ts6N89u8Xr5PD21i+0y7LECas/KylQKGsWGmynNTQr8Dmnjcn19u1mqilsib/ 7jjlqFMpO7SZLLqm26u4VYdoz9JmU8cAfiA++zQlWhm6Y/Kk4NRUM9K5E5C6yhof2j+c 2+2JGxJzKzuIj0/9yc7IIhGy2A6hUwMFGzGtTXY9zf5gT/jugKzTLtJQbX+mjlAAhs8a UhK5+3XR/740THT5KVbSrrZ9bkNU3PBLCBRMiAFroUKdbwiVJ7cO1A/i6FrqWXLwrAC3 J1cbFtKvctLJiZNTHQLHUqk9g5j992bJgiE5IrCv1vFBlsNgNpLhl/NJVdZ4tFcMIThJ OXJA== X-Gm-Message-State: AJIora9WLuSeTT83QeT9mASsLKDGL2bhfMBCPHyC2aApQZ/XYHBuSwL6 Q0XEcPFf1jbenbD8KMz5m/zWdg== X-Received: by 2002:a62:1cc8:0:b0:52a:ee9e:b735 with SMTP id c191-20020a621cc8000000b0052aee9eb735mr770805pfc.42.1657614078541; Tue, 12 Jul 2022 01:21:18 -0700 (PDT) Received: from C02DV8HUMD6R.bytedance.net ([139.177.225.234]) by smtp.gmail.com with ESMTPSA id s13-20020aa78bcd000000b0050dc762816dsm6114428pfd.71.2022.07.12.01.21.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jul 2022 01:21:18 -0700 (PDT) From: Abel Wu To: Peter Zijlstra , Mel Gorman , Vincent Guittot Cc: Josh Don , Chen Yu , linux-kernel@vger.kernel.org, Abel Wu Subject: [PATCH 2/5] sched/fair: default to false in test_idle_cores Date: Tue, 12 Jul 2022 16:20:33 +0800 Message-Id: <20220712082036.5130-3-wuyun.abel@bytedance.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220712082036.5130-1-wuyun.abel@bytedance.com> References: <20220712082036.5130-1-wuyun.abel@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, 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 It's uncertain whether idle cores exist or not if shared sched- domains are not ready, so returning "no idle cores" usually makes sense. While __update_idle_core() is an exception, it checks status of this core and set to shared sched-domain if necessary. So the whole logic depends on the existence of sds, and can bail out early if !sds. It's somehow a little tricky, and as Josh suggested that it should be transient while the domain isn't ready. So remove the self-defined default value to make things more clearer, while introduce little overhead in idle path. Signed-off-by: Abel Wu Reviewed-by: Josh Don --- kernel/sched/fair.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index cd758b3616bd..c72093f282ec 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1592,11 +1592,11 @@ numa_type numa_classify(unsigned int imbalance_pct, #ifdef CONFIG_SCHED_SMT /* Forward declarations of select_idle_sibling helpers */ -static inline bool test_idle_cores(int cpu, bool def); +static inline bool test_idle_cores(int cpu); static inline int numa_idle_core(int idle_core, int cpu) { if (!static_branch_likely(&sched_smt_present) || - idle_core >= 0 || !test_idle_cores(cpu, false)) + idle_core >= 0 || !test_idle_cores(cpu)) return idle_core; /* @@ -6260,7 +6260,7 @@ static inline void set_idle_cores(int cpu, int val) WRITE_ONCE(sds->has_idle_cores, val); } -static inline bool test_idle_cores(int cpu, bool def) +static inline bool test_idle_cores(int cpu) { struct sched_domain_shared *sds; @@ -6268,7 +6268,7 @@ static inline bool test_idle_cores(int cpu, bool def) if (sds) return READ_ONCE(sds->has_idle_cores); - return def; + return false; } /* @@ -6284,7 +6284,7 @@ void __update_idle_core(struct rq *rq) int cpu; rcu_read_lock(); - if (test_idle_cores(core, true)) + if (test_idle_cores(core)) goto unlock; for_each_cpu(cpu, cpu_smt_mask(core)) { @@ -6360,9 +6360,9 @@ static inline void set_idle_cores(int cpu, int val) { } -static inline bool test_idle_cores(int cpu, bool def) +static inline bool test_idle_cores(int cpu) { - return def; + return false; } static inline int select_idle_core(struct task_struct *p, int core, struct cpumask *cpus, int *idle_cpu) @@ -6604,7 +6604,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target) return target; if (sched_smt_active()) { - has_idle_core = test_idle_cores(target, false); + has_idle_core = test_idle_cores(target); if (!has_idle_core && cpus_share_cache(prev, target)) { i = select_idle_smt(p, sd, prev); -- 2.31.1