Offering: HULK hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/8320 -------------------------------- commit 7fd4da9c1584 ("cgroup/cpuset: Optimize cpuset_attach() on v2") skipped cpuset_attach() when the child cgroup's effective cpus and mems remained unchanged, which resulted in the configured prefer_cpus not taking effect. Add is_affinity_unchanged: when a child cpuset is configured with prefer_cpus, even if its cpus/mems are the same as the root cpuset, this function will mark the functional difference and trigger the cpuset_attach_task execution flow, ensuring the normal activation for scheduler dynamic affinity. Fixes: 21dac1062b2f ("cpuset: Introduce new interface for scheduler dynamic affinity") Signed-off-by: Chen Jinghuang <chenjinghuang2@huawei.com> --- kernel/cgroup/cpuset.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index b2a2c0d038b7..755fe05fce3d 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -1022,6 +1022,16 @@ static int update_prefer_cpumask(struct cpuset *cs, struct cpuset *trialcs, return 0; } + +static inline bool prefer_cpus_updated(struct cpuset *cs, struct cpuset *oldcs) +{ + return !cpumask_equal(cs->prefer_cpus, oldcs->prefer_cpus); +} +#else +static inline bool prefer_cpus_updated(struct cpuset *cs, struct cpuset *oldcs) +{ + return false; +} #endif #ifdef CONFIG_SMP @@ -3539,7 +3549,7 @@ static void cpuset_attach(struct cgroup_taskset *tset) * by skipping the task iteration and update. */ if (cgroup_subsys_on_dfl(cpuset_cgrp_subsys) && - !cpus_updated && !mems_updated) { + !cpus_updated && !mems_updated && !prefer_cpus_updated(cs, oldcs)) { cpuset_attach_nodemask_to = cs->effective_mems; goto out; } -- 2.34.1