From nobody Mon Apr 6 06:32:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2236DECAAA1 for ; Fri, 9 Sep 2022 09:02:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231538AbiIIJCA (ORCPT ); Fri, 9 Sep 2022 05:02:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230178AbiIIJAq (ORCPT ); Fri, 9 Sep 2022 05:00:46 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55615F10D4; Fri, 9 Sep 2022 02:00:32 -0700 (PDT) Date: Fri, 09 Sep 2022 09:00:28 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1662714029; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=05YG9MvHh0j7AEAuQ44oyynnYp17xNRkIy236iobukM=; b=Qp6SULMipbrbctlJe7DVDZDOi2NdNf5c68neGma4sSWysYMb9slY0Ju1xyZd4UszRHwCLh NHf9L+thVD5MxaNd1phVyiE+SAWt8xkXigzPnxZmKAw8G9eK+wO/8xoY5FhEvcL5+p0ptm EbnEwsaAvu0CYFp+JyRbuiyg6UZrabqhykfXv6L00c82JwaheAKMPiaopDdVMA6X9G9h6N 6ZA58fjzhH/QCoCIAVal/LbAA/SFNJZvXrugSlZM0IIba1Sv2HhOrHqKVoqDiBGVJ0mqiJ JBiTlT0Zk2U6BRVFrKLIwIpIPNnFRZtW2Wme7h/UrGHH++PaNhS1Pg3sIAieuA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1662714029; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=05YG9MvHh0j7AEAuQ44oyynnYp17xNRkIy236iobukM=; b=FcZH15SfJvc/CjXlbYKqM7qdLaY4vlb1bcUQ8OIgfW5xRY0PCNTLvGVvIrd0JrxJkHPIzK J4OcKseR9Rb5JTCw== From: "tip-bot2 for Abel Wu" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/fair: Default to false in test_idle_cores() Cc: Abel Wu , "Peter Zijlstra (Intel)" , Josh Don , Mel Gorman , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220907112000.1854-5-wuyun.abel@bytedance.com> References: <20220907112000.1854-5-wuyun.abel@bytedance.com> MIME-Version: 1.0 Message-ID: <166271402832.401.6641123344828384147.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: 398ba2b0cc0a43964fe3d2dd19cb2a478f1f220b Gitweb: https://git.kernel.org/tip/398ba2b0cc0a43964fe3d2dd19cb2a478= f1f220b Author: Abel Wu AuthorDate: Wed, 07 Sep 2022 19:19:59 +08:00 Committer: Peter Zijlstra CommitterDate: Wed, 07 Sep 2022 21:53:47 +02:00 sched/fair: Default to false in test_idle_cores() 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 hint to shared sched-domain if necessary. So the whole logic of this function depends on the existence of shared sched-domain, and can certainly bail out early if it is not available. 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. Signed-off-by: Abel Wu Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Josh Don Acked-by: Mel Gorman Link: https://lore.kernel.org/r/20220907112000.1854-5-wuyun.abel@bytedance.= com --- 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 03ce650..23b020c 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1588,11 +1588,11 @@ numa_type numa_classify(unsigned int imbalance_pct, =20 #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 >=3D 0 || !test_idle_cores(cpu, false)) + idle_core >=3D 0 || !test_idle_cores(cpu)) return idle_core; =20 /* @@ -6271,7 +6271,7 @@ static inline void set_idle_cores(int cpu, int val) WRITE_ONCE(sds->has_idle_cores, val); } =20 -static inline bool test_idle_cores(int cpu, bool def) +static inline bool test_idle_cores(int cpu) { struct sched_domain_shared *sds; =20 @@ -6279,7 +6279,7 @@ static inline bool test_idle_cores(int cpu, bool def) if (sds) return READ_ONCE(sds->has_idle_cores); =20 - return def; + return false; } =20 /* @@ -6295,7 +6295,7 @@ void __update_idle_core(struct rq *rq) int cpu; =20 rcu_read_lock(); - if (test_idle_cores(core, true)) + if (test_idle_cores(core)) goto unlock; =20 for_each_cpu(cpu, cpu_smt_mask(core)) { @@ -6367,9 +6367,9 @@ static inline void set_idle_cores(int cpu, int val) { } =20 -static inline bool test_idle_cores(int cpu, bool def) +static inline bool test_idle_cores(int cpu) { - return def; + return false; } =20 static inline int select_idle_core(struct task_struct *p, int core, struct= cpumask *cpus, int *idle_cpu) @@ -6608,7 +6608,7 @@ static int select_idle_sibling(struct task_struct *p,= int prev, int target) return target; =20 if (sched_smt_active()) { - has_idle_core =3D test_idle_cores(target, false); + has_idle_core =3D test_idle_cores(target); =20 if (!has_idle_core && cpus_share_cache(prev, target)) { i =3D select_idle_smt(p, prev);