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 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: 8bit 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 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