From nobody Mon Dec 1 22:05:55 2025 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B2FA30147A for ; Mon, 1 Dec 2025 09:13:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764580402; cv=none; b=KeSPVJoZDHDUPczwezHCr3VuTN926Oo+0Zw5DflPP3OeEo4PnEJoKxs1U80elf9JvhWB/PFYWyYP6TftAS2dvjPBGVDO6/Q0WslmLtQcq5GdFXhO4QjArHJ2gjCIwZ/vW8ks1k456Y8d1ZHXYY7syxH6YOYQ1iqy9DMt1bKiQgA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764580402; c=relaxed/simple; bh=CjNnaBgGisRqeIBtu4QTxT/7hU/7LjOKwy33GHb5I/E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N9fq0sal2v4qU7VlK81T6jrUL2kxfdzwJOJ9LiPG2wqcymZHMyeJyM14sovYFgTZYXsVie3vKh/Elj5mQViRPqUYzVlpLLu3tdbT4YUkT6BNPlARd5E/Xbpt/0i4u+Tr7eJaHPmySQvXe8TAL1rE9Qy/+wFK9UJ+EIFNgvHxw+Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=FrH/sAv1; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FrH/sAv1" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-42e2d44c727so584637f8f.0 for ; Mon, 01 Dec 2025 01:13:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764580399; x=1765185199; darn=vger.kernel.org; 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=R3BOBSKZ2J6e7XAb32c+ir+ZqfdYV3db2IojbkKh5Tk=; b=FrH/sAv1pLxlTmnvcU+Qay3I3QiXz68nev6rTHS0Mu4Vv5swdkbW+am33oKXmCDfcW qsS3V7hiP8W+Krw0vPPs7s1MWthN947dNs51laym4g/wljwk9NXW5Cd3ai+lUWTC6cJb XC6H/bZzx7gBIOk12Nc96q5aJCm8rp5uWrv0Cr+Elmq3bgT7G8wAMir538h7cNujacI3 k5HOYkCd89UImdnnD6RvqJlbXqusVGEM7+LBL64KXjebPF4aw5/EJF3hbOca9Onq+MCF /AMzUN7fvQwzpkT4RKtowFD9+lpoamV/5J+VrsiO3tvfVsAiplMzGy2psX7tcmgpLNEE 5G7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764580399; x=1765185199; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=R3BOBSKZ2J6e7XAb32c+ir+ZqfdYV3db2IojbkKh5Tk=; b=ZV3UJ1RmEFdHAmBWMc8sx5obbffz/yojvs2GhQ82dbNrMrbkHr7cQGWNkZWjJnYAZc lX7M8YrZx4CsPd4HMkqWlucLrdgaQq66uk7+ktA/lHzpJjzueBFigXtKN1dstHpPT/QV KhT7R5twiiFLfCxNTvmdozX5Tt/yqO9wKKRH0WYZru1/0Mp4pm92kQFaL/fi/Xd3iZ0U bX+Gr98ncrdj+OWx3uE1fqwh26LGhxQ2pi7eCJ+oiYE7r0I8cYiw8nAA5c1aiAEkeqaN cU+tV5XgHS8Cr3L8cL5DQTNIk8awW9rY5tDCn81zmZDBML3JKPXyIot/8+PDuWArnMcg 8Olg== X-Forwarded-Encrypted: i=1; AJvYcCX8GPZtmo+5FFZQNS990STcL4HI03yZmowTUyTLy7P/KIP3en9o1+QtIPmRHeY5aH8K8/PS0D4oOJcBFoY=@vger.kernel.org X-Gm-Message-State: AOJu0YyO/ui1gmeLrA8V9/H3+RHZYQf2j2oR1hWMmkM6pGggeMex0DU8 JLi7Ub5WTfrZ3JaMHAeRskvj0He+5eLjNO6v4e5qNJFx2JBylKQW33saGM6fswAYPaU= X-Gm-Gg: ASbGnctnOVlkxd5VrCpT1szgniyLq/Z3rzFzpB4F4ZOTE+75ipyVITx2wclxu72JZCM 61vbon7TgZYYagqG5/x/94Q9LyfP/VpaURkB2mmE5uoAOAtav0FFpxUTL99bg6kuoBmp32csFsd CgowdYDOtVG5Y9mft2OxiSxSGnRvgdNsAF4O/8RC8JRZMVh2NMZ5SwWZS1L35vcNP25FCam6Eqe yeCHjFFZmjo7Y2GClm8z16ov9pxkS28B+yf9PXq+ui0nTcS8x/USKOQrkEsJ8ghMCFBbfI6nqNA ek/GYBzNtdHzwPwoKcyQpBehPpWdS7PuELQs/cgvQuQXCIooeU5ytwdrOEv1RVi8n74c1H2F6Wy 8eWVaPXNkHJhc1gO55DE2NG4plvScu0uBwwhLMiO0CguwkrSRz5j/1FenzCfj7Ed43lsWHtJ6Ub noJOVMd7o7R7BKLKqCs5o= X-Google-Smtp-Source: AGHT+IH9fwMbJkaTV4rEU/fI7QYBA/hmyqNQ2s5J6VC3QXwjDINBIstq7NwJbJjJi/Xztvw5A9qcFA== X-Received: by 2002:a5d:5c89:0:b0:42b:5448:7b11 with SMTP id ffacd0b85a97d-42cc1cf3abdmr41231690f8f.33.1764580398584; Mon, 01 Dec 2025 01:13:18 -0800 (PST) Received: from vingu-cube.. ([2a01:e0a:f:6020:77d1:da59:4ce1:741c]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42e1caa767dsm25344110f8f.38.2025.12.01.01.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Dec 2025 01:13:18 -0800 (PST) From: Vincent Guittot To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, linux-kernel@vger.kernel.org, pierre.gondois@arm.com, kprateek.nayak@amd.com Cc: qyousef@layalina.io, hongyan.xia2@arm.com, christian.loehle@arm.com, luis.machado@arm.com, Vincent Guittot Subject: [RFC PATCH 5/6 v7] sched/fair: Enable idle core tracking for !SMT Date: Mon, 1 Dec 2025 10:13:07 +0100 Message-ID: <20251201091308.761711-6-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251201091308.761711-1-vincent.guittot@linaro.org> References: <20251201091308.761711-1-vincent.guittot@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Enable has_idle_cores at llc level feature for !SMT system for which CPU equals core. We don't enable has_idle_core feature of select_idle_cpu to be conservative and don't parse all CPUs of LLC. At now, has_idle_cores can be cleared even if a CPU is idle because of SIS_UTIL but it looks reasonnable as the probablity to get an idle CPU is low anyway. Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 29 +++++++---------------------- kernel/sched/sched.h | 42 +++++++++++++++++++++++++++++------------- 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 4e94a4cb8caa..9af8d0a61856 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -7500,19 +7500,6 @@ static inline int __select_idle_cpu(int cpu, struct = task_struct *p) return -1; } =20 -#ifdef CONFIG_SCHED_SMT -DEFINE_STATIC_KEY_FALSE(sched_smt_present); -EXPORT_SYMBOL_GPL(sched_smt_present); - -static inline void set_idle_cores(int cpu, int val) -{ - struct sched_domain_shared *sds; - - sds =3D rcu_dereference(per_cpu(sd_llc_shared, cpu)); - if (sds) - WRITE_ONCE(sds->has_idle_cores, val); -} - static inline bool test_idle_cores(int cpu) { struct sched_domain_shared *sds; @@ -7524,6 +7511,10 @@ static inline bool test_idle_cores(int cpu) return false; } =20 +#ifdef CONFIG_SCHED_SMT +DEFINE_STATIC_KEY_FALSE(sched_smt_present); +EXPORT_SYMBOL_GPL(sched_smt_present); + /* * Scans the local SMT mask to see if the entire core is idle, and records= this * information in sd_llc_shared->has_idle_cores. @@ -7611,15 +7602,6 @@ static int select_idle_smt(struct task_struct *p, st= ruct sched_domain *sd, int t =20 #else /* !CONFIG_SCHED_SMT: */ =20 -static inline void set_idle_cores(int cpu, int val) -{ -} - -static inline bool test_idle_cores(int cpu) -{ - return false; -} - static inline int select_idle_core(struct task_struct *p, int core, struct= cpumask *cpus, int *idle_cpu) { return __select_idle_cpu(core, p); @@ -7885,6 +7867,9 @@ static int select_idle_sibling(struct task_struct *p,= int prev, int target) if ((unsigned)i < nr_cpumask_bits) return i; =20 + if (!sched_smt_active()) + set_idle_cores(target, 0); + /* * For cluster machines which have lower sharing cache like L2 or * LLC Tag, we tend to find an idle CPU in the target's cluster diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 697bd654298a..b9e228333d5e 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1591,19 +1591,6 @@ do { \ flags =3D _raw_spin_rq_lock_irqsave(rq); \ } while (0) =20 -#ifdef CONFIG_SCHED_SMT -extern void __update_idle_core(struct rq *rq); - -static inline void update_idle_core(struct rq *rq) -{ - if (static_branch_unlikely(&sched_smt_present)) - __update_idle_core(rq); -} - -#else /* !CONFIG_SCHED_SMT: */ -static inline void update_idle_core(struct rq *rq) { } -#endif /* !CONFIG_SCHED_SMT */ - #ifdef CONFIG_FAIR_GROUP_SCHED =20 static inline struct task_struct *task_of(struct sched_entity *se) @@ -2091,6 +2078,35 @@ static __always_inline bool sched_asym_cpucap_active= (void) return static_branch_unlikely(&sched_asym_cpucapacity); } =20 +static inline void set_idle_cores(int cpu, int val) +{ + struct sched_domain_shared *sds; + + sds =3D rcu_dereference(per_cpu(sd_llc_shared, cpu)); + if (sds) + WRITE_ONCE(sds->has_idle_cores, val); +} + +#ifdef CONFIG_SCHED_SMT +extern void __update_idle_core(struct rq *rq); + +static inline void update_idle_core(struct rq *rq) +{ + if (static_branch_unlikely(&sched_smt_present)) + __update_idle_core(rq); + else + set_idle_cores(cpu_of(rq), 1); + +} + +#else /* !CONFIG_SCHED_SMT: */ +static inline void update_idle_core(struct rq *rq) +{ + set_idle_cores(cpu_of(rq), 1); +} +#endif /* !CONFIG_SCHED_SMT */ + + struct sched_group_capacity { atomic_t ref; /* --=20 2.43.0