From nobody Fri Jun 12 17:16:04 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 C5FD43F4137 for ; Wed, 13 May 2026 13:40:17 +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=1778679619; cv=none; b=U9D5mfkIbyFCE1OMVqBUoo9m/cT915xSRqXVyyhEHIPqGqUTAb7dmnD9fN0i8Q246r5jWxsKnVavF7yLSFvHQmCBbQYUAqJXgNCxIm9AWfdbcG4BVakbJmTwAcCJrn+Mtuw9E6Rql0uqDZGnDel++WBrNU4Lwhs3rM5j2xkYE18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778679619; c=relaxed/simple; bh=PirMdWZzw9r1QNob6l/JhO/g1/vJ+7Xm2zmQ9GUw8E0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i3ZbCnMmP24BlSjeyu4eCnWFhR+l8Y1pk/WDFjtOw5LdzlPU1nXGJp/EU9IYegjivDDkRVuEKX8CNsT/IA+pEdsf90X9qPuLkhFS78sSajBwNR0EzaI9wyyuCshS7rEsPRxaV1He3gZcTqrfhEiCxY6zh2Mx4kpcmZk3KLok+io= 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=SBxEchft; 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="SBxEchft" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64CMxHJA3070217; Wed, 13 May 2026 13:39:50 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=SBxEchftO8mp+YY2QcI2DsBtQh5S/431p DqGxOaibCe4Y8Ikangi2Ezk9XSFKdACH8EKEUCzXytwjUrsttefeBu6tLmb0sUd5 1oo+rYhcQshHZL2O9yQ8hXLL9nJDhI4WvDUP5ya8B1KSOk9OnrRwPhNFu96rCEzb usZBRvKPWND2wCaWnDJmALkfJ2VnLjXv1ENkQla15NKvHHORQ8YXLiiPoiXIWc31 RmAoz5xuZBBSAbmetYK9l48hR/xytUFdZ0R6nIp3+1Rr5CBe4zfUUf9VMdTkQaxX 5MyohtlJfmlFqre5W1onfaNIN561uKjsR8Z0IYqTNbexXc6Tf00uw== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e3nv6qk55-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 13:39:49 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64DDdRnQ017940; Wed, 13 May 2026 13:39:48 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgqymx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 13:39:48 +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 64DDdkQ830081748 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 May 2026 13:39:46 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9236D20043; Wed, 13 May 2026 13:39:46 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B47620040; Wed, 13 May 2026 13:39:43 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.39.28.2]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 May 2026 13:39:42 +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 v3 1/4] topology: Introduce cpu_smt_mask for CONFIG_SCHED_SMT=n Date: Wed, 13 May 2026 19:09:31 +0530 Message-ID: <20260513133934.380347-2-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260513133934.380347-1-sshegde@linux.ibm.com> References: <20260513133934.380347-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-Authority-Analysis: v=2.4 cv=KbvidwYD c=1 sm=1 tr=0 ts=6a047f25 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=zd2uoN0lAAAA:8 a=20KFwNOVAAAA:8 a=VnNF1IyMAAAA:8 a=I-H8Kolf9V4x88b-nqcA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTEzMDE0MCBTYWx0ZWRfX7e9E5vIVZkFW fRcjAUAIebX6N80RSl6q+nVUozWLOuk8jelOfp4Koe+Cw+tCzykuZKkX15602WsVChU6ZjEHjnS VDPy/fPlarSapGToIuGPxfamRMa9MQetjCnE3Zrq7eOeQOJTN4Fb4sa2LcDqizhYPpaRcQNMI8A vRkYg+6MIXuPQQ4Atun5OoJcSm4YwonO7GcX1x/1Pfy+WeVhOtitv3hRsmSfH8JRGsxTCTEGoji cmqCCzSuwmabRxxeqKqbyIHx2QR2TxuROFOgjRHkWTOw6vXwadMl+qrAV+o3Ias2R19nsWvapcI GClRoHAaVFNecQGOCx38LZnf2h+umudDzSfDVk0WhNDV+6f9uPqpfaf2dm1w0igdcrnJ2J0tO2E RxE9IouSShy2TWeZwCvClfo8Lyrtf3A5QZJG0gFoK0yGTttNvOTpU1WGVNgPRMEUCpdoB75h58Q S8NllRZO081T4wk08lA== X-Proofpoint-GUID: JM-7PXmDq6_mWyo5RR4Aea2PV5owPRvB X-Proofpoint-ORIG-GUID: xmoPCkUKbquC5yGsra8SWK8ku-mn76yE 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-13_01,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 spamscore=0 suspectscore=0 clxscore=1015 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605130140 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 Fri Jun 12 17:16:04 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 F16632F6562 for ; Wed, 13 May 2026 13:40:23 +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=1778679625; cv=none; b=VGrh2ijjgO641xOrQxro5QC2bjm2xNGjvg1kGcbjLZ30ajr+1Gm435ThG2dpW83KsRAjPbJJPVN4dFnYkoGRHgN29sUTG8E2KNJYorcpsm1CxpufrWeioaB+6EML6FzC8e7NXJ4EERaK3HBRZOAJgurvJjMxb6cT89iatW6Yz18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778679625; c=relaxed/simple; bh=x5wzeM2ZrKS9z1X0OXbeh04bSE4XPbukQOglb32mkbg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SqvcEsYAWnBd4xorQmfkMtNRH4t5OSQrM4YJfspMxBL7nkR4ayytzH5LpOsNTf8bcE5tXNNzGyVPbRYtaFMWPa6VM9+fAj9NumtFxZu2ylBnaGu25dVFg6MwZqTkHYTakRzkT+B+t5YdJtOkJQ9mQak2J6nNRwv+WMnJU5QkuJU= 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=tYSV8S3V; 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="tYSV8S3V" 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 64D0AQdh3187517; Wed, 13 May 2026 13:39:54 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=7dzF4eFx4Vyr5G1LC MXVeJzoYHCHGJWoRk0PPBhIsRU=; b=tYSV8S3VwHTvGisMm5a+z1F1AX1YMfVoh 2vL393cOk0OU7PFMcQH7phMG8S52lW51XrrMMCvwR+xyxOARAF9UoFtOjVzcM961 DJDKxNelnpm4lmwk9VrbZULyHDghFoXjVxwSs+TMlubXAM9G+pgChGdS2TZsYR0J GPVeKmT9Be+kwIR97t1IIjY2ynsaNoZT4ANxcCfgtm/vN3lsStTp0OCpQv5VrNwz 5QxzjbStDpzq+T+hPohHuRcJh3XVBB8AE1b0UcWJ1Om+dOr6p8+nouBt90t/Imch 5jHki0yCmuYV/7LBbTMGc4Fml43pzkynuhJzD7/Jk8wEr2fR34YtQ== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e3nv5fyfe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 13:39:53 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64DDdOQp006099; Wed, 13 May 2026 13:39:52 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgqysy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 13:39:52 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64DDdoOV26608000 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 May 2026 13:39:50 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A96852004D; Wed, 13 May 2026 13:39:50 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F3F9420040; Wed, 13 May 2026 13:39:46 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.39.28.2]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 May 2026 13:39:46 +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 v3 2/4] sched: Simplify ifdeffery around cpu_smt_mask Date: Wed, 13 May 2026 19:09:32 +0530 Message-ID: <20260513133934.380347-3-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260513133934.380347-1-sshegde@linux.ibm.com> References: <20260513133934.380347-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-Authority-Analysis: v=2.4 cv=cPHQdFeN c=1 sm=1 tr=0 ts=6a047f29 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=zd2uoN0lAAAA:8 a=20KFwNOVAAAA:8 a=VwQbUJbxAAAA:8 a=VnNF1IyMAAAA:8 a=tYOOUy7Fey2-yfTBsNMA:9 X-Proofpoint-ORIG-GUID: gBTdiihUdrjuIX7Fdqs8rQY9FBUX0W3f X-Proofpoint-GUID: Q8xQN_Sgm9Gl6v7Ftn6H1nVKHPMASZYs X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTEzMDE0MCBTYWx0ZWRfX4xeyzC0IQXvW H9zSlxuJ7G/4I+Deyw5+zeQBuR7HzDwfHVvm8nUKjS5QFe6gKjGtCRo5oRiya784VwbSv64tgud DLBXtCoE8o9UNPWECx3v01XA0C5BmTTVgSK2E76HKNOiUgbGw2WTDM/e96pqyasFHYOoBaqTBYe hKhoTi2UP0Bd/p7/3iUmK+v2oIGrbnvnK7AhId6PO9jJ8/nh7NJUuINVjmkbHHx4D7MTL6BJ9kG pNqWfHvQEPBGlKQ2IWWTsa3IMgGOKbyvfAIL0aOSKd1J78g2yNgMzkTNDCEWRPPVEx+ql5jwls2 vtlqTZGlrxDs2ntInJo4SzXXtoxMkj40hlDY+GIYRBUOvmDdnu/6vB9bEB01qsThErog/FhA2FU xe/szuPNE7ynDjeLi8q5iqS/gAp3ZWQFjQ9J3cO0hQ5hM+UgXa8PvIhXNUJMA7utWU/oCEZQ6jw Ouqb/+smQPw6sifChCw== 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-13_01,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 phishscore=0 clxscore=1015 spamscore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605130140 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 3d2e3b2ec528..c911fdcb4428 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -8198,11 +8198,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 Fri Jun 12 17:16:04 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 D415E28DB49 for ; Wed, 13 May 2026 13:40:20 +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=1778679622; cv=none; b=HSIhZ/GCEdL9fmqa23eB8IDrqINNUQboaBweqY5zumLut6bD8D12e8WLkDlollrk151njg63TUKxOw2rBQR2IKcsKL8SYZWOTbNn/zhHx+O/KHxc7T0y3itb1gqLPS8nhhL2qP6AZX/WyE0MDOt/xoG2eACi3q/sQi99pToyL0I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778679622; c=relaxed/simple; bh=/Kd7TA+oM1KAjsWIFcOp0+kbshrg2g8i7orQ7X2qQYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=txTak+Mm4yQVUjEbFuGY5rO5f60i8W1CzFUGIEceBa9635OYDfQ+gkpLM9s3re792jbZIpl2WZlsI7DEgamSUMyQn2nMtZG1YvGaOjbxjTUoBZIuyY8qN5nuqsVY30ANFuD3mdByKnmo/OFdzxuvrYez+wcML9EyssmKFobQSD4= 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=aOYXyAGZ; 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="aOYXyAGZ" 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 64D1aRmq3179813; Wed, 13 May 2026 13:39:58 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=OVuwJJdqVrU01zlpD qZIhUYyihZ8typPZ2AC+gJdzeE=; b=aOYXyAGZ4LC4cySp3bMi7fzN2GdHu8E5c U7nOhHTWumaPOlOatgH8D2rgW5zkeu6dkQdGQe9b4FYx0tTgAqwYhTgFA7tMPucd fpxFGnmqEs6JHwHDXEpkulU4R23xNc10QBNWo+RotcZfLZpjUPv9Tlk+ucrRoKuD iYKwS0bZCweFgwn8xHm/dw+fcXlp3Hpjf6rdCFlf/BJ1eAn88QaWiqfuTGFNABWQ euHGWBwiwwkYgrycqmpdTLdSXBYaycdt/V7tAo16D1WuykKiLREDKjDDCh+vnbA5 mDo26IiOmk6D9oQjPMhn39w1tSNODbhHfJHfd+vaYV5e1Ak13hrEA== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e3nv6qk6r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 13:39:57 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64DDdtYj018896; Wed, 13 May 2026 13:39:56 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgqyn6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 13:39:56 +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 64DDds2K48103838 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 May 2026 13:39:54 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8E4EB20043; Wed, 13 May 2026 13:39:54 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1E13020040; Wed, 13 May 2026 13:39:51 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.39.28.2]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 May 2026 13:39:50 +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 v3 3/4] sched/fair: Add sched_smt_active check for fastpaths Date: Wed, 13 May 2026 19:09:33 +0530 Message-ID: <20260513133934.380347-4-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260513133934.380347-1-sshegde@linux.ibm.com> References: <20260513133934.380347-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-Authority-Analysis: v=2.4 cv=Us1T8ewB c=1 sm=1 tr=0 ts=6a047f2d cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==: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: 7Q9_bEvMHnnjNPruNxKpBljIzw18s1gm X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTEzMDE0MCBTYWx0ZWRfX3s7YGd6quMPH 5Chfku1twTphqVRxIu0ZivzDdiglz+9CWPIOW/LH5T04sU5s33WWcBoUgiox3gCt9y++N5hXwfy Hipp8/7WglQNjp5FPKFJOJcZea5xt0eLUIrCn9QICrjEFmITXHhN29MlKl1Eoiq6Lu0wdG6S5TO OPgdaWR8kvqB8A6KLjaS3frA8zHBSCHnq8CnG0unsigObrK3loEqrMqVAiRPBrQsS1keSFc9zkA YXMyTMgtHuUvoUh15zytGfdbjnfD2BA0jcK2Q61gCxM+9ccYqYD3cNdWO2NjSgNOmkgqeu+frCf iQwjyQZd3A/NA0b16255KzWMQyK95aZDVtpBDm26zSL2kBLMkUeAz9XF7Ee7hvvfnND5/5oEQJb 3rJUDZyM4Lund4Vfud3LK8M6hk868Dltdb56Qa2TwZKfybvfALiogfEE8qOM1+6c1sGxs19KuO5 y6Ogku/SseNiGLJT5bA== X-Proofpoint-ORIG-GUID: x3Okb7pp8xsn0IFwHvnVTK08UtZ2Agsr 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-13_01,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 spamscore=0 malwarescore=0 clxscore=1015 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605130140 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 --- kernel/sched/fair.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 353e31ecaadc..964014a74cf9 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,8 @@ 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 (!(env->sd->flags & SD_SHARE_CPUCAPACITY) && + sched_smt_active() && !is_core_idle(cpu)) { if (idle_smt =3D=3D -1) idle_smt =3D cpu; /* --=20 2.47.3 From nobody Fri Jun 12 17:16:04 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 B3B0F3019D9 for ; Wed, 13 May 2026 13:40:25 +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=1778679627; cv=none; b=BOtq5FztYkqcSpD3VxfE8u5TBaB4miromseShC5fHMubdHHJinArBl1oi50GOH8HGs6rFdxaYf5KvD2ek67BKV8yW7Utp69gJEXMItXItG877LA+Eheh4uXZUMvC5X5Y0lhrGtW34LHj5zbi2Ho6wvylccqqDCiIzFR2/YM1NTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778679627; c=relaxed/simple; bh=a6euAzk2wOdPTLK5q4EK6Xk4VqkwhJF/aXTR7LgHVlw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p7XOopjnD7H3JPIe+Wg34D2pqWgwnJa8OEU6qBZnJYCIsSPPjfy5kK6lwk/B8z+C7IdJDWh4YA+3Bw6QBe5EAspGqvTskrn9CzIm4i4H0Pp52mu+QQtmRDnh2F5S7NyT40aB7bpi/dsR3Ix7FzKhdjNWzvu/0i1n0RmVui4E1Y8= 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=DWVqTxQW; 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="DWVqTxQW" 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 64D317rG2760546; Wed, 13 May 2026 13:40:02 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=p1tKrLp3s4YP/A93h xpuf/oSSN4ggm8px/xnD1g7EVs=; b=DWVqTxQWhsIOU5ZoN+ZBOZz4gF1eBzoSN yaC56WSM110KGXaJlUshRdSYCjfOyFJiZWVQDfLYcysclVhtWY0QzKUvWRnBN2Q0 mMQ1SqwSdhtBDZZ9O1OZ39tZwXNXueSY+MrmUTDEaEVLoylyqVBiBlmhugTUrl/A YDOF3SFwtyLZwjYixlOOfFuxI8y9UFCjJEPKF0z+Ws+aqMe9nNo4r+nK2sGjKFzV c6l8j/PecGbIWI2OOts9kC9MpwjMe7oM4FcI4mZC6sSV4RYBkcvY5iRtIkRjXKwf SsQ/EWbtKkPqd05vTwkCIMJ1fRo38kCLcP1P6uXPOGFlX6UhBWvwg== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4e3nv6qkpv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 13:40:01 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 64DDdWdY006953; Wed, 13 May 2026 13:40:00 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgqyt4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 May 2026 13:40:00 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64DDdwre48824656 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 May 2026 13:39:58 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9373B20043; Wed, 13 May 2026 13:39:58 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F184820040; Wed, 13 May 2026 13:39:54 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.39.28.2]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 May 2026 13:39:54 +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 v3 4/4] sched: Unify SMT active check via sched_smt_active() Date: Wed, 13 May 2026 19:09:34 +0530 Message-ID: <20260513133934.380347-5-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260513133934.380347-1-sshegde@linux.ibm.com> References: <20260513133934.380347-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: T3v0DzPNRS2QLsHmSWdeNcYtI1iJrYV_ X-Proofpoint-GUID: vKd8w53cLGYsF4D4w96H7uwaQ6khPBMK X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTEzMDE0MCBTYWx0ZWRfX00xPjTWp9IXb 1cilHs/WTZutKWlM60RIoufhggyzWrY29BhPAfaVt74aX2c6DM8PKHlF7LdM4V7MQWOyCnS0j2s PyK9+mdwlJ0GGuRBjgZLxV0sAriZg9Ahy46VmVEnJnEWc3HrqoPnZya5W7CNVXkcBg/zIj0ANid k1oSuaNPvI0Dd3p3yqoB6pJbAB/TE6CuvSvyI9ux8O3sD/IVd0rDgkkpDEvn1cqyiHZ6toghAD/ Nrp8jfkNhSQiOVL8lD5/QjQWmATfUWXbWMedTdoyT4X0+QqiqxfxIYcThMipNcryub++XOQB5yr kza17bt/vkp3XEm376WOn9mVua+EKQsH9Nbd/pkfy4FdSfksYnd3iwLwrhKmIyIvxZ8eBOwfNwT I2LT4QTIRNgGhhTAqCS0Js9ZIizGaRfhJEMoFUn49uSyRXQyzhnxYlOWKR31yl+atr2tPmDA924 pHtQN/pqsMzGiQblW5A== X-Authority-Analysis: v=2.4 cv=P8UKQCAu c=1 sm=1 tr=0 ts=6a047f31 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=-Ed73FR7LBI_DYr6sKsA:9 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-13_01,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 phishscore=0 bulkscore=0 clxscore=1015 malwarescore=0 spamscore=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605050000 definitions=main-2605130140 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. Signed-off-by: Shrikanth Hegde Reviewed-by: Valentin Schneider --- 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 964014a74cf9..29fbb5287cfc 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