[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251117024627.1128037-4-chenridong@huaweicloud.com>
Date: Mon, 17 Nov 2025 02:46:09 +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 -next 03/21] cpuset: introduce partition_enable()
From: Chen Ridong <chenridong@...wei.com>
Add partition_enable() to consolidate updates to key cpuset structures
during partition enablement, including:
1. remote_partition
2. effective_xcpus
3. partition_root_state
4. prs_err
Key operations performed:
1. Invokes partition_xcpus_add() to assign exclusive CPUs
2. Maintains remote partition flag
3. Syncs the effective_xcpus mask
4. Updates partition_root_state and prs_err
5. Triggers scheduler domain rebuilds
6. 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 | 48 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 392a0436a19d..b917f2c55767 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1638,6 +1638,54 @@ static enum prs_errcode validate_partition(struct cpuset *cs, int new_prs,
return PERR_NONE;
}
+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)
+{
+ 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 */
+ partition_xcpus_add(new_prs, parent, new_excpus);
+ /* enable remote partition */
+ if (!parent)
+ cs->remote_partition = true;
+ cpumask_copy(cs->effective_xcpus, new_excpus);
+ partition_state_update(cs, new_prs, PERR_NONE);
+ spin_unlock_irq(&callback_lock);
+ update_isolation_cpumasks();
+ cpuset_force_rebuild();
+ notify_partition_change(cs, old_prs);
+}
+
/*
* remote_partition_enable - Enable current cpuset as a remote partition root
* @cs: the cpuset to update
--
2.34.1
Powered by blists - more mailing lists