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 D2DE42FD668 for ; Tue, 2 Dec 2025 06:56:48 +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=1764658610; cv=none; b=Miuri0WUQwupOCIM0unR7teR/e43Rwxf0IipZPOaFaXMDml2j5BmcY5jDTBNhrXr/Bb6yRB9ajHPsHZZ3LNe4Mgkka+dN+4iT7gqCLYkqRa1mv0mI303AJn2QZmz71DxzTfh1Hgv+Zrq5J/xiV/7PZKN2W1QJZbQP6h9HN7SFXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764658610; c=relaxed/simple; bh=dvR9RdBqa6hY/0gcG+n1m4A8PhcC80fgAAYoznl60+k=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ui2kbQVvfwe3KOZnqxGQhEvQk7Dtp1hdBJCF/wQRxnYDsn4qirEukcIAdWXpLRcrzf+Pdw0L+ayWCIz1kJKuF2Iguiemwet4XdPU5n+eT3QUELKk2X4KxXsRo5Nf/dFmBEth4ntjXmp+DkMwJiPPKDEeP0dRyqmbYzaYWEsWVCM= 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=MhgIV/2A; 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="MhgIV/2A" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5B1MNW7Y005729; Tue, 2 Dec 2025 06:55:59 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=2xDdk4 ivrcywTJVthC+gP5a16PoD5u8fIZ7+k+5JD9s=; b=MhgIV/2A/ia+XOHOKRb/of UG3p7Z6cIAT6UCV7dyudjhSxxencm4SHIoP053/VrxNSGf5B8e3K0y2ROKXx2dDv TTGlL+a5Bg0WsFP2B4b0s7Y1yZRcfAX2yMla0Xvd+3p+yESiDf4widxrugbp8pTR eZRrNMK3pTHUewWpK1XbLoIBh1SurfBrk0JfibPVzBxVJkzH5lDyUbrIZbrTP1Dl Ze7/4THKiseNg1DxGdiOona/3zUyZ3EzWr6yttvSSCplzvUuLL6HjL85MmteVNVA PG8JqG89fYOqC69yR3XozFBo4lEdoLoQeC0zXHgIUvCegz6OVpxHdbGeg3zHUSRA == Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4aqrbg3ksf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Dec 2025 06:55:59 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 5B23vFG4010237; Tue, 2 Dec 2025 06:55:58 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4arcnk2s1p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Dec 2025 06:55:58 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 5B26tu0j19857880 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 2 Dec 2025 06:55:56 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 175E620043; Tue, 2 Dec 2025 06:55:56 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 816D020040; Tue, 2 Dec 2025 06:55:53 +0000 (GMT) Received: from [9.124.220.253] (unknown [9.124.220.253]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 2 Dec 2025 06:55:53 +0000 (GMT) Message-ID: Date: Tue, 2 Dec 2025 12:25:52 +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 3/4] sched/fair: Check for blocked task after time check To: Ingo Molnar Cc: peterz@infradead.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, kprateek.nayak@amd.com, dietmar.eggemann@arm.com, vschneid@redhat.com, rostedt@goodmis.org, tglx@linutronix.de, tim.c.chen@linux.intel.com References: <20251201183146.74443-1-sshegde@linux.ibm.com> <20251201183146.74443-4-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-Proofpoint-ORIG-GUID: -7Ee6R2RfBGSgFs4CUIS1BtAwzZrE-mj X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTI5MDAxNiBTYWx0ZWRfX5Y7cXM4O0mVq ZKSrjnoo5i3nc9tUrzg/J9Wc2fO9StQYvXRzpIzXf3MQoWQMJbRQ9s28S9ne+tmZaGzz4gnBA5S 7UUlmamTd+kL+gQ6PC/5QatDz6Uk5DlzKgQ404zqGjzlWeFbRTv6yHceXr+UQl5/n57Px2fVO8a N1JQA3V59m+2ge2ni/pgL6s0TxigaQf6PSF8FihiCF0Ux3LLN4Eb8YavQAIajHSOrBJIz0WR8C6 MbdktMkUx+eRkh89jjCqNihxxMC6DNfyDn3UulnzJYIGf6yKxv1kcDHs0Uez6hG0znzluZE9Zz3 C7I1Ds9rndQ9jLlAkyjyPaerjfnB8Fm1yEyTGDJl8AcwKgRnjZz7kq4+p5C1tYhIq8d1veJi6Yr G1lggQJ35ZOkfPnryLRJI2SZpBS9Nw== X-Authority-Analysis: v=2.4 cv=UO7Q3Sfy c=1 sm=1 tr=0 ts=692e8d7f cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=F6u8y81iznkZqQGKmegA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: -7Ee6R2RfBGSgFs4CUIS1BtAwzZrE-mj 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=2025-11-28_08,2025-11-27_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 spamscore=0 phishscore=0 clxscore=1015 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510240000 definitions=main-2511290016 On 12/2/25 11:56 AM, Ingo Molnar wrote: > > * Shrikanth Hegde wrote: > >> nohz.has_blocked can be updated often as and when CPUs enter idle state. >> But stats are updated only at regular intervals. Usually fixed to >> LOAD_AVG_PERIOD=32. >> >> Read the value only after time check is successful to avoid cache >> references to it. >> >> Signed-off-by: Shrikanth Hegde >> --- >> kernel/sched/fair.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> index 55746274af06..5534822fd754 100644 >> --- a/kernel/sched/fair.c >> +++ b/kernel/sched/fair.c >> @@ -12440,8 +12440,8 @@ static void nohz_balancer_kick(struct rq *rq) >> */ >> nohz_balance_exit_idle(rq); >> >> - if (READ_ONCE(nohz.has_blocked) && >> - time_after(now, READ_ONCE(nohz.next_blocked))) >> + if (time_after(now, READ_ONCE(nohz.next_blocked)) && >> + READ_ONCE(nohz.has_blocked)) >> flags = NOHZ_STATS_KICK; > > So this patch makes no sense, as the two fields [1] and > [2] are almost next to each other: > > static struct { > cpumask_var_t idle_cpus_mask; // 0 > atomic_t nr_cpus; // 8 > int has_blocked; /* Idle CPUS has blocked load */ <========== [1] // 12 > int needs_update; /* Newly idle CPUs need their next_balance collated */ // 16 > unsigned long next_balance; /* in jiffy units */ // 24 > unsigned long next_blocked; /* Next update of blocked load in jiffies */ <========== [2] // 32 > } nohz ____cacheline_aligned; > > ... and thus they very likely share the same cacheline > and there can be no reduction in cacheline bouncing > from this change. > > In fact with OFFSTACK=y the cpumask_var_t is 8 bytes > and thus the offset of the two fields will be 12 and 32 > within the same 64-byte cacheline, guaranteed. I've > marked the field offsets in the rightmost column for > this case. > > Thanks, > > Ingo Ok. Since we fetch the line in either of the case, read should be minimal overhead. at best we maybe saving one read. Likely not worth it. I got a bit carried away. We can ignore this change.