cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Waiman Long <llong@redhat.com>
To: Chen Ridong <chenridong@huaweicloud.com>,
	tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
	lujialin4@huawei.com, chenridong@huawei.com
Subject: Re: [PATCH -next 2/3] cpuset: remove global remote_children list
Date: Mon, 10 Nov 2025 23:34:54 -0500	[thread overview]
Message-ID: <51ee41f3-02d7-4b76-acfc-882abe9a003d@redhat.com> (raw)
In-Reply-To: <20251110015228.897736-3-chenridong@huaweicloud.com>

On 11/9/25 8:52 PM, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> 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>
> ---
>   kernel/cgroup/cpuset-internal.h |  4 ++--
>   kernel/cgroup/cpuset.c          | 14 +++++---------
>   2 files changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset-internal.h b/kernel/cgroup/cpuset-internal.h
> index 5cac42c5fd97..7308e8bc4dde 100644
> --- a/kernel/cgroup/cpuset-internal.h
> +++ b/kernel/cgroup/cpuset-internal.h
> @@ -172,8 +172,8 @@ 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;
> +	/* Whether cpuset is a remote partition */
> +	bool remote_partition;
>   

The original purpose of adding a linked list for remote children is to 
enable us iterate the list of remote children when needed. This 
capability is not currently being used. So we can simplify it for now, 
but I would like to add a comment saying that we can switch it back to a 
list in case we need to iterate the remote children list in the future. 
Also I would suggest moving the bool up before partition_file to reduce 
the number of holes in the cpuset structure.

Cheers,
Longman

>   	/* Used to merge intersecting subsets for generate_sched_domains */
>   	struct uf_node node;
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index c90476d52f09..c357bfb69fe2 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -94,9 +94,6 @@ static bool isolated_cpus_updating;
>   static cpumask_var_t	boot_hk_cpus;
>   static bool		have_boot_isolcpus;
>   
> -/* 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
> @@ -219,7 +216,7 @@ static struct cpuset top_cpuset = {
>   		 BIT(CS_MEM_EXCLUSIVE) | BIT(CS_SCHED_LOAD_BALANCE),
>   	.partition_root_state = PRS_ROOT,
>   	.relax_domain_level = -1,
> -	.remote_sibling = LIST_HEAD_INIT(top_cpuset.remote_sibling),
> +	.remote_partition = false,
>   };
>   
>   /*
> @@ -1572,7 +1569,7 @@ static int compute_trialcs_excpus(struct cpuset *trialcs, 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)
> @@ -1621,7 +1618,7 @@ static int remote_partition_enable(struct cpuset *cs, int new_prs,
>   
>   	spin_lock_irq(&callback_lock);
>   	partition_xcpus_add(new_prs, NULL, tmp->new_cpus);
> -	list_add(&cs->remote_sibling, &remote_children);
> +	cs->remote_partition = true;
>   	cpumask_copy(cs->effective_xcpus, tmp->new_cpus);
>   	spin_unlock_irq(&callback_lock);
>   	update_isolation_cpumasks();
> @@ -1651,7 +1648,7 @@ static void remote_partition_disable(struct cpuset *cs, struct tmpmasks *tmp)
>   	WARN_ON_ONCE(!cpumask_subset(cs->effective_xcpus, subpartitions_cpus));
>   
>   	spin_lock_irq(&callback_lock);
> -	list_del_init(&cs->remote_sibling);
> +	cs->remote_partition = false;
>   	partition_xcpus_del(cs->partition_root_state, NULL, cs->effective_xcpus);
>   	if (cs->prs_err)
>   		cs->partition_root_state = -cs->partition_root_state;
> @@ -3603,7 +3600,7 @@ cpuset_css_alloc(struct cgroup_subsys_state *parent_css)
>   	__set_bit(CS_SCHED_LOAD_BALANCE, &cs->flags);
>   	fmeter_init(&cs->fmeter);
>   	cs->relax_domain_level = -1;
> -	INIT_LIST_HEAD(&cs->remote_sibling);
> +	cs->remote_partition = false;
>   

We don't need to initialize remote_partition here as the structure is 
zalloc'ed.

Cheers,
Longman

>   	/* Set CS_MEMORY_MIGRATE for default hierarchy */
>   	if (cpuset_v2())
> @@ -3874,7 +3871,6 @@ int __init cpuset_init(void)
>   	nodes_setall(top_cpuset.effective_mems);
>   
>   	fmeter_init(&top_cpuset.fmeter);
> -	INIT_LIST_HEAD(&remote_children);
>   
>   	BUG_ON(!alloc_cpumask_var(&cpus_attach, GFP_KERNEL));
>   


  reply	other threads:[~2025-11-11  4:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-10  1:52 [PATCH -next 0/3] cpuset: code cleanups Chen Ridong
2025-11-10  1:52 ` [PATCH -next 1/3] cpuset: simplify node setting on error Chen Ridong
2025-11-10 14:27   ` Michal Koutný
2025-11-11  3:37     ` Chen Ridong
2025-11-11  4:26   ` Waiman Long
2025-11-11  6:16     ` Chen Ridong
2025-11-10  1:52 ` [PATCH -next 2/3] cpuset: remove global remote_children list Chen Ridong
2025-11-11  4:34   ` Waiman Long [this message]
2025-11-11  6:17     ` Chen Ridong
2025-11-10  1:52 ` [PATCH -next 3/3] cpuset: remove need_rebuild_sched_domains Chen Ridong
2025-11-11  4:37   ` Waiman Long
2025-11-11  6:18     ` Chen Ridong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51ee41f3-02d7-4b76-acfc-882abe9a003d@redhat.com \
    --to=llong@redhat.com \
    --cc=cgroups@vger.kernel.org \
    --cc=chenridong@huawei.com \
    --cc=chenridong@huaweicloud.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lujialin4@huawei.com \
    --cc=mkoutny@suse.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).