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 0822238734B for ; Tue, 13 Jan 2026 09:23:41 +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=1768296224; cv=none; b=NrmYJ9weKopIhYyk584iZkypgtG9dZQqKd0zl7GQMSKyRqdq7HGz3TSaW1TqID6n5A+ksoqQuotkZEjg4yWQlgQHQST633PrpA+9gnFnVKc5/p9H3CtAXl1XDVj1kX6aDyThVq9G8yXXhGvpXrpgY12l2rKYDBZQbtLr9G55Osk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768296224; c=relaxed/simple; bh=txaShkdt8Zn+8DkkHOA3SmDk2OfXqdtxSxjsFihXNa0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=BOUxgM2wjDOL8GEzoUkJuRNdPt9mJSU4kyFyYU8g37tm1MnytpAfpCtB2pqvdDFIHyEJUOqZ4oVvGPTg2KJmd9bBDTiy5SlB46J0ilxab9tBYRqa2b7ph5Tv8494h8sGawUHI2Zxzqdm96SQzxVlLSn+fU+CrYBQ5vXx7U/e6dE= 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=V0T7zFkf; 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="V0T7zFkf" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 60D4cvEw014465; Tue, 13 Jan 2026 09:23:12 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=u6tXeB r5MonRcfT/ah7n1jj7Up4BOul+tXwNQZnWZ8w=; b=V0T7zFkf3Z5XL/yZ2NKU1m SIPWT69N1Dnj8RCzLxaAHfkvy8OKBRoPATZUNpSZy0UQvar3aArhox4YO/1Ya738 iwnT5lIetMY9/P9BxbqGzk2akT9bf0El4sCwaCEsZNaHso//JBeTkKQ88o+J6mXL ohSQnIjvZvk+QGcDkGlxmV2cAUpcYYTEhAh/RIQz+Uw4/70a9n7VccCPfjN5TYkb GD/vbLD1KWb+82dQi8NEwSw5AGNIndddEqQpLJnSnl526tdp4mrzSD7txM9uC5w6 QC2W2H3wpNjAMLdEGoX0CfAMDFJaD8ZxrOA4DeTcuqpN14+M01aVO5VGGLMcGTdg == Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4bkeepum0p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jan 2026 09:23:12 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 60D7oFGq031255; Tue, 13 Jan 2026 09:23:11 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4bm3t1jvw0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jan 2026 09:23:11 +0000 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 60D9N9lW15466970 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Jan 2026 09:23:09 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4FC0A20040; Tue, 13 Jan 2026 09:23:09 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D36F420043; Tue, 13 Jan 2026 09:23:06 +0000 (GMT) Received: from [9.39.17.221] (unknown [9.39.17.221]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 13 Jan 2026 09:23:06 +0000 (GMT) Message-ID: Date: Tue, 13 Jan 2026 14:53:05 +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 v4 1/3] sched/fair: Move checking for nohz cpus after time check To: Vincent Guittot Cc: mingo@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, kprateek.nayak@amd.com, juri.lelli@redhat.com, vschneid@redhat.com, tglx@kernel.org, dietmar.eggemann@arm.com, anna-maria@linutronix.de, frederic@kernel.org, wangyang.guo@intel.com References: <20260112050442.138446-1-sshegde@linux.ibm.com> <20260112050442.138446-2-sshegde@linux.ibm.com> Content-Language: en-US From: Shrikanth Hegde In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=DI6CIiNb c=1 sm=1 tr=0 ts=69660f00 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=Nf5byIYXBADaGdIdASAA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: 4WZR2FBNOL_NaRDMZdFdgTBvlkmFLVPy X-Proofpoint-ORIG-GUID: 4WZR2FBNOL_NaRDMZdFdgTBvlkmFLVPy X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTEzMDA3NyBTYWx0ZWRfXy4LIbWaKoVkL OeVyC4FAefEi9vh+BmhfkuXPhW9/wIDVF4aY7MBOhfp84EEh8oL/wdk7eOTR9472BH76ZfDKp3S 47D7HoQrb1Idsd6G43E/TW8OvyFA+HZxfNma/VMXbh9rYIYEWOXApURQmaDR+2RHyP8bfPL3vHL ytir//46kwUasFBgDEebkvHOagLnJhIDG/UFVkDFeU+mdtQsB0/zwufV6BoYWLFtpFiLCsdbL2T ijBtpBI1kK4D+1iJOLirhJRKxIDvMeuwFAo+V/dVFEW6Vi+iRwOIBwR8bxmk6czUhc/reeGJyY4 1CYjCUV49ik2WzoH3ckGxFqOL6FfAUfsvhlyWFQk9xDJCQmKW3CFuuib0Fh5ejqjUoSteVKVy92 +qJ6JMb35HB6JXl6bzJZLBmp/98PQxulPnkSnexIrWOTDv7hLhDy//sMxUOlTOy/+5vF5YCYJqc MlkxFvjIbvP2yWVuEBQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2026-01-13_01,2026-01-09_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 adultscore=0 malwarescore=0 spamscore=0 suspectscore=0 phishscore=0 impostorscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2512120000 definitions=main-2601130077 On 1/13/26 2:37 PM, Vincent Guittot wrote: > On Mon, 12 Jan 2026 at 06:05, Shrikanth Hegde wrote: >> >> NOHZ idle load balancer is kicked off only after time check. So move >> the atomic read after the time check to access it only when needed. >> >> When there are no idle CPUs(100% busy), even if the flag gets set to >> NOHZ_STATS_KICK | NOHZ_NEXT_KICK, find_new_ilb will fail and >> there will be no NOHZ idle balance. The current behaviour is retained. >> >> Note: This patch doesn't solve any cacheline overheads. No improvement >> in performance apart from saving a few cycles of atomic_read. > > But won't these cycles be then wasted by calling needlessly kick_ilb > when there are nohz cpus, i.e nohz.nr_cpus > 0, there is no change in codeflow. Only when system is 100%(which is expected to be rare), nohz.nr_cpus == 0, then it is expected that has_blocked_load = 0. So flags shouldn't be set. Note we are still doing a return if nohz.nr_cpus == 0. So kick_ilb shouldn't be called. Do you see any path still calling kick_ilb un-necessarily? >> >> Signed-off-by: Shrikanth Hegde >> --- >> kernel/sched/fair.c | 18 +++++++++++------- >> 1 file changed, 11 insertions(+), 7 deletions(-) >> >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> index 9743fc0b225c..17e4e8ac5fca 100644 >> --- a/kernel/sched/fair.c >> +++ b/kernel/sched/fair.c >> @@ -12451,20 +12451,24 @@ static void nohz_balancer_kick(struct rq *rq) >> */ >> nohz_balance_exit_idle(rq); >> >> - /* >> - * None are in tickless mode and hence no need for NOHZ idle load >> - * balancing: >> - */ >> - if (likely(!atomic_read(&nohz.nr_cpus))) >> - return; >> - >> if (READ_ONCE(nohz.has_blocked_load) && >> time_after(now, READ_ONCE(nohz.next_blocked))) >> flags = NOHZ_STATS_KICK; >> >> + /* >> + * If none are in tickless mode, though flag maybe set, >> + * idle load balancing is not done as find_new_ilb fails >> + */ >> if (time_before(now, nohz.next_balance)) >> goto out; >> >> + /* >> + * None are in tickless mode and hence no need for NOHZ idle load >> + * balancing: >> + */ >> + if (likely(!atomic_read(&nohz.nr_cpus))) >> + return; >> + >> if (rq->nr_running >= 2) { >> flags = NOHZ_STATS_KICK | NOHZ_BALANCE_KICK; >> goto out; >> -- >> 2.47.3 >>