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 D7E8F39B974 for ; Wed, 6 May 2026 11:04:21 +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=1778065463; cv=none; b=js9TFOFk8f+Q41o5m4xD7mwkqMze69wtcX1sqsB+7ec7tDwCbHMXHmtAwztXbmA4yAUqITCLRxw6dLbWTRkVoBwcORPVW6M8cdwy1yfxBwEsQh/SH/gK/oR01z/V3eVVg/szUcSzWnbNmvxzGnGc6rUS87vO3cuXRkatBD9Nc64= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778065463; c=relaxed/simple; bh=HxLmoyADbdCRA3YAfufSDbeRO6zVs0LMO/FXVbFGatQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NKJq544qAsdzlNXUH63H0O6ULiBj/HyG1oNWVuwGrYIdO3lJbLPVQrivjxXSQKl+fz14BialIlfI6OVSUKNGmmcCVEockz3fbIPRovi8abK9Gnkj8EHMSOJWrlquKk4t5PyOxMkA8rf9x2BE5CvRqyJJ7rx4nPldA5LX65dVATY= 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=Yf+hAs36; 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="Yf+hAs36" 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 6463j393851433; Wed, 6 May 2026 11:01: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=xKXdsePvJaRWZbJlW GSfc86/vHca7q0x6D3U46UrZOw=; b=Yf+hAs363AUFXllNfZ5Qv1S74ANYEFsI3 GpG+joaHQ9DEn/8hHrNA5b4/QfVEInCpn08l9YZ7OrHqPSXBi2Hs63Sl2BDnH9Qy eT0ntf3iBfHGQJkdmmfSv4zY1SxpqB/89E5tv7JHgVfgAyJBzhIYrI0YiP0onz16 AYRm5qnMZfCo2KB8KlcrHlG2ldJBRnaDIsVs4bfcPhT6eOnonIBAtVFIV/1NLGQ0 m4WQg+Rst1aXn0Y6an5F5LNyI9SJZKg+itIIjDvoTijekUTqrYbN6K08q++LPexM TjZtVGYFg1KX4wR9j2ur3Vj6fPzxqehdxouof+7oXZ8kFIT+ASYOw== 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 4dw9y4qmy8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 May 2026 11:01:18 +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 646AsXNL027268; Wed, 6 May 2026 11:01:17 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4dwwtgdqbt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 May 2026 11:01:17 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 646B1FpH47120678 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 6 May 2026 11:01:15 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B131220043; Wed, 6 May 2026 11:01:15 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 695BA20040; Wed, 6 May 2026 11:01:10 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.ibm.com.com (unknown [9.124.208.93]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 6 May 2026 11:01:09 +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, tglx@kernel.org, mgorman@suse.de, bsegall@google.com, arighi@nvidia.com Subject: [PATCH 1/3] topology: Introduce cpu_smt_mask for CONFIG_SCHED_SMT=n Date: Wed, 6 May 2026 16:30:50 +0530 Message-ID: <20260506110052.9974-2-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260506110052.9974-1-sshegde@linux.ibm.com> References: <20260506110052.9974-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: AW1haW4tMjYwNTA2MDEwNCBTYWx0ZWRfX+LOZPf6Onqd3 9wkAjVozA954XYKSxmHAXtP3HKKWGVwsMqkjw27DQO2CxpvyAc5mMq2RePrdYKx88c9xYGF76P/ ccpN3uKM2Ij5tjXYSUm8hLsbXR8rUQc9A7DGW4KrUFDr83CYHjfLDT1txbxDdEo9Ac3hTMW/Bwo UH9sStYpbwSuRZpCnnVZP1GMrC/cnuReDZrPy+RajJz1waer5Q00PTfPBKn+cYZTSQYEe+Qk42L 7c7OAt5AJn8wY2nUqAf3VOv4/5FPE/BTod3iX69s1QjgNSd2Pmle/OspRSvvzfbc1a0AaDp8y0A bgQpttDrTla569GQH/NcIksqLXmoNn1zFWvl/JIV8izkDfpP1brKl7vQIQufe/qLp4cvkZIu22L h1dv4TyTfv19g1ojbu5w24mcSb0i/EPqQWcpz47+SMzy38xXAPHs7u2KChnYIpyRAVP3zxVViKD 4zUkBy0kRPMJ8Is4esA== X-Authority-Analysis: v=2.4 cv=J4GaKgnS c=1 sm=1 tr=0 ts=69fb1f7e 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=I-H8Kolf9V4x88b-nqcA:9 X-Proofpoint-GUID: KpQpTWn5R-XCkI5z4qngpXInO7MZvaAL X-Proofpoint-ORIG-GUID: 5_cHvvww2_k9B46xV9GsNQis-43Lu1H7 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-05_03,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 malwarescore=0 bulkscore=0 suspectscore=0 priorityscore=1501 spamscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605060104 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..3a36fd1066fe 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.51.0