Skip to contentSkip to conversation

cgroup/cpuset: Remove redundant WARN_ON_ONCE() in remote_cpus_update()

PATCH Applied Ridong Chen 3 participants 3 messages Nov 14 – Nov 15

Subsystems (2)
lore
Share & tools
lore

Ridong Chen

author reviewer
#0 lore raw

PATCH 1/1 cgroup/cpuset: Remove redundant WARN_ON_ONCE() in remote_cpus_update()

From: Ridong Chen <[email protected]>

remote_cpus_update() warns if the CPUs to be added to a remote partition intersect subpartitions_cpus, and then checks the very same condition right below to set PERR_NOCPUS and invalidate the partition:

	WARN_ON_ONCE(cpumask_intersects(tmp->addmask, subpartitions_cpus));
	if (!capable(CAP_SYS_ADMIN))
		WRITE_ONCE(cs->prs_err, PERR_ACCESS);
	else if (cpumask_intersects(tmp->addmask, subpartitions_cpus) ||
		 cpumask_subset(top_cpuset.effective_cpus, tmp->addmask))
		WRITE_ONCE(cs->prs_err, PERR_NOCPUS);

Sashiko reported that the warning could be triggered by a write to a cpuset control file, before the CAP_SYS_ADMIN check, which would panic a system with panic_on_warn set.

The warning was added by commit 86888c7bd117 ("cgroup/cpuset: Add warnings to catch inconsistency in exclusive CPUs") as an assertion that such CPUs have been filtered out before. No way to trigger it with the current interfaces has been found, as these CPUs are rejected when cpuset.cpus.exclusive is written. But the warning is redundant, as the conflict is handled right below anyway.

Remove the warning and rely on the PERR_NOCPUS check, the same as remote_partition_enable() already does for this conflict.

---
 kernel/cgroup/cpuset.c | 1 -
 1 file changed, 1 deletion(-)
kernel/cgroup/cpuset.c +0 -1
index 7e374210c123..0be0d26c442b 100644
@@ -1833,7 +1833,6 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus,
 	 * left in the top cpuset.
 	 */
 	if (adding) {
-		WARN_ON_ONCE(cpumask_intersects(tmp->addmask, subpartitions_cpus));
 		if (!capable(CAP_SYS_ADMIN))
 			WRITE_ONCE(cs->prs_err, PERR_ACCESS);
 		else if (cpumask_intersects(tmp->addmask, subpartitions_cpus) ||

base-commit: e234ed1bb82c96a5643fd70784f16cf3d72eeed3

Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 47 lines · Ridong Chen

From: Ridong Chen <[email protected]>

remote_cpus_update() warns if the CPUs to be added to a remote partition intersect subpartitions_cpus, and then checks the very same condition right below to set PERR_NOCPUS and invalidate the partition:

	WARN_ON_ONCE(cpumask_intersects(tmp->addmask, subpartitions_cpus));
	if (!capable(CAP_SYS_ADMIN))
		WRITE_ONCE(cs->prs_err, PERR_ACCESS);
	else if (cpumask_intersects(tmp->addmask, subpartitions_cpus) ||
		 cpumask_subset(top_cpuset.effective_cpus, tmp->addmask))
		WRITE_ONCE(cs->prs_err, PERR_NOCPUS);

Sashiko reported that the warning could be triggered by a write to a cpuset control file, before the CAP_SYS_ADMIN check, which would panic a system with panic_on_warn set.

The warning was added by commit 86888c7bd117 ("cgroup/cpuset: Add warnings to catch inconsistency in exclusive CPUs") as an assertion that such CPUs have been filtered out before. No way to trigger it with the current interfaces has been found, as these CPUs are rejected when cpuset.cpus.exclusive is written. But the warning is redundant, as the conflict is handled right below anyway.

Remove the warning and rely on the PERR_NOCPUS check, the same as remote_partition_enable() already does for this conflict.

---
  kernel/cgroup/cpuset.c | 1 -
  1 file changed, 1 deletion(-)
kernel/cgroup/cpuset.c +0 -1
index 7e374210c123..0be0d26c442b 100644
@@ -1833,7 +1833,6 @@ static void remote_cpus_update(struct cpuset *cs, struct cpumask *xcpus,
  	 * left in the top cpuset.
  	 */
  	if (adding) {
-		WARN_ON_ONCE(cpumask_intersects(tmp->addmask, subpartitions_cpus));
  		if (!capable(CAP_SYS_ADMIN))
  			WRITE_ONCE(cs->prs_err, PERR_ACCESS);
  		else if (cpumask_intersects(tmp->addmask, subpartitions_cpus) ||
Quoted 1 line

base-commit: e234ed1bb82c96a5643fd70784f16cf3d72eeed3