* [PATCH -next 0/3] cpuset: code cleanups
@ 2025-11-10 1:52 Chen Ridong
2025-11-10 1:52 ` [PATCH -next 1/3] cpuset: simplify node setting on error Chen Ridong
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Chen Ridong @ 2025-11-10 1:52 UTC (permalink / raw)
To: longman, tj, hannes, mkoutny; +Cc: cgroups, linux-kernel, lujialin4, chenridong
From: Chen Ridong <chenridong@huawei.com>
Patch 1 simplifies the error handling path in cpuset_set_nodes() by
returning directly on failure, eliminating an unnecessary jump.
Patch 2 removes the global remote_children list and replaces it with
a boolean remote_partition flag, which provides a more direct way
to identify remote partitions.
Patch 3 removes need_rebuild_sched_domains.
Chen Ridong (3):
cpuset: simplify node setting on error
cpuset: remove global remote_children list
cpuset: remove need_rebuild_sched_domains
kernel/cgroup/cpuset-internal.h | 4 ++--
kernel/cgroup/cpuset.c | 41 ++++++++++++---------------------
2 files changed, 17 insertions(+), 28 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH -next 1/3] cpuset: simplify node setting on error
2025-11-10 1:52 [PATCH -next 0/3] cpuset: code cleanups Chen Ridong
@ 2025-11-10 1:52 ` Chen Ridong
2025-11-10 14:27 ` Michal Koutný
2025-11-11 4:26 ` Waiman Long
2025-11-10 1:52 ` [PATCH -next 2/3] cpuset: remove global remote_children list Chen Ridong
2025-11-10 1:52 ` [PATCH -next 3/3] cpuset: remove need_rebuild_sched_domains Chen Ridong
2 siblings, 2 replies; 12+ messages in thread
From: Chen Ridong @ 2025-11-10 1:52 UTC (permalink / raw)
To: longman, tj, hannes, mkoutny; +Cc: cgroups, linux-kernel, lujialin4, chenridong
From: Chen Ridong <chenridong@huawei.com>
There is no need to jump to the 'done' label upon failure, as no cleanup
is required. Return the error code directly instead.
Signed-off-by: Chen Ridong <chenridong@huawei.com>
---
kernel/cgroup/cpuset.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 8238fd8c0c29..c90476d52f09 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2897,21 +2897,19 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
*/
retval = nodelist_parse(buf, trialcs->mems_allowed);
if (retval < 0)
- goto done;
+ return retval;
if (!nodes_subset(trialcs->mems_allowed,
- top_cpuset.mems_allowed)) {
- retval = -EINVAL;
- goto done;
- }
+ top_cpuset.mems_allowed))
+ return -EINVAL;
+
+ /* No change? nothing to do */
+ if (nodes_equal(cs->mems_allowed, trialcs->mems_allowed))
+ return 0;
- if (nodes_equal(cs->mems_allowed, trialcs->mems_allowed)) {
- retval = 0; /* Too easy - nothing to do */
- goto done;
- }
retval = validate_change(cs, trialcs);
if (retval < 0)
- goto done;
+ return retval;
check_insane_mems_config(&trialcs->mems_allowed);
@@ -2921,8 +2919,7 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
/* use trialcs->mems_allowed as a temp variable */
update_nodemasks_hier(cs, &trialcs->mems_allowed);
-done:
- return retval;
+ return 0;
}
bool current_cpuset_is_being_rebound(void)
--
2.34.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH -next 2/3] cpuset: remove global remote_children list
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 1:52 ` Chen Ridong
2025-11-11 4:34 ` Waiman Long
2025-11-10 1:52 ` [PATCH -next 3/3] cpuset: remove need_rebuild_sched_domains Chen Ridong
2 siblings, 1 reply; 12+ messages in thread
From: Chen Ridong @ 2025-11-10 1:52 UTC (permalink / raw)
To: longman, tj, hannes, mkoutny; +Cc: cgroups, linux-kernel, lujialin4, chenridong
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;
/* 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;
/* 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));
--
2.34.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH -next 3/3] cpuset: remove need_rebuild_sched_domains
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 1:52 ` [PATCH -next 2/3] cpuset: remove global remote_children list Chen Ridong
@ 2025-11-10 1:52 ` Chen Ridong
2025-11-11 4:37 ` Waiman Long
2 siblings, 1 reply; 12+ messages in thread
From: Chen Ridong @ 2025-11-10 1:52 UTC (permalink / raw)
To: longman, tj, hannes, mkoutny; +Cc: cgroups, linux-kernel, lujialin4, chenridong
From: Chen Ridong <chenridong@huawei.com>
Previously, update_cpumasks_hier() used need_rebuild_sched_domains to
decide whether to invoke rebuild_sched_domains_locked(). Now that
rebuild_sched_domains_locked() only sets force_rebuild, the flag is
redundant. Hence, remove it.
Signed-off-by: Chen Ridong <chenridong@huawei.com>
---
kernel/cgroup/cpuset.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index c357bfb69fe2..22084d8bdc3f 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2184,7 +2184,6 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
{
struct cpuset *cp;
struct cgroup_subsys_state *pos_css;
- bool need_rebuild_sched_domains = false;
int old_prs, new_prs;
rcu_read_lock();
@@ -2348,15 +2347,12 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
if (!cpumask_empty(cp->cpus_allowed) &&
is_sched_load_balance(cp) &&
(!cpuset_v2() || is_partition_valid(cp)))
- need_rebuild_sched_domains = true;
+ cpuset_force_rebuild();
rcu_read_lock();
css_put(&cp->css);
}
rcu_read_unlock();
-
- if (need_rebuild_sched_domains)
- cpuset_force_rebuild();
}
/**
--
2.34.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH -next 1/3] cpuset: simplify node setting on error
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
1 sibling, 1 reply; 12+ messages in thread
From: Michal Koutný @ 2025-11-10 14:27 UTC (permalink / raw)
To: Chen Ridong
Cc: longman, tj, hannes, cgroups, linux-kernel, lujialin4, chenridong
[-- Attachment #1: Type: text/plain, Size: 493 bytes --]
On Mon, Nov 10, 2025 at 01:52:26AM +0000, Chen Ridong <chenridong@huaweicloud.com> wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> There is no need to jump to the 'done' label upon failure, as no cleanup
> is required. Return the error code directly instead.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
> kernel/cgroup/cpuset.c | 21 +++++++++------------
> 1 file changed, 9 insertions(+), 12 deletions(-)
Reviewed-by: Michal Koutný <mkoutny@suse.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 265 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH -next 1/3] cpuset: simplify node setting on error
2025-11-10 14:27 ` Michal Koutný
@ 2025-11-11 3:37 ` Chen Ridong
0 siblings, 0 replies; 12+ messages in thread
From: Chen Ridong @ 2025-11-11 3:37 UTC (permalink / raw)
To: Michal Koutný
Cc: longman, tj, hannes, cgroups, linux-kernel, lujialin4, chenridong
On 2025/11/10 22:27, Michal Koutný wrote:
> On Mon, Nov 10, 2025 at 01:52:26AM +0000, Chen Ridong <chenridong@huaweicloud.com> wrote:
>> From: Chen Ridong <chenridong@huawei.com>
>>
>> There is no need to jump to the 'done' label upon failure, as no cleanup
>> is required. Return the error code directly instead.
>>
>> Signed-off-by: Chen Ridong <chenridong@huawei.com>
>> ---
>> kernel/cgroup/cpuset.c | 21 +++++++++------------
>> 1 file changed, 9 insertions(+), 12 deletions(-)
>
> Reviewed-by: Michal Koutný <mkoutny@suse.com>
Thanks.
--
Best regards,
Ridong
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH -next 1/3] cpuset: simplify node setting on error
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 4:26 ` Waiman Long
2025-11-11 6:16 ` Chen Ridong
1 sibling, 1 reply; 12+ messages in thread
From: Waiman Long @ 2025-11-11 4:26 UTC (permalink / raw)
To: Chen Ridong, tj, hannes, mkoutny
Cc: cgroups, linux-kernel, lujialin4, chenridong
On 11/9/25 8:52 PM, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> There is no need to jump to the 'done' label upon failure, as no cleanup
> is required. Return the error code directly instead.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
> kernel/cgroup/cpuset.c | 21 +++++++++------------
> 1 file changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 8238fd8c0c29..c90476d52f09 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -2897,21 +2897,19 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
> */
> retval = nodelist_parse(buf, trialcs->mems_allowed);
> if (retval < 0)
> - goto done;
> + return retval;
>
> if (!nodes_subset(trialcs->mems_allowed,
> - top_cpuset.mems_allowed)) {
> - retval = -EINVAL;
> - goto done;
> - }
> + top_cpuset.mems_allowed))
> + return -EINVAL;
> +
> + /* No change? nothing to do */
> + if (nodes_equal(cs->mems_allowed, trialcs->mems_allowed))
> + return 0;
>
> - if (nodes_equal(cs->mems_allowed, trialcs->mems_allowed)) {
> - retval = 0; /* Too easy - nothing to do */
> - goto done;
> - }
> retval = validate_change(cs, trialcs);
> if (retval < 0)
> - goto done;
> + return retval;
>
> check_insane_mems_config(&trialcs->mems_allowed);
>
> @@ -2921,8 +2919,7 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
>
> /* use trialcs->mems_allowed as a temp variable */
> update_nodemasks_hier(cs, &trialcs->mems_allowed);
> -done:
> - return retval;
> + return 0;
> }
>
> bool current_cpuset_is_being_rebound(void)
Reviewed-by: Waiman Long <longman@redhat.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH -next 2/3] cpuset: remove global remote_children list
2025-11-10 1:52 ` [PATCH -next 2/3] cpuset: remove global remote_children list Chen Ridong
@ 2025-11-11 4:34 ` Waiman Long
2025-11-11 6:17 ` Chen Ridong
0 siblings, 1 reply; 12+ messages in thread
From: Waiman Long @ 2025-11-11 4:34 UTC (permalink / raw)
To: Chen Ridong, tj, hannes, mkoutny
Cc: cgroups, linux-kernel, lujialin4, chenridong
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));
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH -next 3/3] cpuset: remove need_rebuild_sched_domains
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
0 siblings, 1 reply; 12+ messages in thread
From: Waiman Long @ 2025-11-11 4:37 UTC (permalink / raw)
To: Chen Ridong, tj, hannes, mkoutny
Cc: cgroups, linux-kernel, lujialin4, chenridong
On 11/9/25 8:52 PM, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> Previously, update_cpumasks_hier() used need_rebuild_sched_domains to
> decide whether to invoke rebuild_sched_domains_locked(). Now that
> rebuild_sched_domains_locked() only sets force_rebuild, the flag is
> redundant. Hence, remove it.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
> kernel/cgroup/cpuset.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index c357bfb69fe2..22084d8bdc3f 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -2184,7 +2184,6 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
> {
> struct cpuset *cp;
> struct cgroup_subsys_state *pos_css;
> - bool need_rebuild_sched_domains = false;
> int old_prs, new_prs;
>
> rcu_read_lock();
> @@ -2348,15 +2347,12 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
> if (!cpumask_empty(cp->cpus_allowed) &&
> is_sched_load_balance(cp) &&
> (!cpuset_v2() || is_partition_valid(cp)))
> - need_rebuild_sched_domains = true;
> + cpuset_force_rebuild();
>
> rcu_read_lock();
> css_put(&cp->css);
> }
> rcu_read_unlock();
> -
> - if (need_rebuild_sched_domains)
> - cpuset_force_rebuild();
> }
>
> /**
Reviewed-by: Waiman Long <longman@redhat.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH -next 1/3] cpuset: simplify node setting on error
2025-11-11 4:26 ` Waiman Long
@ 2025-11-11 6:16 ` Chen Ridong
0 siblings, 0 replies; 12+ messages in thread
From: Chen Ridong @ 2025-11-11 6:16 UTC (permalink / raw)
To: Waiman Long, tj, hannes, mkoutny
Cc: cgroups, linux-kernel, lujialin4, chenridong
On 2025/11/11 12:26, Waiman Long wrote:
> On 11/9/25 8:52 PM, Chen Ridong wrote:
>> From: Chen Ridong <chenridong@huawei.com>
>>
>> There is no need to jump to the 'done' label upon failure, as no cleanup
>> is required. Return the error code directly instead.
>>
>> Signed-off-by: Chen Ridong <chenridong@huawei.com>
>> ---
>> kernel/cgroup/cpuset.c | 21 +++++++++------------
>> 1 file changed, 9 insertions(+), 12 deletions(-)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index 8238fd8c0c29..c90476d52f09 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -2897,21 +2897,19 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
>> */
>> retval = nodelist_parse(buf, trialcs->mems_allowed);
>> if (retval < 0)
>> - goto done;
>> + return retval;
>> if (!nodes_subset(trialcs->mems_allowed,
>> - top_cpuset.mems_allowed)) {
>> - retval = -EINVAL;
>> - goto done;
>> - }
>> + top_cpuset.mems_allowed))
>> + return -EINVAL;
>> +
>> + /* No change? nothing to do */
>> + if (nodes_equal(cs->mems_allowed, trialcs->mems_allowed))
>> + return 0;
>> - if (nodes_equal(cs->mems_allowed, trialcs->mems_allowed)) {
>> - retval = 0; /* Too easy - nothing to do */
>> - goto done;
>> - }
>> retval = validate_change(cs, trialcs);
>> if (retval < 0)
>> - goto done;
>> + return retval;
>> check_insane_mems_config(&trialcs->mems_allowed);
>> @@ -2921,8 +2919,7 @@ static int update_nodemask(struct cpuset *cs, struct cpuset *trialcs,
>> /* use trialcs->mems_allowed as a temp variable */
>> update_nodemasks_hier(cs, &trialcs->mems_allowed);
>> -done:
>> - return retval;
>> + return 0;
>> }
>> bool current_cpuset_is_being_rebound(void)
> Reviewed-by: Waiman Long <longman@redhat.com>
>
Thanks.
--
Best regards,
Ridong
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH -next 2/3] cpuset: remove global remote_children list
2025-11-11 4:34 ` Waiman Long
@ 2025-11-11 6:17 ` Chen Ridong
0 siblings, 0 replies; 12+ messages in thread
From: Chen Ridong @ 2025-11-11 6:17 UTC (permalink / raw)
To: Waiman Long, tj, hannes, mkoutny
Cc: cgroups, linux-kernel, lujialin4, chenridong
On 2025/11/11 12:34, Waiman Long wrote:
> 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.
>
Thanks, will update.
>
>> /* 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.
>
Thanks, will update.
>
>> /* 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));
>>
>
--
Best regards,
Ridong
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH -next 3/3] cpuset: remove need_rebuild_sched_domains
2025-11-11 4:37 ` Waiman Long
@ 2025-11-11 6:18 ` Chen Ridong
0 siblings, 0 replies; 12+ messages in thread
From: Chen Ridong @ 2025-11-11 6:18 UTC (permalink / raw)
To: Waiman Long, tj, hannes, mkoutny
Cc: cgroups, linux-kernel, lujialin4, chenridong
On 2025/11/11 12:37, Waiman Long wrote:
>
> On 11/9/25 8:52 PM, Chen Ridong wrote:
>> From: Chen Ridong <chenridong@huawei.com>
>>
>> Previously, update_cpumasks_hier() used need_rebuild_sched_domains to
>> decide whether to invoke rebuild_sched_domains_locked(). Now that
>> rebuild_sched_domains_locked() only sets force_rebuild, the flag is
>> redundant. Hence, remove it.
>>
>> Signed-off-by: Chen Ridong <chenridong@huawei.com>
>> ---
>> kernel/cgroup/cpuset.c | 6 +-----
>> 1 file changed, 1 insertion(+), 5 deletions(-)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index c357bfb69fe2..22084d8bdc3f 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -2184,7 +2184,6 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
>> {
>> struct cpuset *cp;
>> struct cgroup_subsys_state *pos_css;
>> - bool need_rebuild_sched_domains = false;
>> int old_prs, new_prs;
>> rcu_read_lock();
>> @@ -2348,15 +2347,12 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
>> if (!cpumask_empty(cp->cpus_allowed) &&
>> is_sched_load_balance(cp) &&
>> (!cpuset_v2() || is_partition_valid(cp)))
>> - need_rebuild_sched_domains = true;
>> + cpuset_force_rebuild();
>> rcu_read_lock();
>> css_put(&cp->css);
>> }
>> rcu_read_unlock();
>> -
>> - if (need_rebuild_sched_domains)
>> - cpuset_force_rebuild();
>> }
>> /**
> Reviewed-by: Waiman Long <longman@redhat.com>
>
Thanks.
--
Best regards,
Ridong
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-11-11 6:18 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®