[PATCH -next RFC 15/16] cpuset: use partition_disable for update_prstate

Chen Ridong posted 16 patches 3 days, 14 hours ago
[PATCH -next RFC 15/16] cpuset: use partition_disable for update_prstate
Posted by Chen Ridong 3 days, 14 hours ago
From: Chen Ridong <chenridong@huawei.com>

The update_prstate() function currently handles partition state transitions
by directly manipulating partition-related fields. However, when a
partition is enabled or disabled through the proper interfaces, these
fields are already set correctly, making the direct manipulation redundant.

This patch refactors the logic to use partition_disable() when partition
errors are detected, ensuring consistent state management. For successful
state transitions, the partition-related fields are set appropriately.

This change eliminates redundant field manipulation and centralizes
partition state management through the established partition_disable()
interface, improving code maintainability and consistency.

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

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 2aaa688c596f..a22cf97e6af5 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -2961,17 +2961,8 @@ static int update_prstate(struct cpuset *cs, int new_prs)
 	 * Make partition invalid & disable CS_CPU_EXCLUSIVE if an error
 	 * happens.
 	 */
-	if (err) {
-		new_prs = -new_prs;
-		update_partition_exclusive_flag(cs, new_prs);
-	}
-
-	spin_lock_irq(&callback_lock);
-	cs->partition_root_state = new_prs;
-	WRITE_ONCE(cs->prs_err, err);
-	if (!is_partition_valid(cs))
-		reset_partition_data(cs);
-	spin_unlock_irq(&callback_lock);
+	if (err)
+		partition_disable(cs, parent, -new_prs, err);
 
 	/* Force update if switching back to member & update effective_xcpus */
 	update_cpumasks_hier(cs, &tmpmask, !new_prs);
@@ -2983,7 +2974,6 @@ static int update_prstate(struct cpuset *cs, int new_prs)
 	/* Update sched domains and load balance flag */
 	update_partition_sd_lb(cs, old_prs);
 
-	notify_partition_change(cs, old_prs);
 	if (force_sd_rebuild)
 		rebuild_sched_domains_locked();
 	free_tmpmasks(&tmpmask);
-- 
2.34.1