[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251025064844.495525-5-chenridong@huaweicloud.com>
Date: Sat, 25 Oct 2025 06:48:26 +0000
From: Chen Ridong <chenridong@...weicloud.com>
To: longman@...hat.com,
tj@...nel.org,
hannes@...xchg.org,
mkoutny@...e.com
Cc: cgroups@...r.kernel.org,
linux-kernel@...r.kernel.org,
lujialin4@...wei.com,
chenridong@...wei.com
Subject: [PATCH RFC v2 04/22] cpuset: introduce partition_enable()
From: Chen Ridong <chenridong@...wei.com>
Add partition_enable() to consolidate updates to key cpuset structures
during partition enablement, including:
- remote_sibling
- effective_xcpus
- partition_root_state
- prs_err
Key operations performed:
- Invokes partition_xcpus_add() to assign exclusive CPUs
- Maintains remote partition sibling links
- Syncs the effective_xcpus mask
- Updates partition_root_state and prs_err
- Triggers scheduler domain rebuilds
- Sends partition change notifications
This helper enables transitions between root and isolated states. All
fields except remote_sibling are reassigned during the transition.
Signed-off-by: Chen Ridong <chenridong@...wei.com>
---
kernel/cgroup/cpuset.c | 49 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 493e094961da..c767d1be6bbb 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1521,6 +1521,55 @@ static inline bool is_local_partition(struct cpuset *cs)
return is_partition_valid(cs) && !is_remote_partition(cs);
}
+static void partition_state_update(struct cpuset *cs, int new_prs,
+ enum prs_errcode prs_err)
+{
+ lockdep_assert_held(&callback_lock);
+
+ cs->partition_root_state = new_prs;
+ WRITE_ONCE(cs->prs_err, prs_err);
+ if (!is_partition_valid(cs))
+ reset_partition_data(cs);
+}
+
+/**
+ * partition_enable - Transitions a cpuset to a partition root
+ * @cs: The cpuset to enable partition for
+ * @parent: Parent cpuset of @cs, NULL for remote parent
+ * @new_prs: New partition state to set
+ * @new_excpus: New effective exclusive CPUs mask for the partition
+ *
+ * Transitions a cpuset to a partition root, only for v2.
+ * It supports the transition between root and isolated partition.
+ */
+static void partition_enable(struct cpuset *cs, struct cpuset *parent,
+ int new_prs, struct cpumask *new_excpus)
+{
+ bool isolcpus_updated;
+ int old_prs;
+
+ lockdep_assert_held(&cpuset_mutex);
+ WARN_ON_ONCE(new_prs <= 0);
+ WARN_ON_ONCE(!cpuset_v2());
+
+ if (cs->partition_root_state == new_prs)
+ return;
+
+ old_prs = cs->partition_root_state;
+ spin_lock_irq(&callback_lock);
+ /* enable partition should only add exclusive cpus */
+ isolcpus_updated = partition_xcpus_add(new_prs, parent, new_excpus);
+ /* enable remote partition */
+ if (!parent && list_empty(&cs->remote_sibling))
+ list_add(&cs->remote_sibling, &remote_children);
+ cpumask_copy(cs->effective_xcpus, new_excpus);
+ partition_state_update(cs, new_prs, PERR_NONE);
+ spin_unlock_irq(&callback_lock);
+ update_unbound_workqueue_cpumask(isolcpus_updated);
+ cpuset_force_rebuild();
+ notify_partition_change(cs, old_prs);
+}
+
/*
* prstate_housekeeping_conflict - check for partition & housekeeping conflicts
* @prstate: partition root state to be checked
--
2.34.1
Powered by blists - more mailing lists