Re: [PATCH v3] sched/fair: Prefer fully idle cores for NOHZ balancing

From: Mete Durlu

Date: Tue Aug 04 2026 - 08:49:17 EST


Hi,

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.

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.

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.

Although what you describe above with siblings suffering interference
does not really fit to s390, I'd like to hear more about what sort
of GEMM (general matrix multiplication) tests you did.

I tested this patch with a couple of different tools
- perf bench sched pipe
- hackbench
- uperf
- cyclictest
- stress-ng (3d-matrix and cyclic)

Didn't come across any meaningful difference in any of them on multiple
runs each. So I was curious about the exact sort of benchmark you
mention here.

One minor nit for the diff below;


diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 37001c63452e5..574b6b3ee922a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -13965,28 +13965,66 @@ 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();
- hk_mask = housekeeping_cpumask(HK_TYPE_KERNEL_NOISE);
+ /*
+ * 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_and(ilb_cpu, nohz.idle_cpus_mask, hk_mask) {
+ for_each_cpu(ilb_cpu, ilb_cpus) {
if (ilb_cpu == this_cpu)
continue;
- if (idle_cpu(ilb_cpu))
- return ilb_cpu;
+ 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));

nit;
With line break this if block is now taking multiple lines and deserves
its own curly braces.

With or without the nit, feel free to add my r-b to v4, I doubt removal
of the "this_cpu" check will change anything as it is a dud.

Reviewed By: Mete Durlu <meted@xxxxxxxxxxxxx>