From mboxrd@z Thu Jan 1 00:00:00 1970 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: 8bit 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 Define cpu_smt_mask in case of CONFIG_SCHED_SMT=n 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=y. 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 -#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=n. 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 #ifndef topology_is_primary_thread -- 2.47.3