mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cgroup/cpuset: prevent overlapping local and remote partition creation
@ 2026-09-19 22:17 Hui Peng
  2026-09-20  1:22 ` Ridong Chen
  2026-09-20  6:30 ` [PATCH] cgroup/cpuset: prevent overlapping local and remote partition creation Guopeng Zhang
  0 siblings, 2 replies; 8+ messages in thread
From: Hui Peng @ 2026-09-19 22:17 UTC (permalink / raw)
  To: longman, ridong.chen, tj, hannes, mkoutny; +Cc: cgroups, linux-kernel

Fix two partition validation bugs in kernel/cgroup/cpuset.c:

1. In remote_partition_enable(), check whether the requested effective
   xcpus intersect parent->subpartitions_cpus so a remote partition
   cannot claim CPUs already delegated to a local child partition.
2. In validate_partition(), verify that enabling a local partition does
   not overlap CPUs already allocated to an active remote partition.

Fixes: aa7d3a56a20f ("cpuset: fix warning when disabling remote partition")
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 2538faac9aba..13fad096c494 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -713,7 +713,10 @@ static inline bool cpus_excl_conflict(struct cpuset *trial, struct cpuset *sibli
 		return true;
 
 	/* Exclusive_cpus cannot intersect */
-	return cpumask_intersects(trial->exclusive_cpus, sibling->exclusive_cpus);
+	return cpumask_intersects(trial->exclusive_cpus,
+				  cpumask_empty(sibling->exclusive_cpus)
+				  ? sibling->effective_xcpus
+				  : sibling->exclusive_cpus);
 }
 
 static inline bool mems_excl_conflict(struct cpuset *cs1, struct cpuset *cs2)
@@ -1591,8 +1594,8 @@ static int remote_partition_enable(struct cpuset *cs, int new_prs,
 	 * above it or remote partition root underneath it is not allowed.
 	 */
 	compute_excpus(cs, tmp->new_cpus);
-	WARN_ON_ONCE(cpumask_intersects(tmp->new_cpus, subpartitions_cpus));
 	if (!cpumask_intersects(tmp->new_cpus, cpu_active_mask) ||
+	    cpumask_intersects(tmp->new_cpus, subpartitions_cpus) ||
 	    cpumask_subset(top_cpuset.effective_cpus, tmp->new_cpus))
 		return PERR_INVCPUS;
 	if (((new_prs == PRS_ISOLATED) &&
@@ -2411,6 +2414,10 @@ static enum prs_errcode validate_partition(struct cpuset *cs, struct cpuset *tri
 	if (cpumask_empty(trialcs->effective_xcpus))
 		return PERR_INVCPUS;
 
+	if ((parent == &top_cpuset) &&
+	    cpumask_intersects(trialcs->effective_xcpus, subpartitions_cpus))
+		return PERR_REMOTE;
+
 	if (prstate_housekeeping_conflict(trialcs->partition_root_state,
 					  trialcs->effective_xcpus))
 		return PERR_HKEEPING;
@@ -2970,7 +2977,7 @@ static int update_prstate(struct cpuset *cs, int new_prs)
 		 * local or remote partition.
 		 */
 		if ((parent == &top_cpuset) &&
-		    cpumask_intersects(cs->exclusive_cpus, subpartitions_cpus)) {
+		    cpumask_intersects(user_xcpus(cs), subpartitions_cpus)) {
 			err = PERR_REMOTE;
 			goto out;
 		}

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-09-20  8:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-19 22:17 [PATCH] cgroup/cpuset: prevent overlapping local and remote partition creation Hui Peng
2026-09-20  1:22 ` Ridong Chen
2026-09-20  3:04   ` Hui Peng
2026-09-20  8:23   ` [PATCH v2 1/2] cgroup/cpuset: return PERR_NOCPUS in remote_partition_enable() on subpartitions_cpus conflict Hui Peng
2026-09-20  8:23     ` [PATCH v2 2/2] cgroup/cpuset: prevent local partition activation over remote partition and sibling xcpus conflict Hui Peng
2026-09-20  8:57       ` Guopeng Zhang
2026-09-20  6:30 ` [PATCH] cgroup/cpuset: prevent overlapping local and remote partition creation Guopeng Zhang
2026-09-20  8:23   ` Hui Peng

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®