[PATCH 3/3] sched/fair: Rename sgc->imbalance to sgc->pinned_task
From: Jemmy Wong
Date: Mon Sep 28 2026 - 00:21:49 EST
sgc->imbalance does not describe a load skew either. It is set only
when a child domain failed to balance because some tasks were pinned by
cpus_ptr, and the parent then classifies the group as group_pinned_task
so that it can force a migration.
The old name also collides with env->imbalance, the amount of load
still to move, and with imbalance_pct. And after the previous rename,
sg_imbalanced() returns group_pinned_task, so the helper and the group
type no longer agree.
Rename the field to pinned_task and its reader to sg_pinned_task().
No functional change.
Signed-off-by: Jemmy Wong <jemmywong512@xxxxxxxxx>
---
kernel/sched/fair.c | 24 ++++++++++++------------
kernel/sched/sched.h | 6 +++++-
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index aa63950976aa..43bdca636461 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -11595,7 +11595,7 @@ static inline bool check_misfit_status(struct rq *rq)
}
/*
- * Group imbalance indicates (and tries to solve) the problem where balancing
+ * sgc->pinned_task indicates (and tries to solve) the problem where balancing
* groups is inadequate due to ->cpus_ptr constraints.
*
* Imagine a situation of two groups of 4 CPUs each and 4 tasks each with a
@@ -11623,9 +11623,9 @@ static inline bool check_misfit_status(struct rq *rq)
* subtle and fragile situation.
*/
-static inline int sg_imbalanced(struct sched_group *group)
+static inline int sg_pinned_task(struct sched_group *group)
{
- return group->sgc->imbalance;
+ return group->sgc->pinned_task;
}
/*
@@ -11700,7 +11700,7 @@ group_type group_classify(unsigned int imbalance_pct,
if (sgs->group_llc_balance)
return group_llc_balance;
- if (sg_imbalanced(group))
+ if (sg_pinned_task(group))
return group_pinned_task;
if (sgs->group_asym_packing)
@@ -13619,10 +13619,10 @@ static int sched_balance_rq(int this_cpu, struct rq *this_rq,
* We failed to reach balance because of affinity.
*/
if (sd_parent) {
- int *group_imbalance = &sd_parent->groups->sgc->imbalance;
+ int *pinned_task = &sd_parent->groups->sgc->pinned_task;
if ((env.flags & LBF_SOME_PINNED) && env.imbalance > 0)
- *group_imbalance = 1;
+ *pinned_task = 1;
}
/* All tasks on this runqueue were pinned by CPU affinity */
@@ -13722,21 +13722,21 @@ static int sched_balance_rq(int this_cpu, struct rq *this_rq,
out_balanced:
/*
* We reach balance although we may have faced some affinity
- * constraints. Clear the imbalance flag only if other tasks got
+ * constraints. Clear the pinned flag only if other tasks got
* a chance to move and fix the imbalance.
*/
if (sd_parent && !(env.flags & LBF_ALL_PINNED)) {
- int *group_imbalance = &sd_parent->groups->sgc->imbalance;
+ int *pinned_task = &sd_parent->groups->sgc->pinned_task;
- if (*group_imbalance)
- *group_imbalance = 0;
+ if (*pinned_task)
+ *pinned_task = 0;
}
out_all_pinned:
/*
* We reach balance because all tasks are pinned at this level so
- * we can't migrate them. Let the imbalance flag set so parent level
- * can try to migrate them.
+ * we can't migrate them. Let the pinned flag stay set so the parent
+ * level can try to migrate them.
*/
schedstat_inc(sd->lb_balanced[idle]);
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index e656c7059bf8..b64966dde395 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -2257,7 +2257,11 @@ struct sched_group_capacity {
unsigned long min_capacity; /* Min per-CPU capacity in group */
unsigned long max_capacity; /* Max per-CPU capacity in group */
unsigned long next_update;
- int imbalance; /* XXX unrelated to capacity but shared group state */
+ /*
+ * Set when a child domain cannot balance pinned tasks.
+ * XXX unrelated to capacity, but it is shared group state.
+ */
+ int pinned_task;
int id;
--
2.54.0 (Apple Git-157)