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 2B5303F871B for ; Fri, 15 May 2026 15:35:46 +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=1778859351; cv=none; b=XQiRkg04Q7PVT+e0pMDmIQ8ztvwfLOpvjZ2hL6tdcZ6t4IDFvUWjB2YDiS1PYitkVBfiKgtHIwZONmtDukSB+k1XOS1dvIk5bFu24ruqx1SxEWgF9PswrKsE65k9zhvt6jNqeHHoNC6cA/jGmK9JLMmGq7FpZdA1BKRxRi+T1+k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778859351; c=relaxed/simple; bh=gXhKLcq4QZj0Qd10s1vDzcwMPjf/GV+BVy5TeyXduxA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eVQikNjp25OZ0Dw/MP+YukYNLPT7ZD8Z/q/tTrIEA5ic86puXaHeHDiabffzIhWnvzn/c9rk+eEnpmqq4+3g7xLWjFtY6ZXoukInfAPr/KKAPKBsJKkLBacO3HCh5pfZfZJOwhTNKDvGu58nzVx4LoC4VHW4EOn0DaKGZJyA9F0= 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=AjkOEj/Z; 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="AjkOEj/Z" 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 64FF3L0F864281; Fri, 15 May 2026 15:35:14 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=ZRiMS7 7dtd3VESwbUR7isLu1z9v7aP0kRWnybSLZQrc=; b=AjkOEj/Za27+FskPsUEuhx S6IgaLgbWIzeFX4yhEDDUX9IlAr5OyD81N94kg+nNvyg6EqGimGc2gZN86h+Wi7j PYT526+8kfNHBGmD2ZxqPGHA4EOWksgchVLeGKrczN9EpETfiVmveTmqWMb+4Q3W ugfOJCdA1VQoAV5DEpH+uHV39vN1egTVXzqfhfM670Kb5JkpUBfNhi38y1Htu78p zkR5mEwn91NBlF6zWnQtlukjuogIgbCHkTdpf2gcJrGD8Jo14f9DlYNqNJzItigz OUa17pIzYhnrtwwrzmexvPPnjQqd9DeGGuVWMdo9+E/BYzr/pDVAPIYNQZLf3KlA == 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 4e5m8y3snb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 May 2026 15:35:13 +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 64FFOCsu012415; Fri, 15 May 2026 15:35:12 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4e5kvcc57t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 May 2026 15:35:12 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 64FFZAbm49742128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 May 2026 15:35:11 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D41112004B; Fri, 15 May 2026 15:35:10 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A96D520043; Fri, 15 May 2026 15:35:07 +0000 (GMT) Received: from [9.39.30.78] (unknown [9.39.30.78]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 15 May 2026 15:35:07 +0000 (GMT) Message-ID: Date: Fri, 15 May 2026 21:04:40 +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 v3 3/4] sched/fair: Add sched_smt_active check for fastpaths To: Valentin Schneider , kprateek.nayak@amd.com Cc: juri.lelli@redhat.com, dietmar.eggemann@arm.com, tj@kernel.org, rostedt@goodmis.org, mgorman@suse.de, bsegall@google.com, arighi@nvidia.com, pauld@redhat.com, mingo@kernel.org, peterz@infradead.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org References: <20260513133934.380347-1-sshegde@linux.ibm.com> <20260513133934.380347-4-sshegde@linux.ibm.com> From: Shrikanth Hegde Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: wTM6sd3KrbDhdcEeEzcPOdRV8oKxo4Gw X-Authority-Analysis: v=2.4 cv=RemgzVtv c=1 sm=1 tr=0 ts=6a073d32 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=zd2uoN0lAAAA:8 a=VnNF1IyMAAAA:8 a=UoyUfUpiTlBJPs34GZ4A:9 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: qXbdWDdrjgLa9cQxQgQC3iTTjOvrLGPY X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE1MDE1NCBTYWx0ZWRfX7nqIib88kH+M GzXOeRARzoLznzjdtf25SBaC2ykDBwlzz/LeurN1iH84yxsUDjeiSqF/FSyyzLO9f7pc9qC9fCU A6WSplQ5zMiB7NEKCqGzxghAqoyTJx8xu6ynygDp6RSRSXuJwjZTKCt4h13TpUElktQt86cb5+9 RUtZvs0pt2NKO7f91fuqtJcJKfEVDHiQp3vgZaG00s4guLynWCTAfZPHjseRI7C8bl3dcdMKAZQ HqgRP8OUekY/NM7SjFNWXtfC6G2oQ7jgdtQ0Y4bLuuDBWcDB0ufSZWr73h+iaCvt41YrrIjSJhN qKvhz5qLycq5MRo0mwOppp78ViH/mkD1Q8NSlnVuglCTWF1bAExsKJobX2cmx99oC0llOUtSOW5 wrfKbyLI4+ZMLFnl6uBBBO64/v87fKUvJKUDDh2APCADhFb5tIAwSCYKIDnt3BZJiYPge+GgeWY LL4z203F9qyp5emjcKA== 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_03,2026-05-15_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 adultscore=0 priorityscore=1501 bulkscore=0 phishscore=0 spamscore=0 impostorscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605150154 Hi Valentin. Thanks for going through the patches. On 5/15/26 7:05 PM, Valentin Schneider wrote: > On 13/05/26 19:09, Shrikanth Hegde wrote: >> For fastpaths such as wakeup and load balance even minimal code additions >> can add up. is_core_idle is accessed during load balance. >> >> Other callsites of is_core_idle make sched_smt_active() check first. >> Make the same check in should_we_balance. >> >> Rest of access to cpu_smt_mask isn't in fastpath. >> >> Note: Remove the stale comment above is_core_idle. Enqueue methods >> of fair aren't close to it anymore. >> >> Suggested-by: K Prateek Nayak >> Signed-off-by: Shrikanth Hegde >> --- >> kernel/sched/fair.c | 8 +++----- >> 1 file changed, 3 insertions(+), 5 deletions(-) >> >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> index 353e31ecaadc..964014a74cf9 100644 >> --- a/kernel/sched/fair.c >> +++ b/kernel/sched/fair.c >> @@ -1578,10 +1578,7 @@ update_stats_curr_start(struct cfs_rq *cfs_rq, struct sched_entity *se) >> se->exec_start = rq_clock_task(rq_of(cfs_rq)); >> } >> >> -/************************************************** >> - * Scheduling class queueing methods: >> - */ >> - >> +/* Check sched_smt_active before calling this to avoid overheads in fastpaths */ >> static inline bool is_core_idle(int cpu) >> { >> int sibling; >> @@ -11995,7 +11992,8 @@ static int should_we_balance(struct lb_env *env) >> * balancing cores, but remember the first idle SMT CPU for >> * later consideration. Find CPU on an idle core first. >> */ >> - if (!(env->sd->flags & SD_SHARE_CPUCAPACITY) && !is_core_idle(cpu)) { >> + if (!(env->sd->flags & SD_SHARE_CPUCAPACITY) && >> + sched_smt_active() && !is_core_idle(cpu)) { > > Nit: Since that whole if statement is about SMT, you could have the static > key be the first thing checked in the condition so it can short circuit > earlier. Ok. We can do that too. Only reason i had kept it that way was to avoid calling it when load balancing at SMT domain assuming sched_smt_active() is a more common in the field. I can send out v4 out quickly with below change. if (sched_smt_active() && !(env->sd->flags & SD_SHARE_CPUCAPACITY) && !is_core_idle(cpu)) { That's exactly what prateek had suggested.