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 3780F43D4FD for ; Tue, 4 Aug 2026 15:19:43 +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=1785856784; cv=none; b=n0XvR24SuAMNZFHNx6Iu46yd1AxjwUkJasCVDCPNpmM1n6OR+WS/IVv6eM39aBf3GmC2IdZIjAFHfGF50y1gN7RnoTiJoKQkztD2gKarSMh4gp5VfLSQcganfL6vJWzXjtUzEckWHULlfOii0lPM1ci7JR+9JT5TgD3yxvWQGPM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785856784; c=relaxed/simple; bh=/n6MmQF3Tgbe1gUY7QBqDADgxy/TEYFWCE3Vgn3FrNk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=E/fbvjhpfxtkJY8XXvjgr5guZNd7PJesSD3UM6kbVH/zz65vk2POArBjW1FxMzxpfyNRIxyWwKF+5FdNPyTkRwrI7gQJYArchFYPMl5dOJsPf/ZKqdIq7lq3JSXefkS0Wkbkgm7syLBIz+PPmx7+aB4rLo1hltmCDoPm8ws5ipE= 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=oQVoF5NE; 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="oQVoF5NE" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 674ClxXa894654; Tue, 4 Aug 2026 15:19:11 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=8Ph0oF bc0N+saxE9kae+fQ3aSzBver/HGnVWsoYIXHU=; b=oQVoF5NENgxwS/KQFDayOJ ADPsW221uZd5y1vhx5hpA3Gx1IEBnldEdLHvYA0WunA215/P9+eVTUW0KkFUzrvN 8t+j9/B2Boi2+d9MxLdDBk0athmI31YDZYAPlz/idhf6y8aH9b/fl2w49c3d+zno yQMA8b4h2Ur9co3lCHQkigjsMFlyNq4yuu3OR2tzdomi5n/D5S6OZU0Gynr7L7MA SIzLoyxsS5nR+hSt7bOKWdK6ptJQOO6LR87ajP5maVGPrRTl9R6jNMLV2n/Z57yu C/DgzsFFxkAOmVYwlFLAv8/80ls+EaTB/ygx63INZpGjtv53zfLr03OVisGrzSEw == Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4fs8h4xh8a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Aug 2026 15:19:10 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 674FBNYL013394; Tue, 4 Aug 2026 15:19:09 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4fsugw2ka7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Aug 2026 15:19:09 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 674FJ7Ra52888042 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 4 Aug 2026 15:19:07 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0DEB820043; Tue, 4 Aug 2026 15:19:07 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 281D32004B; Tue, 4 Aug 2026 15:19:03 +0000 (GMT) Received: from [9.39.27.209] (unknown [9.39.27.209]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 4 Aug 2026 15:19:02 +0000 (GMT) Message-ID: <92dae374-14ec-4acb-b451-7ac81d9d262b@linux.ibm.com> Date: Tue, 4 Aug 2026 20:49:01 +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] sched/fair: Prefer fully idle cores for NOHZ balancing To: Andrea Righi , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot Cc: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Christian Loehle , Phil Auld , Mete Durlu , linux-kernel@vger.kernel.org References: <20260804151324.918020-1-arighi@nvidia.com> Content-Language: en-US From: Shrikanth Hegde In-Reply-To: <20260804151324.918020-1-arighi@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: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ut3YA:10 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-ORIG-GUID: sdtco9u2tvVPu6eheK6DoJ2fDYROwUrc X-Proofpoint-GUID: 0DkrapJnD3WXOA1Uj3dhTdlr3lnGdgkO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-04_03,2026-08-03_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 suspectscore=0 impostorscore=0 spamscore=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608040123 Hi Andrea, On 8/4/26 8:43 PM, Andrea Righi wrote: > find_new_ilb() selects the first idle housekeeping CPU without > considering whether another thread is running on the same physical core. > On an SMT system, the idle load balancer can therefore activate both > siblings even when another housekeeping CPU has an entirely idle core. > > On most SMT systems, this is not problematic because the idle load > balancer is a short-lived activity and the transient wakeup of a sibling > has negligible performance impact. > > However, this can be particularly costly on NVIDIA Olympus cores used in > Vera. Briefly activating an otherwise idle sibling can reduce the > performance available to the other sibling and this effect does not > necessarily end once the activated sibling becomes idle: after the ILB > finishes and its CPU enters WFI, full single-thread performance is > restored only after the sibling has remained idle for a qualification > interval (10 Ki cycles on the tested Vera system). Repeated short > sibling wakeups can therefore sustain the interference even with little > actual overlap. Is this hardware cost has been accounted in things like cpufreq or cpuidle? or have you set it already to max performance. > > Prevent this by preferring an idle housekeeping CPU whose entire SMT > core is idle. Retain the first idle CPU as a fallback when no fully idle > core is available, so NOHZ balancing continues to make forward progress. > Once a partially busy core has been examined, skip its remaining SMT > siblings to avoid repeating the core-idle check on wide SMT systems. > Just Curious, making nohz_full= yeilds similar numbers? > Tests performed using an ad hoc GEMM benchmark running one CPU-intensive > task per SMT core within its CPU affinity mask improved from > approximately 6.2 TFLOP/s to 9.4 TFLOP/s. > > Note that this preference may wake a fully idle physical core instead of > using an idle sibling of an active core, potentially increasing ILB > wakeup latency or energy consumption on some architectures. It may also > scan additional CPUs before selecting the one to run the ILB. The > selection falls back to the first idle CPU when no fully idle SMT core > is available. Non-SMT systems continue to select the first idle > housekeeping CPU. > > Cc: Vincent Guittot > Cc: K Prateek Nayak > Cc: Shrikanth Hegde > Signed-off-by: Andrea Righi > Reviewed-by: Mete Durlu > --- > Changes in v4: > - Remove redundant this_cpu check (Prateek Nayak, Vincent Guittot) > - Link to v3: https://lore.kernel.org/all/20260731191957.3199642-1-arighi@nvidia.com/ > > Changes in v3: > - After finding an idle fallback, skip all siblings when a busy CPU is > encountered, avoiding per-CPU traversal of known-busy cores (Mete Durlu) > - Link to v2: https://lore.kernel.org/all/20260729163225.1987068-1-arighi@nvidia.com/ > > Changes in v2: > - Avoid repeated is_core_idle() checks on wide SMT systems by pruning > the remaining siblings of a partially busy core (Prateek Nayak) > - Link to v1: https://lore.kernel.org/r/20260728214442.1648483-1-arighi@nvidia.com/ > > kernel/sched/fair.c | 55 ++++++++++++++++++++++++++++++++++++--------- > 1 file changed, 44 insertions(+), 11 deletions(-) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 37001c63452e5..9a975a684b487 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -13964,29 +13964,62 @@ static inline int on_null_domain(struct rq *rq) > */ > static inline int find_new_ilb(void) > { > - int this_cpu = smp_processor_id(); > - const struct cpumask *hk_mask; > - int ilb_cpu; > + struct cpumask *ilb_cpus; > + int ilb_cpu, fallback = -1; > + > + lockdep_assert_irqs_disabled(); > + > + /* > + * Reuse the per-CPU select_rq_mask, which is protected from concurrent > + * use on this CPU by having interrupts disabled. > + */ > + ilb_cpus = this_cpu_cpumask_var_ptr(select_rq_mask); > + cpumask_and(ilb_cpus, nohz.idle_cpus_mask, > + housekeeping_cpumask(HK_TYPE_KERNEL_NOISE)); > + > + for_each_cpu(ilb_cpu, ilb_cpus) { > + if (!idle_cpu(ilb_cpu)) { > + /* > + * Once an idle fallback exists, a busy CPU proves that > + * this core cannot be fully idle. Skip its siblings. > + */ > + if (sched_smt_active() && fallback >= 0) > + cpumask_andnot(ilb_cpus, ilb_cpus, cpu_smt_mask(ilb_cpu)); > + continue; > + } > > - hk_mask = housekeeping_cpumask(HK_TYPE_KERNEL_NOISE); > + /* > + * Running the idle load balancer on an idle sibling of a busy > + * SMT core can reduce the capacity available to its sibling. Prefer > + * a CPU whose entire core is idle, but retain the first idle CPU as > + * a fallback so idle balancing can still make progress when no fully > + * idle core exists. > + */ > + if (sched_smt_active() && !is_core_idle(ilb_cpu)) { > + if (fallback < 0) > + fallback = ilb_cpu; > > - for_each_cpu_and(ilb_cpu, nohz.idle_cpus_mask, hk_mask) { > - if (ilb_cpu == this_cpu) > + /* > + * The core is not idle, so there is no need to check > + * any of its other SMT siblings. > + */ > + cpumask_andnot(ilb_cpus, ilb_cpus, > + cpu_smt_mask(ilb_cpu)); > continue; > + } > > - if (idle_cpu(ilb_cpu)) > - return ilb_cpu; > + return ilb_cpu; > } > > - return -1; > + return fallback; > } > > /* > * Kick a CPU to do the NOHZ balancing, if it is time for it, via a cross-CPU > * SMP function call (IPI). > * > - * We pick the first idle CPU in the HK_TYPE_KERNEL_NOISE housekeeping set > - * (if there is one). > + * Prefer a CPU on a fully idle core in the HK_TYPE_KERNEL_NOISE housekeeping > + * set. Fall back to the first idle CPU when no fully idle core exists. > */ > static void kick_ilb(unsigned int flags) > {