From: Chen Ridong <chenridong@huawei.com> mainline inclusion from mainline-v6.19 commit 648d43da64f0221ab1050825b28995c17ce091a4 category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/9899 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- The remote_children list is used to track all remote partitions attached to a cpuset. However, it serves no other purpose. Using a boolean flag to indicate whether a cpuset is a remote partition is a more direct approach, making remote_children unnecessary. This patch replaces the list with a remote_partition flag in the cpuset structure and removes remote_children entirely. Signed-off-by: Chen Ridong <chenridong@huawei.com> Reviewed-by: Waiman Long <longman@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org> Conflicts: kernel/cgroup/cpuset.c kernel/cgroup/cpuset-internal.h [ cpuset-internal.h does not exist in OLK-6.6 and is kept deleted; the remote_partition bool is added to struct cpuset in cpuset.c. remote_partition_enable() keeps the (cs, tmp) signature and the 1/0 return convention as upstream's new_prs parameter and errcode returns come from e55f45b4bafe (not backported); the direct cpumask operations are kept instead of partition_xcpus_add/del() (not backported). ] Signed-off-by: Zhang Qiao <zhangqiao22@huawei.com> --- kernel/cgroup/cpuset.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index e0aa3a3c5523..e14b6d96d7c0 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -195,6 +195,14 @@ struct cpuset { /* partition root state */ int partition_root_state; + /* + * Whether cpuset is a remote partition. + * It used to be a list anchoring all remote partitions - we can + * switch back to a list if we need to iterate over the remote + * partitions. + */ + bool remote_partition; + /* * Default hierarchy only: * use_parent_ecpus - set if using parent's effective_cpus @@ -216,9 +224,6 @@ struct cpuset { /* Handle for cpuset.cpus.partition */ struct cgroup_file partition_file; - - /* Remote partition silbling list anchored at remote_children */ - struct list_head remote_sibling; }; /* @@ -234,9 +239,6 @@ struct cpuset_remove_tasks_struct { */ static cpumask_var_t subpartitions_cpus; -/* List of remote partition root children */ -static struct list_head remote_children; - /* * A flag to force sched domain rebuild at the end of an operation. * It can be set in @@ -411,7 +413,7 @@ static struct cpuset top_cpuset = { .flags = ((1 << CS_ONLINE) | (1 << CS_CPU_EXCLUSIVE) | (1 << CS_MEM_EXCLUSIVE)), .partition_root_state = PRS_ROOT, - .remote_sibling = LIST_HEAD_INIT(top_cpuset.remote_sibling), + .remote_partition = false, }; /** @@ -1724,7 +1726,7 @@ static int compute_effective_exclusive_cpumask(struct cpuset *cs, static inline bool is_remote_partition(struct cpuset *cs) { - return !list_empty(&cs->remote_sibling); + return cs->remote_partition; } static inline bool is_local_partition(struct cpuset *cs) @@ -1775,7 +1777,7 @@ static int remote_partition_enable(struct cpuset *cs, struct tmpmasks *tmp) cs->use_parent_ecpus = false; parent->child_ecpus_count--; } - list_add(&cs->remote_sibling, &remote_children); + cs->remote_partition = true; cpumask_copy(cs->effective_xcpus, tmp->new_cpus); spin_unlock_irq(&callback_lock); cpuset_force_rebuild(); @@ -1806,12 +1808,12 @@ static void remote_partition_disable(struct cpuset *cs, struct tmpmasks *tmp) spin_lock_irq(&callback_lock); cpumask_andnot(subpartitions_cpus, - subpartitions_cpus, tmp->new_cpus); + subpartitions_cpus, cs->effective_xcpus); cpumask_and(tmp->new_cpus, - tmp->new_cpus, cpu_active_mask); + cs->effective_xcpus, cpu_active_mask); cpumask_or(top_cpuset.effective_cpus, top_cpuset.effective_cpus, tmp->new_cpus); - list_del_init(&cs->remote_sibling); + cs->remote_partition = false; if (cs->prs_err) cs->partition_root_state = -cs->partition_root_state; else @@ -4201,7 +4203,6 @@ cpuset_css_alloc(struct cgroup_subsys_state *parent_css) nodes_clear(cs->effective_mems); fmeter_init(&cs->fmeter); cs->relax_domain_level = -1; - INIT_LIST_HEAD(&cs->remote_sibling); /* Set CS_MEMORY_MIGRATE for default hierarchy */ if (cgroup_subsys_on_dfl(cpuset_cgrp_subsys)) @@ -4512,7 +4513,6 @@ int __init cpuset_init(void) fmeter_init(&top_cpuset.fmeter); set_bit(CS_SCHED_LOAD_BALANCE, &top_cpuset.flags); top_cpuset.relax_domain_level = -1; - INIT_LIST_HEAD(&remote_children); BUG_ON(!alloc_cpumask_var(&cpus_attach, GFP_KERNEL)); #ifdef CONFIG_QOS_SCHED_DYNAMIC_AFFINITY -- 2.18.0