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 D3A0B33291F for ; Tue, 6 Jan 2026 15:58:12 +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=1767715094; cv=none; b=atCrgEaiPOART058HB4XT42kTCPdIKzyoBkj63Hotj8OWah/BtPWi43tw0hcqRlWe8uXkpLRvdGYySsgm3WR/xolt7jOmr/FHop1isrbwQ+cIB9QMPQzx1VAbnfpwZEhKhOLTQsKoMDZQ4C2HqLM8o6ceeIvxjRam3l5+weY15g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767715094; c=relaxed/simple; bh=kk3ogAMmn2/YFz1A5i+zxVMz+UvvbHhn55v8veptfpA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=GDBsFbmhqG+PlaahPhsV6OIbJteonztKm+lP2KOW90TnxS4Sf8ETu1aDGMfLrCm0tZJNu5L4rFdjJ29UmDfFalb8aMzoqVTQ2R8k7CczH2xTuB+t8Z5ke2u3tMLxAdcexIFUOtrWK5YzcI4l9jJuV/QsnAe/9HTYvJ+CyzXJWCs= 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=dgkgV1QE; 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="dgkgV1QE" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 606255hG017255; Tue, 6 Jan 2026 15:57:53 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=DdL/X1 l2LmE3A44XuK7oLSvIDvCdrA1RANT+i6kUV+Y=; b=dgkgV1QEmGhI39CBaSOwy6 kYpaZmrJ0gsFW+o3Oc5bagzm6OHzjrTXeBui722hwJJ571UQ9+DtZ038Y2w7k43Z R28QItu/J6L/HkowpKrZdSmdtp3PP+7vNtBCmJj1g4bfAGo44AWDb5lOUuwbey82 e3g+l6BaFH2KS58Y5Y/hXF1PrcHa/lG1OILRq6kaXhVqRpsKssZz827DJ05ZH4SQ F8okrXOmP2qwiXvThniquNNB8FLppjZMn6xCHAJbra4g4956tWhHfYVbobvsE7hF c5zi3sGOrV5+12kua8UQznovspzDSB3vCRZDjbuNPN0YPmOU7M8AnAZaBufpZLbg == 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 4betu64nm9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Jan 2026 15:57:53 +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 606FXLWh015202; Tue, 6 Jan 2026 15:57:52 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4bfdesccxd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Jan 2026 15:57:52 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 606FvodM39846388 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Jan 2026 15:57:50 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7FD242004B; Tue, 6 Jan 2026 15:57:50 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A190A20040; Tue, 6 Jan 2026 15:57:47 +0000 (GMT) Received: from [9.39.31.28] (unknown [9.39.31.28]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 6 Jan 2026 15:57:47 +0000 (GMT) Message-ID: Date: Tue, 6 Jan 2026 21:27:46 +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 v2 1/3] sched/fair: Move checking for nohz cpus after time check To: Peter Zijlstra Cc: mingo@kernel.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, kprateek.nayak@amd.com, juri.lelli@redhat.com, vschneid@redhat.com, tglx@linutronix.de, dietmar.eggemann@arm.com, anna-maria@linutronix.de, frederic@kernel.org, wangyang.guo@intel.com References: <20260102124744.360872-1-sshegde@linux.ibm.com> <20260102124744.360872-2-sshegde@linux.ibm.com> <20260106155010.GC3707837@noisy.programming.kicks-ass.net> Content-Language: en-US From: Shrikanth Hegde In-Reply-To: <20260106155010.GC3707837@noisy.programming.kicks-ass.net> 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=QbNrf8bv c=1 sm=1 tr=0 ts=695d3101 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=qDmT30rx5SGKxNbiLiQA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: 6QxqszF3ptpr3BzXeEN0PKDNj5ejfEgs X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTA2MDEzNyBTYWx0ZWRfX6we+OM2QOhXv k01yhWgVVDRTTwmcMUIN2q/xSUuaSLIyh99f0Zv1HrrYjXaUcouYlkREipNlViAzN9eVEusDqXD SGwnzGkCwDRl2kS7C+NDG1e/I/G6m3/0nAJP7LSsxeHei50W+FPixZX7q+f15BMjD3mYGX/KDi+ IQEkkqxzdwp2O2mUV9jliiRiKtAPQPDbkFyVQla9kYFfH29G3+SHZ6q9EqDIdphJxpndHjxBdeX bvpB0EmvwcwiZy5vqsSROH/pmIfbGTT6SqQeiQY4X92yJyM3pLYer/tr7nEsW38ORkVgTOpw+8e NIDQcY6jdZnetJ16foRj7xok0AtNwZlz7G96F3Z8ai4PHiGYqWF5+4uLmEGzdyAOFBYtSSYcBuI MzwUWvp662TCQ+XHG3VI0qFG0TEWJSQMKI93iIDGuDqBpxywfRwXRHB7ZQ2jWXAkmCw4Z0otyA+ 2aBZNTvwVF4wJ0jSYCg== X-Proofpoint-GUID: 6QxqszF3ptpr3BzXeEN0PKDNj5ejfEgs 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-06_01,2026-01-06_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 bulkscore=0 suspectscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2512120000 definitions=main-2601060137 Hi Peter. On 1/6/26 9:20 PM, Peter Zijlstra wrote: > On Fri, Jan 02, 2026 at 06:17:42PM +0530, Shrikanth Hegde wrote: >> Idle load balancer is kicked off only after time check. So move >> the atomic read after the time check to avoid the overhead. > > Presumably this is because the nr_cpus field is more contended than the > next_balance field; but aren't they in the same cacheline? That is, > *what* !??! Main reason for cacheline contention is nr_cpus in nohz struct. Other one is idle_cpus_mask, but that is in different cacheline itself(most of the time) This patch is not due to next_balance being contended. It is simply to check the value when we are sure time has passed to attempt NOHZ balance again. > >> If there are no nohz CPUs and next_blocked has passed, then there >> will be one additional stats based load balancing which would set the >> has_blocked_load to 0. It shouldn't make a difference. >> >> Signed-off-by: Shrikanth Hegde >> --- >> kernel/sched/fair.c | 14 +++++++------- >> 1 file changed, 7 insertions(+), 7 deletions(-) >> >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> index 7377f9117501..cd1c78d2c272 100644 >> --- a/kernel/sched/fair.c >> +++ b/kernel/sched/fair.c >> @@ -12447,13 +12447,6 @@ 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; >> @@ -12461,6 +12454,13 @@ static void nohz_balancer_kick(struct rq *rq) >> 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 >>