From: sashiko-bot@kernel.org
To: "Shrikanth Hegde" <sshegde@linux.ibm.com>
Cc: virtualization@lists.linux.dev,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH v13 07/13] sched/fair: Load balance only among preferred CPUs
Date: Wed, 09 Sep 2026 14:33:00 +0000 [thread overview]
Message-ID: <20260909143301.46F121F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260909135617.871006-8-sshegde@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Group statistics (`avg_load`, `group_has_spare`) and load balancing math are corrupted because load and utilization exclude non-preferred CPUs, while group capacity and weight incorrectly include them.
- [High] Periodic and busy load balancing can be completely disabled for a scheduling domain if the statically designated `group_balance_cpu` becomes non-preferred.
--
commit 2dcc3be382ec42f554b59dc47da29e35996ce2d6
Author: Shrikanth Hegde <sshegde@linux.ibm.com>
Subject: sched/fair: Load balance only among preferred CPUs
This patch modifies load balancing to only consider preferred CPUs,
aiming to prevent balancing against the push task mechanism. It
updates sched_balance_rq() and sched_balance_newidle() to restrict
operations using cpu_preferred_mask.
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index b8bd308c2d5b1..4ef1167b8c73f 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -13473,7 +13473,7 @@ static int sched_balance_rq(int this_cpu, struct rq *this_rq,
> };
> bool need_unlock = false;
>
> - cpumask_and(cpus, sched_domain_span(sd), cpu_active_mask);
> + cpumask_and(cpus, sched_domain_span(sd), cpu_preferred_mask);
[Severity: High]
Does restricting env.cpus to cpu_preferred_mask here corrupt the group
statistics calculation in update_sg_lb_stats()?
Looking at update_sg_lb_stats(), it accumulates load and utilization by
iterating only over env->cpus:
kernel/sched/fair.c:update_sg_lb_stats() {
...
for_each_cpu_and(i, sched_group_span(group), env->cpus) {
...
}
...
sgs->group_capacity = group->sgc->capacity;
sgs->group_weight = group->group_weight;
...
}
Since it assigns the full capacity and weight of the entire group, but only
accumulates load for the preferred CPUs, won't this artificially deflate
avg_load? This could cause the load balancer to perceive mixed groups as
severely under-loaded and aggressively pull tasks to already overloaded
preferred CPUs.
[Severity: High]
Can this also completely disable periodic and busy load balancing for a
scheduling domain if the statically designated balance CPU is non-preferred?
Looking at should_we_balance():
kernel/sched/fair.c:should_we_balance() {
...
if (!cpumask_test_cpu(env->dst_cpu, env->cpus))
return 0;
...
return group_balance_cpu(sg) == env->dst_cpu;
}
If the statically designated group_balance_cpu(sg) is non-preferred, it
will abort immediately because it is excluded from env.cpus. All other
preferred CPUs in the group will also abort because they fail the
group_balance_cpu(sg) == env->dst_cpu check.
Does this mean no CPU will perform the domain balance, potentially causing
severe starvation?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909135617.871006-1-sshegde@linux.ibm.com?part=7
next prev parent reply other threads:[~2026-09-09 14:33 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 13:56 [PATCH v13 00/13] sched, steal_governor: Introduce preferred CPUs and steal-driven vCPU backoff Shrikanth Hegde
2026-09-09 13:56 ` [PATCH v13 01/13] sched/cputime: Add kcpustat_field_total helper Shrikanth Hegde
2026-09-09 14:16 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 02/13] cpumask: Introduce cpumask_intersects_and Shrikanth Hegde
2026-09-09 14:02 ` sashiko-bot
2026-09-09 16:03 ` Yury Norov
2026-09-09 13:56 ` [PATCH v13 03/13] sched/docs: Document cpu_preferred_mask and Preferred CPU concept Shrikanth Hegde
2026-09-09 14:01 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 04/13] cpumask: Introduce cpu_preferred_mask Shrikanth Hegde
2026-09-09 14:06 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 05/13] sysfs: Add preferred CPU file Shrikanth Hegde
2026-09-09 14:04 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 06/13] sched/core: Try to use a preferred CPU in is_cpu_allowed Shrikanth Hegde
2026-09-09 14:18 ` sashiko-bot
2026-09-09 16:49 ` Shrikanth Hegde
2026-09-09 13:56 ` [PATCH v13 07/13] sched/fair: Load balance only among preferred CPUs Shrikanth Hegde
2026-09-09 14:33 ` sashiko-bot [this message]
2026-09-09 17:09 ` Shrikanth Hegde
2026-09-09 17:19 ` Yury Norov
2026-09-09 13:56 ` [PATCH v13 08/13] sched/core: Push current task from non preferred CPU Shrikanth Hegde
2026-09-09 14:18 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 09/13] sched/debug: Add migration stats due to non preferred CPUs Shrikanth Hegde
2026-09-09 14:07 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 10/13] virt: Introduce steal governor driver Shrikanth Hegde
2026-09-09 14:09 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 11/13] virt/steal_governor: Add control knobs for handling steal values Shrikanth Hegde
2026-09-09 14:06 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 12/13] virt/steal_governor: Implement steal_governor policy loop Shrikanth Hegde
2026-09-09 14:16 ` sashiko-bot
2026-09-09 16:52 ` Shrikanth Hegde
2026-09-09 13:56 ` [PATCH v13 13/13] virt/steal_governor: Enable the driver Shrikanth Hegde
2026-09-09 14:17 ` sashiko-bot
2026-09-09 16:58 ` Shrikanth Hegde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260909143301.46F121F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=eperezma@redhat.com \
--cc=mst@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sshegde@linux.ibm.com \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.