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 1F7BD31A05E for ; Fri, 20 Mar 2026 09:20:22 +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=1773998424; cv=none; b=oxJRdZg1wHbG3bftNXMDKPiVH02ZgGEtP0ychULJjXpmY+Tlb9Q0+sDKsPhON+acM6u9k2zylcGx/bOgHfUpgkrkEjAYPigAtEfgnpksrXm3SAo3h401wloVro/xE37IwT/nZQyS9ZODK6kkkzviGC2sToxiLfRxmFBgz5oQWyI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773998424; c=relaxed/simple; bh=gNxiCGbv8Mld1DX3hMhkzMyRU20BDfnu6OASUyF1HTI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=J+C+ee7iJQqujJaCGb5oBJpc/eNsGeexyPbJEFKkSJjYT/ocYe4+HWElAFg1TW4oGyO98YbluhEDRUcIYdE/hJ5jl7Woc+pQzvogFJs9jy9F8/c58jMYwXeI3N+hjSJ45xTQu3GiTSeIlfgO53HmO9daSUjjw6c2xt45RKE5swI= 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=S2ronGzy; 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="S2ronGzy" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62K6cxvo1866748; Fri, 20 Mar 2026 09:19:37 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=TveYec Knnk7aqUiwlip15W4iy3VFSXaCd92rbyp0D1g=; b=S2ronGzyPEDc8576krHTws BNNKcyf8mLbolS/xXuj4bosF3u2Y6q13eerR9lfMmwXOZ8AdYR2t0LAzQ5Vxc6vA spqEdI+eo1u/0BIA3kF92wFjjFn+XMcm4V0PopRvYfgEJXFtYF48piYVQFE7usKv YqrM/Xb5uaCqK4e8yo6CkuqvM4OblTG8I3BnghlUM6clxwb5WjfCF4xPoIm3RAd3 P3tLGXU5u7nKE1l2pPx5jmkeKqhpe6j9hpt1rpKY+L2JNKSeCx9uQph++xQAlEP0 +e6VzHZ4t79urshXwyz5YTumEzeBhn+725guvCM5JpkUlA9KiEFrgoNV8vsQWP0w == 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 4cvy6531ma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Mar 2026 09:19:36 +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 62K7ZSF2028713; Fri, 20 Mar 2026 09:19:35 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4cwkgkpht6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Mar 2026 09:19:35 +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 62K9JX2f29950564 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 20 Mar 2026 09:19:33 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7BAEC2004F; Fri, 20 Mar 2026 09:19:33 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B00220043; Fri, 20 Mar 2026 09:19:31 +0000 (GMT) Received: from [9.39.23.72] (unknown [9.39.23.72]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 20 Mar 2026 09:19:30 +0000 (GMT) Message-ID: Date: Fri, 20 Mar 2026 14:49:30 +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 1/2] sched/fair: consider hk_mask early in triggering ilb To: K Prateek Nayak , mingo@kernel.org, peterz@infradead.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org Cc: juri.lelli@redhat.com, vschneid@redhat.com, tglx@linutronix.de, dietmar.eggemann@arm.com, frederic@kernel.org, longman@redhat.com References: <20260319065314.343932-1-sshegde@linux.ibm.com> <20260319065314.343932-2-sshegde@linux.ibm.com> <6f78a46d-9f12-4e42-ae9b-17f3543136e7@amd.com> From: Shrikanth Hegde Content-Language: en-US In-Reply-To: <6f78a46d-9f12-4e42-ae9b-17f3543136e7@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 5PukCzRrSRO6INtFuWku3otfH0-t9ujx X-Proofpoint-GUID: 5PukCzRrSRO6INtFuWku3otfH0-t9ujx X-Authority-Analysis: v=2.4 cv=KYnfcAYD c=1 sm=1 tr=0 ts=69bd1128 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=khkihPzDl6IAYyBmt9AA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIwMDA3MCBTYWx0ZWRfX13gt+6wwG1UY YWNGQIhVyznStct45E94PbZbAp5LblSu3FML7UquCAh/pcPgAOVcV7sY1SP0l+5BFNwBc0wqyqB YgSfImOjO4XxHgM0DXl6BIyk5V7fh2sF+VWKeiWsR25E2xKhoAi+WdMca9gkq6V8YTix178hPqZ Kpsd1SOfJNXagzvzOGoXd/2WzWST54HOfyVKup6HblGKvzlxNCQtnc526OlnG6UW7d4YPiSQkcG +cJPHOMytiYj8Ce/LCmF2vNLkOjLoJ4zHtHLgEY6fzM56VJCpLmIwS7EYKS94rq4yhTfCw/FPmj MjQa5tRb61COZ+l4YECypFhBlU3RMAXEa8AnS0/IpJ0xKKFJa0uhGmrFKx89injqowqA2km83HI C0bTjFxez/ShE3qCweEMd4lOPDmd9h9RWNEPql9VdBqaUrJeFp2GMumHsqj9TOar95/S6r+Q3R1 GaVgaugGANY0DcJkmaA== 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-03-20_01,2026-03-19_05,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 bulkscore=0 spamscore=0 impostorscore=0 malwarescore=0 adultscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603200070 On 3/20/26 9:07 AM, K Prateek Nayak wrote: > Hello Shrikanth, > > On 3/19/2026 12:23 PM, Shrikanth Hegde wrote: >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> index b19aeaa51ebc..02cca2c7a98d 100644 >> --- a/kernel/sched/fair.c >> +++ b/kernel/sched/fair.c >> @@ -7392,6 +7392,7 @@ static inline unsigned int cfs_h_nr_delayed(struct rq *rq) >> static DEFINE_PER_CPU(cpumask_var_t, load_balance_mask); >> static DEFINE_PER_CPU(cpumask_var_t, select_rq_mask); >> static DEFINE_PER_CPU(cpumask_var_t, should_we_balance_tmpmask); >> +static DEFINE_PER_CPU(cpumask_var_t, kick_ilb_tmpmask); > > nit. We can rename and reuse select_rq_mask. Wakeups happen with IRQs > disabled and kick happens from the hrtimer handler so it should be safe > to reuse that and save some space. > > Thoughts? May be. but it could be a confusing name. sched_tmpmask? We could similar stuff already to load_balance_mask, select_rq_mask. So, i would prefer to keep it separate. > > [..snip..] > >> @@ -12715,27 +12716,41 @@ static void nohz_balancer_kick(struct rq *rq) >> */ >> nohz_balance_exit_idle(rq); >> >> + /* ILB considers only HK_TYPE_KERNEL_NOISE housekeeping CPUs */ >> + >> if (READ_ONCE(nohz.has_blocked_load) && >> - time_after(now, READ_ONCE(nohz.next_blocked))) >> + time_after(now, READ_ONCE(nohz.next_blocked))) { >> flags = NOHZ_STATS_KICK; >> + cpumask_and(ilb_cpus, nohz.idle_cpus_mask, >> + housekeeping_cpumask(HK_TYPE_KERNEL_NOISE)); >> + } >> >> /* >> - * Most of the time system is not 100% busy. i.e nohz.nr_cpus > 0 >> - * Skip the read if time is not due. >> + * Most of the time system is not 100% busy. i.e there are idle >> + * housekeeping CPUs. >> + * >> + * So, Skip the reading idle_cpus_mask if time is not due. >> * >> * If none are in tickless mode, there maybe a narrow window >> * (28 jiffies, HZ=1000) where flags maybe set and kick_ilb called. >> * But idle load balancing is not done as find_new_ilb fails. >> - * That's very rare. So read nohz.nr_cpus only if time is due. >> + * That's very rare. So check (idle_cpus_mask & HK_TYPE_KERNEL_NOISE) >> + * only if time is due. >> + * >> */ >> if (time_before(now, nohz.next_balance)) >> goto out; >> >> + /* Avoid the double computation */ >> + if (flags != NOHZ_STATS_KICK) >> + cpumask_and(ilb_cpus, nohz.idle_cpus_mask, >> + housekeeping_cpumask(HK_TYPE_KERNEL_NOISE)); >> + >> /* >> * None are in tickless mode and hence no need for NOHZ idle load >> * balancing >> */ >> - if (unlikely(cpumask_empty(nohz.idle_cpus_mask))) >> + if (unlikely(cpumask_empty(ilb_cpus))) >> return; > > We can just use the return value from the previous cpumask_and() for > this and save on another cpumask iteration. > Makes sense. Will do. >> >> if (rq->nr_running >= 2) {