From nobody Mon Feb 9 00:25:40 2026 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 75A89E573 for ; Mon, 12 Jan 2026 05:05:34 +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=1768194335; cv=none; b=OsVU4qOEnzHDSy+gpx+bcV5ACCL6uicQ8urWFwSchjR4CeBneS9fbb1iW6wu8yxMB2W+6clvWcNBr+5b5QTd4CVejX84nXKFRiSZFS0cjk31lxS+9R0VTl5MH4GgE7AL0axUVdFyoURGnURhb9iwN+dU3CWXi+T7geeYIwCvx3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768194335; c=relaxed/simple; bh=+dwnAhz20tvtws6VvZ4x071mmwbZM4PcK4846f5pptg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZJE+DfV5DUT2DibDuk04mbRMhah8S1u632my5rZ5aVgd7/18Fo0jLWsSRV/iFxJx/f25Q9PrnMMFuUGyxqPZh6bX4ntgG7fsTRpRmEnhYFqlLsub9ouxC0lCiqbvVbjT5GLmn9HjpRbuQhHGHBB5FrW1+gy4Nx0A3J1gqEMfM3Y= 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=b8Up6STt; 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="b8Up6STt" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 60B6aY80008622; Mon, 12 Jan 2026 05:05:06 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=zs20oWepA0YSSIqFU xVO+9FieISgIhMvpPwXV44qxGs=; b=b8Up6STtc04xSspQSmeI88UCZgRMSA1mF ngm77DCzdV4XVa4u7Yo9KcjdlMBU0TJb9lVTQ+vcfc5v9uYEwZiq2ylFmzUoSnjb TBcCbG91uhcoBUkdLx45hGXSmgo3BsOGpk6JkIZ8ceJOM3BslrWVH5VF53N7oUDO TOAd3AIz+XvFI2SIQqJ2XTC34LhV6HUIcZI/de/Dp/LZ3/HH4+J9uxcVZA0yklpc b0UKj1yMPceGtC7OxYsZqjYaELfeI6Ng5EoxoRwI9xcqCs6vCfTslVbuJW9E9jGN Bi57veo7mFuwCpbBgUquV6M48Lob4/CaKRjysRuLD1m89EyNwVEjQ== 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 4bkd6dwd1u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Jan 2026 05:05:05 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 60C00TbH002505; Mon, 12 Jan 2026 05:05:04 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4bm13sccjx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Jan 2026 05:05:04 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 60C553NB45547864 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 12 Jan 2026 05:05:03 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1C9FE20043; Mon, 12 Jan 2026 05:05:03 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 23DAE20040; Mon, 12 Jan 2026 05:05:00 +0000 (GMT) Received: from li-7bb28a4c-2dab-11b2-a85c-887b5c60d769.in.ibm.com (unknown [9.109.215.252]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 12 Jan 2026 05:04:59 +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, tglx@kernel.org, dietmar.eggemann@arm.com, anna-maria@linutronix.de, frederic@kernel.org, wangyang.guo@intel.com Subject: [PATCH v4 1/3] sched/fair: Move checking for nohz cpus after time check Date: Mon, 12 Jan 2026 10:34:40 +0530 Message-ID: <20260112050442.138446-2-sshegde@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260112050442.138446-1-sshegde@linux.ibm.com> References: <20260112050442.138446-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: HA_J_0l-52HRtb113qyipzqkYjvDBMLj X-Authority-Analysis: v=2.4 cv=LLxrgZW9 c=1 sm=1 tr=0 ts=69648101 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=IMJbMpzTyqkz7RZfM9YA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTEyMDAzNyBTYWx0ZWRfXwan+6qqdmklS YpB5PL14kIgTOBI162c2sehOjE16ewQj/wy7PMSSqHOZFMdpGz4UA/X/QOabJFPGko7I6DbzxM5 iP3iTO3JE819L8dSgzG9oPJOPCzGdLtPijQB0Stwo6DSQw6cS8LpLfZDOlZSzMBedYN5+Y2R1G/ pqwXfzbdqn3PDXne3JBNNvPVYcKwTxZ6Scz7Zblr+TZuxGAh1X7xNwPNsQ85kaeiuPm/W9SAKNs QjneFq+LpH8bqwNftQ21x1eBT1TT9fzBbqPzvUZN4zv9o7MJIpNb+2xCAwY82rJSp/pSprK7u6c avtI7EXo/HGdpeXWITbvGLZ55GDqT/o6PJelCRyHtDxgc44YOYXsgp45lK9pqLKS5AFgXVy11jr rx9YMgCK6P9cpyoSwvDTFZcSfa4wofwG38+OlKS+bEHO3XH0MGNF0Cu+wr37K3UZTXOCussbAsb Hw9hupxwbNCVVq8RB9A== X-Proofpoint-ORIG-GUID: HA_J_0l-52HRtb113qyipzqkYjvDBMLj 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-12_01,2026-01-09_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 clxscore=1011 spamscore=0 impostorscore=0 malwarescore=0 phishscore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2512120000 definitions=main-2601120037 Content-Type: text/plain; charset="utf-8" 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. 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); =20 - /* - * 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 =3D NOHZ_STATS_KICK; =20 + /* + * 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; =20 + /* + * 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 >=3D 2) { flags =3D NOHZ_STATS_KICK | NOHZ_BALANCE_KICK; goto out; --=20 2.47.3