From bcddff7edab1f07bb2824b9dfc7380db995ddccf Mon Sep 17 00:00:00 2001 From: tanghui Date: Wed, 16 Nov 2022 15:12:19 +0800 Subject: [PATCH] sched: Adjust cpu allowed in load balance dynamicly hulk inclusion category: feature bugzilla: 186575, https://gitee.com/openeuler/kernel/issues/I526XC -------------------------------- Not allow task to migrate out of cpu preferred. Signed-off-by: tanghui Signed-off-by: Zheng Zucheng Reviewed-by: Zhang Qiao --- kernel/sched/fair.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index c70a2776a569..49e2886c4c6b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8512,7 +8512,12 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env) if (kthread_is_per_cpu(p)) return 0; +#ifdef CONFIG_QOS_SCHED_DYNAMIC_AFFINITY + set_task_select_cpus(p, NULL, 0); + if (!cpumask_test_cpu(env->dst_cpu, p->select_cpus)) { +#else if (!cpumask_test_cpu(env->dst_cpu, p->cpus_ptr)) { +#endif int cpu; schedstat_inc(p->se.statistics.nr_failed_migrations_affine); @@ -8532,7 +8537,11 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env) /* Prevent to re-select dst_cpu via env's CPUs: */ for_each_cpu_and(cpu, env->dst_grpmask, env->cpus) { +#ifdef CONFIG_QOS_SCHED_DYNAMIC_AFFINITY + if (cpumask_test_cpu(cpu, p->select_cpus)) { +#else if (cpumask_test_cpu(cpu, p->cpus_ptr)) { +#endif env->flags |= LBF_DST_PINNED; env->new_dst_cpu = cpu; break; -- GitLab