2023-12-09 01:18:47

by Qais Yousef

[permalink] [raw]
Subject: [PATCH 1/3] sched/fair: Add is_misfit_task() function

Split it from update_misfit_status(). Use it in detach_tasks() and
update_sg_lb_wakeup_stats().

This should help us generalize misfit lb to handle more than
upmigration.

Signed-off-by: Qais Yousef (Google) <[email protected]>
---
kernel/sched/fair.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index bcea3d55d95d..eb9e891182cc 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5063,17 +5063,23 @@ static inline int task_fits_cpu(struct task_struct *p, int cpu)
return (util_fits_cpu(util, uclamp_min, uclamp_max, cpu) > 0);
}

+static inline int is_misfit_task(struct task_struct *p, struct rq *rq)
+{
+ if (!p || p->nr_cpus_allowed == 1)
+ return 0;
+
+ if (task_fits_cpu(p, cpu_of(rq)))
+ return 0;
+
+ return 1;
+}
+
static inline void update_misfit_status(struct task_struct *p, struct rq *rq)
{
if (!sched_asym_cpucap_active())
return;

- if (!p || p->nr_cpus_allowed == 1) {
- rq->misfit_task_load = 0;
- return;
- }
-
- if (task_fits_cpu(p, cpu_of(rq))) {
+ if (!is_misfit_task(p, rq)) {
rq->misfit_task_load = 0;
return;
}
@@ -9105,7 +9111,7 @@ static int detach_tasks(struct lb_env *env)

case migrate_misfit:
/* This is not a misfit task */
- if (task_fits_cpu(p, env->src_cpu))
+ if (!is_misfit_task(p, cpu_rq(env->src_cpu)))
goto next;

env->imbalance = 0;
@@ -10207,7 +10213,7 @@ static inline void update_sg_wakeup_stats(struct sched_domain *sd,
/* Check if task fits in the CPU */
if (sd->flags & SD_ASYM_CPUCAPACITY &&
sgs->group_misfit_task_load &&
- task_fits_cpu(p, i))
+ !is_misfit_task(p, rq))
sgs->group_misfit_task_load = 0;

}
--
2.34.1