[PATCH v2 1/3] sched/fair: Add smt_balance and llc_balance to the decision matrix
From: Jemmy Wong
Date: Fri Oct 02 2026 - 11:50:15 EST
The group-type matrix was introduced in commit 0b0695f2b34a
("sched/fair: Rework load_balance()"). When commit fee1759e4f04
("sched/fair: Determine active load balance for SMT sched groups")
added group_smt_balance and commit f38cc2f0d8a3 ("sched/cache:
Prioritize tasks preferring destination LLC during balancing")
added group_llc_balance, neither commit updated the matrix table.
Both types are only tagged on non-local groups in update_sg_lb_stats(),
so their local columns are N/A.
As busiest, group_smt_balance is only set when dst_cpu is idle and the
SMT group runs more than one task. Against a local has_spare or
fully_busy group it goes through the nr_idle checks, where a non-SMT
dst group may also force the pull via smt_vs_nonsmt_groups(). Against a
local imbalanced or overloaded group the local group is busier and the
pair is balanced.
As busiest, group_llc_balance is not an unconditional force. Against a
local has_spare group it forces the pull when prefer_sibling is set,
because the group_llc_balance test comes before sibling_imbalance() in
sched_balance_find_src_group(). SD_PREFER_SIBLING is only cleared for
NUMA domains. Against a local fully_busy or imbalanced group the nr_idle
checks apply, and against a local overloaded group the local group is
busier and the pair is balanced.
No functional change.
Signed-off-by: Jemmy Wong <jemmywong512@xxxxxxxxx>
---
kernel/sched/fair.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 57360f5cdde4..bcb9987952b9 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -13184,13 +13184,15 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
/*
* Decision matrix according to the local and busiest group type:
*
- * busiest \ local has_spare fully_busy misfit asym imbalanced overloaded
- * has_spare nr_idle balanced N/A N/A balanced balanced
- * fully_busy nr_idle nr_idle N/A N/A balanced balanced
- * misfit_task force N/A N/A N/A N/A N/A
- * asym_packing force force N/A N/A force force
- * imbalanced force force N/A N/A force force
- * overloaded force force N/A N/A force avg_load
+ * busiest \ local has_spare fully_busy misfit smt asym imbalanced llc overloaded
+ * has_spare nr_idle balanced N/A N/A N/A balanced N/A balanced
+ * fully_busy nr_idle nr_idle N/A N/A N/A balanced N/A balanced
+ * misfit_task force N/A N/A N/A N/A N/A N/A N/A
+ * smt_balance nr_idle nr_idle N/A N/A N/A balanced N/A balanced
+ * asym_packing force force N/A N/A N/A force N/A force
+ * imbalanced force force N/A N/A N/A force N/A force
+ * llc_balance force nr_idle N/A N/A N/A nr_idle N/A balanced
+ * overloaded force force N/A N/A N/A force N/A avg_load
*
* N/A : Not Applicable because already filtered while updating
* statistics.
--
2.54.0 (Apple Git-157)