From mboxrd@z Thu Jan 1 00:00:00 1970 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 EF8F83E1722 for ; Tue, 12 May 2026 15:22:00 +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=1778599322; cv=none; b=ClW8PWQ1N60dP/adeikzqDcqdezr087MA8mkCpUmtPPf4ywayQkqdRBTNgu4Gqhbv4nFFnlYgKLn7yPPwvaGU/+BTZsD9W1rkywmqLoQy1DNj7+d2544FdqWQH7oVsfp6jft7lyjQiXo0isDcjPylDnMWJl53Y/DE6zajYWKbhg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778599322; c=relaxed/simple; bh=49cwHBA2E3H25fArul/lFU1Q/1mXKjTmMv37/biGK5E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XqWRZImijiWOC5wbwyFTsyV+nqMk9/kImi5u3r69DqyZJ9yuWyZv+8Ze0cfw2L1U6nGki2oJChHKbE0wY3fjohtbs1PwQTuzT4zkfDCGZEC4nGqoQxHIp0SvvJBG0q0pivvPfODU4g9WqdDhWu9yugr4bsiNMSukfpkwgE/lDCo= 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=puH16gku; 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="puH16gku" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64CB9Vtq2608617; Tue, 12 May 2026 15:21:42 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=wbf43pekJOFLT4e4L vlNSuZLW0Y55ZLYEeHvS8mddLg=; b=puH16gkuLAo23VzFIW5JN4NRDGPYfl3Fp Yqxuhz1fKBPu89Yx5p6EOjUVRP1qmXZdVbXhqFeNgaeQlAjp3nr68G7MfFT5xrdS EexKikdi2ZdjuoTB5tSVcQX/ieNqFya10AVTMn7zECZuPcMAvmLP6JTYbEcMz9h1 vvh+Eigm1LG3sLfpfzPZZgtZISmJHh4Az9mAJ1XmWF6GBHjVcgJlmy2iSRo7GW3r G04c0rfWuQ2rss0LGlewY7bZpROpuzJWnozo1y6+KYgi+g5Fp+v3t/8ysKgPRY5I Kualb3h2yPyjVUYmqs383xB+prxcOJdFT6hx4oCLmpOMMmrw3CWUg== 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 4e3nv53qtw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 May 2026 15:21:41 +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 64CF9XKJ006015; Tue, 12 May 2026 15:21:41 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgkpe0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 May 2026 15:21:40 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64CFLdRG15008188 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 May 2026 15:21:39 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 519E120040; Tue, 12 May 2026 15:21:39 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E90B020043; Tue, 12 May 2026 15:21:35 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.39.28.106]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 12 May 2026 15:21:35 +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 Subject: [PATCH v2 1/3] topology: Introduce cpu_smt_mask for CONFIG_SCHED_SMT=n Date: Tue, 12 May 2026 20:51:23 +0530 Message-ID: <20260512152125.308280-2-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260512152125.308280-1-sshegde@linux.ibm.com> References: <20260512152125.308280-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-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTEyMDE1OCBTYWx0ZWRfXyJN4pzvzCQdc h2uKhAlYyehEG0is1AVqTphewt6ItPKHouB2orbeMuNnyspUISI9Wu/J8krLRV8buY1Fd7EWpgA D1WXtVVYAIT/kh0HT79DouyPcM/nGva/qKZpvV/KAEUc52jypHkcWMfMe4L70abPABsznrTfveg 2LTWOE2FrGGjXpSRLdvMrWs5sQoX+KbUusMN5mNIZML1zJn/QSljtwIHOh2iD/Re/nIu5M2l4TX xAyegyCRpKWhvDuKGDhUe7AraB6qTf+egPqajpyCY1HnCqqwYtlpHV2V7e+IXdaWHax5Gdo+82h YG5pW5dWZttatEt6lVaqqV9xEUpDkf82RF09n0BluNL3XxX/0QZaNVvlKKuBjOLjwrU0JNFMkSW TQwZERynwsHTKtbM0e7IpdFaV2cLuZ+wJ3BSaLCIPTGm2hC11u4JGePsvlOZb48wD6GVs8yI96G mfnvVYEo9rDHR2jsNSg== X-Proofpoint-ORIG-GUID: drBdAL_poBaT6HL_P8cX4kkmmMM_RA-B X-Authority-Analysis: v=2.4 cv=Jc6Ma0KV c=1 sm=1 tr=0 ts=6a034586 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=I-H8Kolf9V4x88b-nqcA:9 X-Proofpoint-GUID: IVWYDdDuK_9AiVQlqen7EyQg-67fy2BJ 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-11_05,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 clxscore=1015 phishscore=0 adultscore=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-2605120158 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 redefintion errors. 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