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 2A65445BD67 for ; Tue, 12 May 2026 10:13:47 +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=1778580829; cv=none; b=pfulc1rle8BYplPmCbmDCPLn/WVCCEf5Pw2T4ME7eSBD/czdGCnfGseCdAUftEpkUG0dvnVzEiuflbCKWrPQsaoxyyGdtQNAMWl/aQiT24y8yVka3jrQYKzgNrxD0hUh88j4Sc9iwWvQJ7bgBLoMiPVsS+trcdTnh4nJHC8phCc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778580829; c=relaxed/simple; bh=lx58fEW86iMuoAw2cJK3CXnp/asZgIXKH+lfa7vS/uM=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=eaDBiCyMOeXfTYUQDq9/vaDOH26OBuwKlLQIE3Z5WFobNw1hgGXiQ5T9akLZ26k1Zic9SqWbw7o4hfz3bWJyWWAfhkXTCcvVssnOUhdJzxCU591IJGrm1VtMumkxCqqvpJ012ITjnvE28B6KnKx0i9PWbcka4ntqBOgD/qqNsZo= 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=liTEp3ui; 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="liTEp3ui" 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 64BK7NGY3180036; Tue, 12 May 2026 10:13:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=Gs31i4 tAx0XT6ylPg8+dBjkkWerrnJqQ2XugTCJP+Pw=; b=liTEp3uiAHDxLDtIHbwkz2 jkOvPxWucNiVWsW76Jz0C0zsSCkWgQdO1KCImvZh3qDgcKNZQMG/E54tDns5dUnZ LveXUeli/Bj5Hu3DzBkFWXzs6MqtUd+Xq2ClcR/6zKmkao6Ef6e29gUeV6yzVnY1 Yl0J9TmiirOdj78AnQIpf6jd81o0Rl9t57ggdT3HJ2bh61B8bgnpLGh/CfiI5+8M wD/4ihqJjjxHZO+fXLTbcItvD8tNhOs0a1FVvDMR77k9QrQXt3wqf5VrlQdIiENA JMSKOLFYKzYc8bkb9dVzazsVuCoZNilJaJLqoGRqzTwF0RV/mPcSXqUo35+0QtCw == 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 4e3nv6jc51-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 May 2026 10:13:28 +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 64CA9Rpw007970; Tue, 12 May 2026 10:13:27 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4e3nfgjn5g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 May 2026 10:13:27 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64CADPvG30999226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 May 2026 10:13:25 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9EDA120071; Tue, 12 May 2026 10:13:25 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 720462006F; Tue, 12 May 2026 10:13:22 +0000 (GMT) Received: from [9.39.28.106] (unknown [9.39.28.106]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 12 May 2026 10:13:22 +0000 (GMT) Message-ID: Date: Tue, 12 May 2026 15:43:21 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] sched: Simplify ifdeffery around cpu_smt_mask From: Shrikanth Hegde To: Valentin Schneider Cc: kprateek.nayak@amd.com, juri.lelli@redhat.com, dietmar.eggemann@arm.com, tj@kernel.org, rostedt@goodmis.org, tglx@kernel.org, mgorman@suse.de, bsegall@google.com, arighi@nvidia.com, linux-kernel@vger.kernel.org, mingo@kernel.org, peterz@infradead.org, vincent.guittot@linaro.org References: <20260506110052.9974-1-sshegde@linux.ibm.com> <20260506110052.9974-3-sshegde@linux.ibm.com> <09edb32d-774a-4780-bb05-cb227f6cddb7@linux.ibm.com> Content-Language: en-US In-Reply-To: <09edb32d-774a-4780-bb05-cb227f6cddb7@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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=6a02fd48 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=HU13SzflhV-jFaKIzegA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: aBC1dPerQFYz57cqiust4LE7ZpogEMUG X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTEyMDEwMyBTYWx0ZWRfX6K16wUKWn9Rr 24zmhsOnK3Q/lUbP+LkENkVHnwZTYP/F5Ronq/9R9VpON2jHxenTbjyRGswz6UPvAaMqAWDPFY1 kPs5/Q17ouI5WbB2Df1+LyeOipPCFtZJtfnFdmiV8EAUDD58kMuKTmRWzjjWbW3XoF4O7FicJg9 GgmPic8YIPUyswl8jEaC/nslqTLSvLI5bJSU/nbl4h6jum4T7w7Yhdbcr8vcKpO6AvOQoI2OjP0 duZsXs6FoNuf08U2hEzWZfIiXXy2uS9/lpiGApoliu5bBXmJWLzNCV9XnrMze5h/O9LP3DBRFV+ scMC6ABxjA3qmmrfeykD9Vp+fNvdpSaobh0ARIEbnOBc257u2C5Pky0Ccs2adSeGbcGzXYx35Jb BVTe4BTzUOeTgNhfYmfLEIXCuYt5y3GXpBDnj6TVj2ErFItX5WyrSHLdmV0iLGXRTNocScFUlaB /FZKSnp1WOiE0XyC2ZA== X-Proofpoint-ORIG-GUID: uo_XOrGE2xWjzuhgdbqg78F5NgxDf0TB 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 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-2605120103 On 5/11/26 8:07 PM, Shrikanth Hegde wrote: > Hi Valentin, Thanks for the reviewing this patchset. > > On 5/11/26 6:23 PM, Valentin Schneider wrote: >> On 06/05/26 16:30, Shrikanth Hegde wrote: >>> Now, that cpu_smt_mask is defined as cpumask_of(cpu) for >>> CONFIG_SCHED_SMT=n, it is possible to get rid of the ifdeffery. >>> >>> Effectively, >>> - This makes sched_smt_present is defined always >>> >>> - cpumask_weight(cpumask_of(cpu)) == 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=n systems to use the same optimizations >>> within the >>>    LLC at wakeups. >>> >>> - This will expose sched_smt_present,stop_core_cpuslocked symbol for >>>    CONFIG_SCHED_SMT=n. Likely not a concern. >>> >>> - There a bloat of code CONFIG_SCHED_SMT=n. (NR_CPUS=2048) >>>    add/remove: 25/18 grow/shrink: 26/19 up/down: 6696/-3064 (3632) >>>    Total: Before=30771823, After=30775455, chg +0.01% >>> >>> - No code bloat for CONFIG_SCHED_SMT=y, which is expected. >>> >> >> Some nitpicks below, otherwise this LGTM except the sched_ext bits which >> I'm not familiar enough with. > > sched_ext just added the ifdefs for the masks i think. > It has sched_smt_active() already. > >> >>> @@ -8703,9 +8699,7 @@ int sched_cpu_deactivate(unsigned int cpu) >>>         */ >>>        sched_smt_present_dec(cpu); >>> >>> -#ifdef CONFIG_SCHED_SMT >>>        sched_core_cpu_deactivate(cpu); >>> -#endif >> >> That ends up grabbing @core_lock, arguably this is during hotplug but >> still >> seems a bit wasteful when, with CONFIG_SCHED_SMT=1, we know the mask >> weight >> will never exceed 1. Probably worth adding a sched_smt_active() check >> within the callee. >> > > Ok. Fair enough. Even cpu bringup path too could use the same opt. > Something like below? > --- > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 084ec3987d7c..add0fcc8ba90 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -6494,6 +6494,10 @@ static void sched_core_cpu_starting(unsigned int > cpu) >         struct rq *rq = cpu_rq(cpu), *core_rq = NULL; >         int t; > > +       /* No point in doing anything further if SMT is not active */ > +       if (!sched_smt_active()) > +               return; > + >         guard(core_lock)(&cpu); > >         WARN_ON_ONCE(rq->core != rq); > @@ -6533,6 +6537,10 @@ static void sched_core_cpu_deactivate(unsigned > int cpu) >         struct rq *rq = cpu_rq(cpu), *core_rq = NULL; >         int t; > > +       /* No point in doing anything further if SMT is not active */ > +       if (!sched_smt_active()) > +               return; > + >         guard(core_lock)(&cpu); > >         /* if we're the last man standing, nothing to do */ > > This isn't necessary. Both sched_core_cpu_starting/sched_core_cpu_deactivate bail out quickly when cpumask_weight(cpu_smt_mask) == 1. Given that it is not fastpath, I will skip the above diff.