From nobody Mon May 25 08:11:30 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9DC730568E for ; Fri, 15 May 2026 17:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778865930; cv=none; b=HB6J2WcFBLaL3pnjWBz06/dto1ke4Z4aEBsMxAZu+DWI/5Getd8nEW4gfWoTFmptKI7u2W5bi3YE54blOb/TvD+CgdtyyOBoswprdF2Ez1poysfDdtL93Jt+iWWb/4zZQCIoe8UW/EDrWHG73dEiPwFsJi1T5Ydk/Mc/Wz2QhLs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778865930; c=relaxed/simple; bh=PirMdWZzw9r1QNob6l/JhO/g1/vJ+7Xm2zmQ9GUw8E0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QDnwcmjowmdbF4sb1dU8CB1odeauRgZb5r4l+NKwdk1Sz8zXBx/AT9028aMJXikVohtiHZnfhav3ewvZknosbYOwiNBG2mutYeq/4INdXzL76KFKERbrU4FR457mZmyLCmyz7r1f+Ndsux98Iz82WoALsoc59C89PvUM0FaUoys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=aX95yw1z; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="aX95yw1z" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64FAtBhA393542; Fri, 15 May 2026 17:25:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=RfWoDn0oRrxnavECs g87mMQ9SwDe5w7ZnUF7Yn6vZZw=; b=aX95yw1zupnlHv/LyXjdMcxV98zL4d0p6 5ZYtTqJUUcI94v6Gg+w4LDRWoj2EG48yVUKd2KhSS8krK91LxK55OgUb6Ax6Io07 rRd3O/65tajUguVmLbZgUNLSp3crp0o+/jBvmSRyUEXh9yfvk692ZkYwm8xHjaOE Wkbo/YurTsMEi0fZEzMrYobWRxNkDapqef1OmuohX86YOcyY6o6qkVzz8cRVmOsn A5IGMmNFqRaGNALrAOoIkHOkIdnLrlFj3kum4Um6uxJOtpfl+K8lemVweA0Zhvcv 3yABs6F8eFHsyWqwwagf+PCD0APi8/I0xe2pA1YFm9nPumpXtRTcQ== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e5m8vccrq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 May 2026 17:25:10 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64FHO7SQ013170; Fri, 15 May 2026 17:25:09 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e5kvccju4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 May 2026 17:25:09 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64FHP7XX62062870 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 May 2026 17:25:07 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6C8F120043; Fri, 15 May 2026 17:25:07 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F13E920040; Fri, 15 May 2026 17:25:03 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.39.30.78]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 15 May 2026 17:25:03 +0000 (GMT) From: Shrikanth Hegde To: mingo@kernel.org, peterz@infradead.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org Cc: sshegde@linux.ibm.com, kprateek.nayak@amd.com, juri.lelli@redhat.com, vschneid@redhat.com, dietmar.eggemann@arm.com, tj@kernel.org, rostedt@goodmis.org, mgorman@suse.de, bsegall@google.com, arighi@nvidia.com, pauld@redhat.com Subject: [PATCH v4 1/4] topology: Introduce cpu_smt_mask for CONFIG_SCHED_SMT=n Date: Fri, 15 May 2026 22:54:53 +0530 Message-ID: <20260515172456.542799-2-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260515172456.542799-1-sshegde@linux.ibm.com> References: <20260515172456.542799-1-sshegde@linux.ibm.com> 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 X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-ORIG-GUID: B2vXHFK-8j-6px4RwqsgD8Tcf9owfkJg X-Authority-Analysis: v=2.4 cv=duXrzVg4 c=1 sm=1 tr=0 ts=6a0756f6 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=zd2uoN0lAAAA:8 a=20KFwNOVAAAA:8 a=VnNF1IyMAAAA:8 a=I-H8Kolf9V4x88b-nqcA:9 X-Proofpoint-GUID: _twVkJPQRWfpXryIcTc8M5rpDzTrfDii X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE1MDE3NSBTYWx0ZWRfX2aIBqf+E1GLE 3seJoHsfm2sHJ622ah4kdpzFYItmx+mDSNpCrEbhs7h2lDexeabL4Poh1RNnqYIAoOspvKyTpzD a9UBWpNsZGWZJoCnUH34pXW/AweYlAy1qVqYoHRKxohFyqibylz8v0m/vHhY/+J7xQaZrQkNW3Y tjWppaVTwh8wfDZomgNVJ8a0QdSVlDdixHouhI9JknVRSdaoCz+dRxFnrSVfugAWxTOoPWKSOSA K8B772KXnfaiOBY2kBCCm/Bqp/DyIIx63Z9PRSg2oitoWpjeX1esMnKEXctb0X1DtMIGRqGH1lT E2idB1ORp4MolrHHX6ICfFJqvGb5pmCCqPvRyfepz1Ozi2pFVJJkejaH+VJTwld87cHTBISJhBT ZGgIccQhC62jqF0QjYeGdBNIuMHoEUhoQJQvndCfKNouhfw10zJmS4Rydz1tG9EyKvn7WYqrCna 9adv3t+vLJqpw9cz/aA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-15_04,2026-05-15_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 priorityscore=1501 phishscore=0 bulkscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605150175 Content-Type: text/plain; charset="utf-8" Define cpu_smt_mask in case of CONFIG_SCHED_SMT=3Dn as cpumask_of that CPU. With that config, it is expected that kernel treats each CPU as individual core. Using cpumask_of(cpu) reflects that. This would help to get rid of the ifdeffery that is spread across the codebase since cpu_smt_mask is defined only in case of CONFIG_SCHED_SMT=3Dy. Note: There is no arch today which defines cpu_smt_mask unconditionally. So likely defining the cpu_smt_mask shouldn't lead redefinition errors. Tested-by: K Prateek Nayak Reviewed-by: Phil Auld Reviewed-by: Valentin Schneider Signed-off-by: Shrikanth Hegde --- include/linux/topology.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/topology.h b/include/linux/topology.h index 6575af39fd10..709a2dcf4c73 100644 --- a/include/linux/topology.h +++ b/include/linux/topology.h @@ -230,11 +230,24 @@ static inline int cpu_to_mem(int cpu) #define topology_drawer_cpumask(cpu) cpumask_of(cpu) #endif =20 -#if defined(CONFIG_SCHED_SMT) && !defined(cpu_smt_mask) +/* + * Defining cpu_smt_mask as cpumask_of that CPU helps to get + * rid of lot of ifdeffery all around the codebase in case of + * CONFIG_SCHED_SMT=3Dn. It just means there are no other siblings, which + * is what is expected. + */ +#if defined(CONFIG_SCHED_SMT) +# if !defined(cpu_smt_mask) static inline const struct cpumask *cpu_smt_mask(int cpu) { return topology_sibling_cpumask(cpu); } +# endif +#else /* !CONFIG_SCHED_SMT */ +static inline const struct cpumask *cpu_smt_mask(int cpu) +{ + return cpumask_of(cpu); +} #endif =20 #ifndef topology_is_primary_thread --=20 2.47.3 From nobody Mon May 25 08:11:30 2026 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C13173DB636 for ; Fri, 15 May 2026 17:25:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778865934; cv=none; b=MkagMdB3x7gzgNFsdv0VFASX7M7+nz4NAF6dWSq9WSynjzeJpP+T4uSetvQ6PevRf14Z4UoP8DQqr8kAckSeORT5MtB/zM6KFt3HbJqlC8SiTeWNe2kQT7QK15Vi9xlD/CDF9Lu9yGGsnjb1G3N/iDyDmIz9RAIIQdQ0lmShGeU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778865934; c=relaxed/simple; bh=QNHH53p0vTa3+3W4viU0AL4yNubUfTdtIOh1XuU/4kw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sxqsHPG5zPmWHFn3OeScLEg56KJNdWGfmuZyqX+v7Ul2oswHe9vE5kDbfJPYYIazzidqdbQ96ZqA8Zeh0qQuJL89iC9Y+H9H9wzhXFF4N9AU7EWKRhHBsK+Kfl3VkEv88Lgmmwk4l0OUEnGjVhDUsmaGXn29YS7YVRLorKnQ/CU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=GwOhPakf; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="GwOhPakf" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64FAWW0J3950751; Fri, 15 May 2026 17:25:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=1iR1O0kt5BgByG1yy /EKBd7UvgRzCBXkbUFwM43YQAA=; b=GwOhPakfEoi7/4/fd7o7qkoHYuW4jQMQD OxSIY9Tuusan+8OvNPlxhRxae6X3uWfhdmrR75tTBJezSOavIRLeDoE0fw5ZO0nO TPBHNQk6lIohf2hpXHmHoY76u4hsu2fNda724nwuoNnSwWlYQywkUi+3M8THbhAj 4YfOy1IWhbKRQJoxLyyOm1Lg1Cg2aidsLalzR84Xr6saQ98IDK+FCFCJaks1kxen 7twGnfYa9mc2AYvZoynysk1PIN8NWdmE4P9gpn5y2bIdaGqRXblMP/dBbn7kXvLq JAMWN+olmfwLgFm4ewJm4STeoFjReKO4o2y1iQodE8VQMwovt9xKA== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e5m8ycc81-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 May 2026 17:25:14 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64FHOAQx025886; Fri, 15 May 2026 17:25:13 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e5kvcckcu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 May 2026 17:25:13 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64FHPBuh57868716 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 May 2026 17:25:11 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9CEE020043; Fri, 15 May 2026 17:25:11 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D2CAC2004B; Fri, 15 May 2026 17:25:07 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.39.30.78]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 15 May 2026 17:25:07 +0000 (GMT) From: Shrikanth Hegde To: mingo@kernel.org, peterz@infradead.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org Cc: sshegde@linux.ibm.com, kprateek.nayak@amd.com, juri.lelli@redhat.com, vschneid@redhat.com, dietmar.eggemann@arm.com, tj@kernel.org, rostedt@goodmis.org, mgorman@suse.de, bsegall@google.com, arighi@nvidia.com, pauld@redhat.com Subject: [PATCH v4 2/4] sched: Simplify ifdeffery around cpu_smt_mask Date: Fri, 15 May 2026 22:54:54 +0530 Message-ID: <20260515172456.542799-3-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260515172456.542799-1-sshegde@linux.ibm.com> References: <20260515172456.542799-1-sshegde@linux.ibm.com> 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 X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: IvGHuaRI5qY4y0iFuWIddmpUWK4eUBeZ X-Authority-Analysis: v=2.4 cv=Os5/DS/t c=1 sm=1 tr=0 ts=6a0756fa cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=zd2uoN0lAAAA:8 a=20KFwNOVAAAA:8 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=tYOOUy7Fey2-yfTBsNMA:9 X-Proofpoint-ORIG-GUID: dGsy9UjWFNT30djQUs-7vv77EQOjdPOG X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE1MDE3NSBTYWx0ZWRfX6hNFienyH5Ea SNlB9r4oUaPwq5i8kSoD8zlOhI2HuXVThgZ1MVUYVBi6i3Ek47rWabNaYOkU95ybOvkeMYXJeBq CDiqN2/ON5ss6HhBrU5BhQPOYX3tlxYvpq+kYXwYNV0o6e9LCmUyOVgtyDq93yTpodU2jSUXXtn FEyLzRZdbHxrR2fMNEACkX9THAiflyoClE4dZQwe3IF+AZH0u1PBdI3SgL1r8cbrQBjtIx6Tnek JxtV5OIfy8O7F/6TLh649c1mPPgg5JnE5cRBmn9i9hiqt1edTdAIV6sIhm9+baH4dbTkF9puxsP dkMJ5CirGKZElmmbAuQPUI+/Cz1PKqVHEM1xtZuPU4+5NtTaJ3JMT8xS6Q6PvD+YtRHn2a2iyj+ sAYfgLGdWGJ2ugsq7mG9Cs3lYjKBKoeMfPPsXjVaVUrRP7EHmZ7CIkjznCs6ExlmkBhP3ozHp41 kdr1RNnxnDwvYoJ4vOA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-15_04,2026-05-15_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 adultscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605150175 Content-Type: text/plain; charset="utf-8" Now, that cpu_smt_mask is defined as cpumask_of(cpu) for CONFIG_SCHED_SMT=3Dn, it is possible to get rid of the ifdeffery. Effectively, - This makes sched_smt_present is defined always - cpumask_weight(cpumask_of(cpu)) =3D=3D 1. So sched_smt_present_inc/dec will never enable the sched_smt_present. Which is expected. - Paths that were compile-time eliminated become runtime guarded using static keys. - Defines set_idle_cores, test_idle_cores, etc which could likely benefit the CONFIG_SCHED_SMT=3Dn systems to use the same optimizations within the LLC at wakeups. - This will expose sched_smt_present symbol for CONFIG_SCHED_SMT=3Dn. Likely not a concern. - There is a bloat of code CONFIG_SCHED_SMT=3Dn. (NR_CPUS=3D2048) add/remove: 24/18 grow/shrink: 26/28 up/down: 6396/-3188 (3208) Total: Before=3D30629880, After=3D30633088, chg +0.01% - No code bloat for CONFIG_SCHED_SMT=3Dy, which is expected. - Add comments around stop_core_cpuslocked on why ifdefs are not removed. - This leaves the remaining uses of CONFIG_SCHED_SMT mainly for topology building bits which has a policy based decision. Tested-by: K Prateek Nayak Reviewed-by: Phil Auld Reviewed-by: Valentin Schneider Acked-by: Tejun Heo Signed-off-by: Shrikanth Hegde --- include/linux/sched/smt.h | 4 ---- kernel/sched/core.c | 6 ------ kernel/sched/ext_idle.c | 6 ------ kernel/sched/fair.c | 35 ----------------------------------- kernel/sched/sched.h | 6 ------ kernel/sched/topology.c | 2 -- kernel/stop_machine.c | 5 +++++ kernel/workqueue.c | 4 ---- 8 files changed, 5 insertions(+), 63 deletions(-) diff --git a/include/linux/sched/smt.h b/include/linux/sched/smt.h index 166b19af956f..cde6679c0278 100644 --- a/include/linux/sched/smt.h +++ b/include/linux/sched/smt.h @@ -4,16 +4,12 @@ =20 #include =20 -#ifdef CONFIG_SCHED_SMT extern struct static_key_false sched_smt_present; =20 static __always_inline bool sched_smt_active(void) { return static_branch_likely(&sched_smt_present); } -#else -static __always_inline bool sched_smt_active(void) { return false; } -#endif =20 void arch_smt_update(void); =20 diff --git a/kernel/sched/core.c b/kernel/sched/core.c index b905805bbcbe..3ae5f19c1b7e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -8612,18 +8612,14 @@ static void cpuset_cpu_inactive(unsigned int cpu) =20 static inline void sched_smt_present_inc(int cpu) { -#ifdef CONFIG_SCHED_SMT if (cpumask_weight(cpu_smt_mask(cpu)) =3D=3D 2) static_branch_inc_cpuslocked(&sched_smt_present); -#endif } =20 static inline void sched_smt_present_dec(int cpu) { -#ifdef CONFIG_SCHED_SMT if (cpumask_weight(cpu_smt_mask(cpu)) =3D=3D 2) static_branch_dec_cpuslocked(&sched_smt_present); -#endif } =20 int sched_cpu_activate(unsigned int cpu) @@ -8711,9 +8707,7 @@ int sched_cpu_deactivate(unsigned int cpu) */ sched_smt_present_dec(cpu); =20 -#ifdef CONFIG_SCHED_SMT sched_core_cpu_deactivate(cpu); -#endif =20 if (!sched_smp_initialized) return 0; diff --git a/kernel/sched/ext_idle.c b/kernel/sched/ext_idle.c index 6e1980763270..9f5ad6b071f9 100644 --- a/kernel/sched/ext_idle.c +++ b/kernel/sched/ext_idle.c @@ -79,7 +79,6 @@ static bool scx_idle_test_and_clear_cpu(int cpu) int node =3D scx_cpu_node_if_enabled(cpu); struct cpumask *idle_cpus =3D idle_cpumask(node)->cpu; =20 -#ifdef CONFIG_SCHED_SMT /* * SMT mask should be cleared whether we can claim @cpu or not. The SMT * cluster is not wholly idle either way. This also prevents @@ -104,7 +103,6 @@ static bool scx_idle_test_and_clear_cpu(int cpu) else if (cpumask_test_cpu(cpu, idle_smts)) __cpumask_clear_cpu(cpu, idle_smts); } -#endif =20 return cpumask_test_and_clear_cpu(cpu, idle_cpus); } @@ -622,7 +620,6 @@ s32 scx_select_cpu_dfl(struct task_struct *p, s32 prev_= cpu, u64 wake_flags, goto out_unlock; } =20 -#ifdef CONFIG_SCHED_SMT /* * Use @prev_cpu's sibling if it's idle. */ @@ -634,7 +631,6 @@ s32 scx_select_cpu_dfl(struct task_struct *p, s32 prev_= cpu, u64 wake_flags, goto out_unlock; } } -#endif =20 /* * Search for any idle CPU in the same LLC domain. @@ -714,7 +710,6 @@ static void update_builtin_idle(int cpu, bool idle) =20 assign_cpu(cpu, idle_cpus, idle); =20 -#ifdef CONFIG_SCHED_SMT if (sched_smt_active()) { const struct cpumask *smt =3D cpu_smt_mask(cpu); struct cpumask *idle_smts =3D idle_cpumask(node)->smt; @@ -731,7 +726,6 @@ static void update_builtin_idle(int cpu, bool idle) cpumask_andnot(idle_smts, idle_smts, smt); } } -#endif } =20 /* diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 3ebec186f982..353e31ecaadc 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1584,7 +1584,6 @@ update_stats_curr_start(struct cfs_rq *cfs_rq, struct= sched_entity *se) =20 static inline bool is_core_idle(int cpu) { -#ifdef CONFIG_SCHED_SMT int sibling; =20 for_each_cpu(sibling, cpu_smt_mask(cpu)) { @@ -1594,7 +1593,6 @@ static inline bool is_core_idle(int cpu) if (!idle_cpu(sibling)) return false; } -#endif =20 return true; } @@ -2277,7 +2275,6 @@ numa_type numa_classify(unsigned int imbalance_pct, return node_fully_busy; } =20 -#ifdef CONFIG_SCHED_SMT /* Forward declarations of select_idle_sibling helpers */ static inline bool test_idle_cores(int cpu); static inline int numa_idle_core(int idle_core, int cpu) @@ -2295,12 +2292,6 @@ static inline int numa_idle_core(int idle_core, int = cpu) =20 return idle_core; } -#else /* !CONFIG_SCHED_SMT: */ -static inline int numa_idle_core(int idle_core, int cpu) -{ - return idle_core; -} -#endif /* !CONFIG_SCHED_SMT */ =20 /* * Gather all necessary information to make NUMA balancing placement @@ -7811,7 +7802,6 @@ static inline int __select_idle_cpu(int cpu, struct t= ask_struct *p) return -1; } =20 -#ifdef CONFIG_SCHED_SMT DEFINE_STATIC_KEY_FALSE(sched_smt_present); EXPORT_SYMBOL_GPL(sched_smt_present); =20 @@ -7921,29 +7911,6 @@ static int select_idle_smt(struct task_struct *p, st= ruct sched_domain *sd, int t return -1; } =20 -#else /* !CONFIG_SCHED_SMT: */ - -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); -} - -static inline int select_idle_smt(struct task_struct *p, struct sched_doma= in *sd, int target) -{ - return -1; -} - -#endif /* !CONFIG_SCHED_SMT */ - /* * Scan the LLC domain for idle CPUs; this is dynamically regulated by * comparing the average scan cost (tracked in sd->avg_scan_cost) against = the @@ -12036,9 +12003,7 @@ static int should_we_balance(struct lb_env *env) * idle has been found, then its not needed to check other * SMT siblings for idleness: */ -#ifdef CONFIG_SCHED_SMT cpumask_andnot(swb_cpus, swb_cpus, cpu_smt_mask(cpu)); -#endif continue; } =20 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 9f63b15d309d..e476623a0c2a 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1667,7 +1667,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); =20 static inline void update_idle_core(struct rq *rq) @@ -1676,12 +1675,7 @@ static inline void update_idle_core(struct rq *rq) __update_idle_core(rq); } =20 -#else /* !CONFIG_SCHED_SMT: */ -static inline void update_idle_core(struct rq *rq) { } -#endif /* !CONFIG_SCHED_SMT */ - #ifdef CONFIG_FAIR_GROUP_SCHED - static inline struct task_struct *task_of(struct sched_entity *se) { WARN_ON_ONCE(!entity_is_task(se)); diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 5847b83d9d55..a1f46e3f4ede 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -1310,9 +1310,7 @@ static void init_sched_groups_capacity(int cpu, struc= t sched_domain *sd) cpumask_copy(mask, sched_group_span(sg)); for_each_cpu(cpu, mask) { cores++; -#ifdef CONFIG_SCHED_SMT cpumask_andnot(mask, mask, cpu_smt_mask(cpu)); -#endif } sg->cores =3D cores; =20 diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index 3fe6b0c99f3d..773d8e9ae30c 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c @@ -633,6 +633,11 @@ int stop_machine(cpu_stop_fn_t fn, void *data, const s= truct cpumask *cpus) EXPORT_SYMBOL_GPL(stop_machine); =20 #ifdef CONFIG_SCHED_SMT +/* + * INTEL_IFS is the only user of this API. That selftest can + * only be compiled if SMP=3Dy. On x86 it selects SCHED_SMT. + * Keep the ifdefs for now. + */ int stop_core_cpuslocked(unsigned int cpu, cpu_stop_fn_t fn, void *data) { const struct cpumask *smt_mask =3D cpu_smt_mask(cpu); diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 33b721a9af02..0c265eac903a 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -8212,11 +8212,7 @@ static bool __init cpus_dont_share(int cpu0, int cpu= 1) =20 static bool __init cpus_share_smt(int cpu0, int cpu1) { -#ifdef CONFIG_SCHED_SMT return cpumask_test_cpu(cpu0, cpu_smt_mask(cpu1)); -#else - return false; -#endif } =20 static bool __init cpus_share_numa(int cpu0, int cpu1) --=20 2.47.3 From nobody Mon May 25 08:11:30 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 705263D9DB3 for ; Fri, 15 May 2026 17:25:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778865936; cv=none; b=sbivRpKA1dxlD1Z8r09L7REEkB5If7D3eHnXF5ynrkuGKaEqTkb05wdoSTOAvN3V/u52OIhV+4CYNFDi/CPxX9zA4jTF9PT5YUR76RtxAH0C7W9twvpjnHSBhoFJENdrTgzM16XOZCYAEPdSODEAeLOSdkmcPnILZJTmDYJaTKU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778865936; c=relaxed/simple; bh=4MRtxFT/+sLsJ/sdumWDaeobg7ePpjgbaGEb5ANJV1o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=j3V50F2eCmQ8KPdgWWAK9zPbyLxUfqKIswNBy9iyKriAXq4nDwALeIPUS20soUgN+2S0n9nvAK8h1d8BA1n2COJlbzjjK8/CDaecm4OApNJ3BYY+jnLOr7b9XulRiuI3cFO9kbET1I1P3qRbbzsfvz8k7TIQfOjTsf2pJx9crDU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=nWcnA0s0; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="nWcnA0s0" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64FBoNPG575999; Fri, 15 May 2026 17:25:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=SfIlDQN+AyfcPHU/e 2HiVk4jsH1b2tdUoFf+2ySoB54=; b=nWcnA0s0xDTtCCG5vIDV4Z5fJ7lf8maFO bhe/WvOMZdmoRFBPNZKbvyIIwZsKCZzkuuB5yaddR+h52Qcp6V9YJ+IiZ8QvCmPd lqJh96It8FO6TmaOnISvt0SJvgVg1bmzOs7lWQwMtOFc7HDqwIhSR+0+NblLx+BS 2f9E5piUMFDSVEyzIp8gS3GWqapTr+M9JyhzOEWaL0JBiAea7WwJh0rr06n/OXTF Urh/NeWE6qPpTF0Lj0YidZ+RgHwJXfg/R6cUxcTGt3l3rK8l/iyIrLmt8HCKh83e Aww9QQw2fRt0QRe1zTzlzs5UmeajIdCuOFLDp7Y4mIMhdFhrXO3cg== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e5m92m7q3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 May 2026 17:25:17 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64FHO8sq013194; Fri, 15 May 2026 17:25:17 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e5kvccjup-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 May 2026 17:25:17 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64FHPF5f49742216 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 May 2026 17:25:15 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 59A3F2004E; Fri, 15 May 2026 17:25:15 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0909820043; Fri, 15 May 2026 17:25:12 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.39.30.78]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 15 May 2026 17:25:11 +0000 (GMT) From: Shrikanth Hegde To: mingo@kernel.org, peterz@infradead.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org Cc: sshegde@linux.ibm.com, kprateek.nayak@amd.com, juri.lelli@redhat.com, vschneid@redhat.com, dietmar.eggemann@arm.com, tj@kernel.org, rostedt@goodmis.org, mgorman@suse.de, bsegall@google.com, arighi@nvidia.com, pauld@redhat.com Subject: [PATCH v4 3/4] sched/fair: Add sched_smt_active check for fastpaths Date: Fri, 15 May 2026 22:54:55 +0530 Message-ID: <20260515172456.542799-4-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260515172456.542799-1-sshegde@linux.ibm.com> References: <20260515172456.542799-1-sshegde@linux.ibm.com> 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 X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE1MDE3NSBTYWx0ZWRfX5stfIcU5FqRE 6DrhvaydWznEISvfZFB9aC61bzr/6H5Hpb5rjSTgpJb0bNlpxYs7zrXIvnefUvQmY/aupwgVAFD +bowl92IKO0tvHY/VwBLNyTIYy+oG7tY9JQdkbKgnMJQCp/6ANLTHGt6ryTwKuLjJg06o6UtYz7 p/pdOSaiK3T/FUew8EECS1wyzLXBmDYp0XYR/xP18IP3JUaQN0MWAiSwRE9IBfM42ffCYCVOyom kt1eBeI2fuKR9x8lKxkQxlgAKEN7dZJLDAnBE2h33O3DsrEmGgtCkzj3hxJ1n81vUMG1GGcRzES ztDCAEpjxQn7JTeiMJQAhGKL9E2i36KPAHAV7sBKhf2BSs3hP7N72FvXTyXqyPi6oy3uTWEyLvt HEDOQCx1cJN1CIx2GKOUBpxe3oCjnRM3p/iYiVyJ1hdVCKF7dlRDGk2zVhcbrBjfRf591huv095 0RPmP07mLnKhTNBqPJg== X-Proofpoint-ORIG-GUID: OITuhTylAV5U2y-DojEenlWApAZNrRyO X-Authority-Analysis: v=2.4 cv=aNnAb79m c=1 sm=1 tr=0 ts=6a0756fe cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=zd2uoN0lAAAA:8 a=VnNF1IyMAAAA:8 a=BCh2IS2iSeRwy_Yvm5cA:9 X-Proofpoint-GUID: H8huClDVbKXyvPukxU7-kcyrHsPuO0sV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-15_04,2026-05-15_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 malwarescore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 clxscore=1015 adultscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605150175 Content-Type: text/plain; charset="utf-8" For fastpaths such as wakeup and load balance even minimal code additions can add up. is_core_idle is accessed during load balance. Other callsites of is_core_idle make sched_smt_active() check first. Make the same check in should_we_balance. Rest of access to cpu_smt_mask isn't in fastpath. Note: Remove the stale comment above is_core_idle. Enqueue methods of fair aren't close to it anymore. Suggested-by: K Prateek Nayak Signed-off-by: Shrikanth Hegde Reviewed-by: Valentin Schneider --- kernel/sched/fair.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 353e31ecaadc..c0d66a10d01e 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1578,10 +1578,7 @@ update_stats_curr_start(struct cfs_rq *cfs_rq, struc= t sched_entity *se) se->exec_start =3D rq_clock_task(rq_of(cfs_rq)); } =20 -/************************************************** - * Scheduling class queueing methods: - */ - +/* Check sched_smt_active before calling this to avoid overheads in fastpa= ths */ static inline bool is_core_idle(int cpu) { int sibling; @@ -11995,7 +11992,9 @@ static int should_we_balance(struct lb_env *env) * balancing cores, but remember the first idle SMT CPU for * later consideration. Find CPU on an idle core first. */ - if (!(env->sd->flags & SD_SHARE_CPUCAPACITY) && !is_core_idle(cpu)) { + if (sched_smt_active() && + !(env->sd->flags & SD_SHARE_CPUCAPACITY) && + !is_core_idle(cpu)) { if (idle_smt =3D=3D -1) idle_smt =3D cpu; /* --=20 2.47.3 From nobody Mon May 25 08:11:30 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9EA233D9DB3 for ; Fri, 15 May 2026 17:25:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778865941; cv=none; b=YcGMz/Lxc0h0THxy2ifu0iIMeF6tfQTc3vr7ciyV8T2u8EB95AXaSbboJxhMBnKqyxaz5eAvJMAcErchnXLg5wZKy1XejezgtFF/m59KwpyAO946b3tg6i3nbLcXM3AIXDtVK+2/QOJNTWOp7upHSLw3KYpLdykswayoSegmdW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778865941; c=relaxed/simple; bh=j+0yNXPywQF++Qj67M/KxDC1+69Wamni8Yw2VKlFDfg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SFekqOXo7e4F9xfQF0tNXHWW80Nph/cD45VzbhuwdMVWZZijYQWtXVXOVs2oDCFltOuOeVsXStv9I0uQf7ICWV42Ft3SioH4HeKtei4IfMgJaAtaTzn1amy+KRCoRhnCp2UNNaZ+SkYiGSJwQ/7gWnb70Mdn78PrhmYMKU6zUIY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=MPOhzXLm; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="MPOhzXLm" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64FBPJTc001935; Fri, 15 May 2026 17:25:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=D8hZdXRFELLGxwxKs Os9GbFKmFLqkGzS1Um9Sszck2U=; b=MPOhzXLm3j3erzvFqxIbZQspR5LhvmjCI 3/Nd4B2GuatrWmjG9Y4ip3itoSh6kLUZ+OJHgYhk/QQCaJva7ax05hZ7S7+5GJlk kJa+b6KOtRAfApCZrNJ4FjX/AZtV8jpfXETuF8JcqEW3rskuXP+Trq6AfRYj6itq bG1LEuQJhTvd0Mq6OipQc7axT4OAPgusykkAgYwr3ZaJvBJ805DAtstojJpqRCgW 3AoEWCppyzd7H3I9znX0qrPWFO2kYLqEXQ2yrkTJ345/Ikov4ap88erHaoEpE6fL SmEm2vjruBISY7yIY7GtMyGdn/+RoagtzCiQAc9WSxURHwDZlPALg== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e5m8y47k3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 May 2026 17:25:21 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64FHO6lU028963; Fri, 15 May 2026 17:25:21 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e5m3amgq1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 May 2026 17:25:21 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64FHPJP615597946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 May 2026 17:25:19 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2510A2004B; Fri, 15 May 2026 17:25:19 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C3D652004D; Fri, 15 May 2026 17:25:15 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.39.30.78]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 15 May 2026 17:25:15 +0000 (GMT) From: Shrikanth Hegde To: mingo@kernel.org, peterz@infradead.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org Cc: sshegde@linux.ibm.com, kprateek.nayak@amd.com, juri.lelli@redhat.com, vschneid@redhat.com, dietmar.eggemann@arm.com, tj@kernel.org, rostedt@goodmis.org, mgorman@suse.de, bsegall@google.com, arighi@nvidia.com, pauld@redhat.com Subject: [PATCH v4 4/4] sched: Unify SMT active check via sched_smt_active() Date: Fri, 15 May 2026 22:54:56 +0530 Message-ID: <20260515172456.542799-5-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260515172456.542799-1-sshegde@linux.ibm.com> References: <20260515172456.542799-1-sshegde@linux.ibm.com> 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 X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: XwxSsgNXW7JIhEcnw6YpHuBIKTAfTriN X-Authority-Analysis: v=2.4 cv=RemgzVtv c=1 sm=1 tr=0 ts=6a075702 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=20KFwNOVAAAA:8 a=VnNF1IyMAAAA:8 a=oDfC2TE6gg0lhyfcySYA:9 X-Proofpoint-ORIG-GUID: CvHZaEP7KhZXjfHQuDmx0Jesv1TR4CSa X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE1MDE3NSBTYWx0ZWRfX7w5cjHfx+Erc 8uCRRUYg08KKgJyfuev9Gpzb77HHIVIkDjVbxjAHSZRBliMel0r2/JqwlGL20GY7oTDKdM2rUL9 zWDgexdUvQH++heK6Y599a0MldKzlEwxlnkdfS7rbdukdiHFtwL8h7EapIv63Gc5tkvMsRTJkar Nd774n0OcGXiFUgDaaQ/qIRbc8yy0zmYkiNkNhOeiaTpK+vspO3iVdTSRCnb4zeLR6m0QZvIbmf 3T4UbeLmD+uFA0JPDHxsMyMm2+I7lOBfjwY9BQftG/IOsE224FFw54HIyYNSIYiKkNh2C7xKKEi 3nwsiHDJlpVz6Z9yFvMXMe5p/fWDxwwYaWwYMgBNZj1XSn+w/AGxoEa/8CnC948AKvxCObMQQnN D9RllmdvIaUIhFP4csqrnOqQLSljks01IO81M8iATZ/R/fyewDO6qC8f/OrTgdtSZjLobk59rpm 7O6DxlWvCcAWZocMaFg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-15_04,2026-05-15_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 adultscore=0 priorityscore=1501 bulkscore=0 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605150175 Content-Type: text/plain; charset="utf-8" There is a use of sched_smt_active() and explicit use of sched_smt_present. Remove the explicit usage for better code maintenance and readability. Note that this differs slightly for update_idle_core. It used to call static_branch_unlikely earlier and now it will call static_branch_likely. Reviewed-by: Valentin Schneider Signed-off-by: Shrikanth Hegde --- kernel/sched/core_sched.c | 2 +- kernel/sched/fair.c | 2 +- kernel/sched/sched.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core_sched.c b/kernel/sched/core_sched.c index 73b6b2426911..43e0bde3038e 100644 --- a/kernel/sched/core_sched.c +++ b/kernel/sched/core_sched.c @@ -136,7 +136,7 @@ int sched_core_share_pid(unsigned int cmd, pid_t pid, e= num pid_type type, struct pid *grp; int err =3D 0; =20 - if (!static_branch_likely(&sched_smt_present)) + if (!sched_smt_active()) return -ENODEV; =20 BUILD_BUG_ON(PR_SCHED_CORE_SCOPE_THREAD !=3D PIDTYPE_PID); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index c0d66a10d01e..3e51b30ae7de 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2276,7 +2276,7 @@ numa_type numa_classify(unsigned int imbalance_pct, 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) || + if (!sched_smt_active() || idle_core >=3D 0 || !test_idle_cores(cpu)) return idle_core; =20 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index e476623a0c2a..ffe77b2b6296 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1671,7 +1671,7 @@ extern void __update_idle_core(struct rq *rq); =20 static inline void update_idle_core(struct rq *rq) { - if (static_branch_unlikely(&sched_smt_present)) + if (sched_smt_active()) __update_idle_core(rq); } =20 --=20 2.47.3