[PATCH v2 -next] cgroup/cpuset: remove child_ecpus_count

Chen Ridong posted 1 patch 1 year, 4 months ago
kernel/cgroup/cpuset.c | 25 ++++---------------------
1 file changed, 4 insertions(+), 21 deletions(-)
[PATCH v2 -next] cgroup/cpuset: remove child_ecpus_count
Posted by Chen Ridong 1 year, 4 months ago
The child_ecpus_count variable was previously used to update
sibling cpumask when parent's effective_cpus is updated. However, it became
obsolete after commit e2ffe502ba45 ("cgroup/cpuset: Add
cpuset.cpus.exclusive for v2"). It should be removed.

Signed-off-by: Chen Ridong <chenridong@huawei.com>
---
 kernel/cgroup/cpuset.c | 25 ++++---------------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 40ec4abaf440..d4322619e59a 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -188,10 +188,8 @@ struct cpuset {
 	/*
 	 * Default hierarchy only:
 	 * use_parent_ecpus - set if using parent's effective_cpus
-	 * child_ecpus_count - # of children with use_parent_ecpus set
 	 */
 	int use_parent_ecpus;
-	int child_ecpus_count;
 
 	/*
 	 * number of SCHED_DEADLINE tasks attached to this cpuset, so that we
@@ -1512,7 +1510,6 @@ static void reset_partition_data(struct cpuset *cs)
 	if (!cpumask_and(cs->effective_cpus,
 			 parent->effective_cpus, cs->cpus_allowed)) {
 		cs->use_parent_ecpus = true;
-		parent->child_ecpus_count++;
 		cpumask_copy(cs->effective_cpus, parent->effective_cpus);
 	}
 }
@@ -1688,12 +1685,8 @@ static int remote_partition_enable(struct cpuset *cs, int new_prs,
 	spin_lock_irq(&callback_lock);
 	isolcpus_updated = partition_xcpus_add(new_prs, NULL, tmp->new_cpus);
 	list_add(&cs->remote_sibling, &remote_children);
-	if (cs->use_parent_ecpus) {
-		struct cpuset *parent = parent_cs(cs);
-
+	if (cs->use_parent_ecpus)
 		cs->use_parent_ecpus = false;
-		parent->child_ecpus_count--;
-	}
 	spin_unlock_irq(&callback_lock);
 	update_unbound_workqueue_cpumask(isolcpus_updated);
 
@@ -2318,15 +2311,10 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
 		 */
 		if (is_in_v2_mode() && !remote && cpumask_empty(tmp->new_cpus)) {
 			cpumask_copy(tmp->new_cpus, parent->effective_cpus);
-			if (!cp->use_parent_ecpus) {
+			if (!cp->use_parent_ecpus)
 				cp->use_parent_ecpus = true;
-				parent->child_ecpus_count++;
-			}
-		} else if (cp->use_parent_ecpus) {
+		} else if (cp->use_parent_ecpus)
 			cp->use_parent_ecpus = false;
-			WARN_ON_ONCE(!parent->child_ecpus_count);
-			parent->child_ecpus_count--;
-		}
 
 		if (remote)
 			goto get_css;
@@ -4139,7 +4127,6 @@ static int cpuset_css_online(struct cgroup_subsys_state *css)
 		cpumask_copy(cs->effective_cpus, parent->effective_cpus);
 		cs->effective_mems = parent->effective_mems;
 		cs->use_parent_ecpus = true;
-		parent->child_ecpus_count++;
 	}
 	spin_unlock_irq(&callback_lock);
 
@@ -4205,12 +4192,8 @@ static void cpuset_css_offline(struct cgroup_subsys_state *css)
 	    is_sched_load_balance(cs))
 		update_flag(CS_SCHED_LOAD_BALANCE, cs, 0);
 
-	if (cs->use_parent_ecpus) {
-		struct cpuset *parent = parent_cs(cs);
-
+	if (cs->use_parent_ecpus)
 		cs->use_parent_ecpus = false;
-		parent->child_ecpus_count--;
-	}
 
 	cpuset_dec();
 	clear_bit(CS_ONLINE, &cs->flags);
-- 
2.34.1
Re: [PATCH v2 -next] cgroup/cpuset: remove child_ecpus_count
Posted by Tejun Heo 1 year, 4 months ago
On Wed, Jul 24, 2024 at 10:24:18AM +0000, Chen Ridong wrote:
> The child_ecpus_count variable was previously used to update
> sibling cpumask when parent's effective_cpus is updated. However, it became
> obsolete after commit e2ffe502ba45 ("cgroup/cpuset: Add
> cpuset.cpus.exclusive for v2"). It should be removed.
> 
> Signed-off-by: Chen Ridong <chenridong@huawei.com>

Applied to cgroup/for-6.12 w/ the {} Waiman pointed out Restored.

Thanks.

-- 
tejun
Re: [PATCH v2 -next] cgroup/cpuset: remove child_ecpus_count
Posted by Waiman Long 1 year, 4 months ago
On 7/24/24 06:24, Chen Ridong wrote:
> The child_ecpus_count variable was previously used to update
> sibling cpumask when parent's effective_cpus is updated. However, it became
> obsolete after commit e2ffe502ba45 ("cgroup/cpuset: Add
> cpuset.cpus.exclusive for v2"). It should be removed.
>
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
>   kernel/cgroup/cpuset.c | 25 ++++---------------------
>   1 file changed, 4 insertions(+), 21 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 40ec4abaf440..d4322619e59a 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -188,10 +188,8 @@ struct cpuset {
>   	/*
>   	 * Default hierarchy only:
>   	 * use_parent_ecpus - set if using parent's effective_cpus
> -	 * child_ecpus_count - # of children with use_parent_ecpus set
>   	 */
>   	int use_parent_ecpus;
> -	int child_ecpus_count;
>   
>   	/*
>   	 * number of SCHED_DEADLINE tasks attached to this cpuset, so that we
> @@ -1512,7 +1510,6 @@ static void reset_partition_data(struct cpuset *cs)
>   	if (!cpumask_and(cs->effective_cpus,
>   			 parent->effective_cpus, cs->cpus_allowed)) {
>   		cs->use_parent_ecpus = true;
> -		parent->child_ecpus_count++;
>   		cpumask_copy(cs->effective_cpus, parent->effective_cpus);
>   	}
>   }
> @@ -1688,12 +1685,8 @@ static int remote_partition_enable(struct cpuset *cs, int new_prs,
>   	spin_lock_irq(&callback_lock);
>   	isolcpus_updated = partition_xcpus_add(new_prs, NULL, tmp->new_cpus);
>   	list_add(&cs->remote_sibling, &remote_children);
> -	if (cs->use_parent_ecpus) {
> -		struct cpuset *parent = parent_cs(cs);
> -
> +	if (cs->use_parent_ecpus)
>   		cs->use_parent_ecpus = false;
> -		parent->child_ecpus_count--;
> -	}
>   	spin_unlock_irq(&callback_lock);
>   	update_unbound_workqueue_cpumask(isolcpus_updated);
>   
> @@ -2318,15 +2311,10 @@ static void update_cpumasks_hier(struct cpuset *cs, struct tmpmasks *tmp,
>   		 */
>   		if (is_in_v2_mode() && !remote && cpumask_empty(tmp->new_cpus)) {
>   			cpumask_copy(tmp->new_cpus, parent->effective_cpus);
> -			if (!cp->use_parent_ecpus) {
> +			if (!cp->use_parent_ecpus)
>   				cp->use_parent_ecpus = true;
> -				parent->child_ecpus_count++;
> -			}
> -		} else if (cp->use_parent_ecpus) {
> +		} else if (cp->use_parent_ecpus)
>   			cp->use_parent_ecpus = false;
> -			WARN_ON_ONCE(!parent->child_ecpus_count);
> -			parent->child_ecpus_count--;
> -		}
>   

The usual practice is to keep the {} in the else part even if it is a 
single statement when the if-part requires {}. Anyway, it is a minor issue.

Acked-by: Waiman Long <longman@redhat.com>