<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/kernel/cgroup, branch master</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>Merge tag 'cgroup-for-7.4-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup</title>
<updated>2026-11-15T22:17:31+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2026-11-15T22:17:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=4b15991b3be43e9581aca489ec30a351310bb49d'/>
<id>4b15991b3be43e9581aca489ec30a351310bb49d</id>
<content type='text'>
Pull cgroup fixes from Tejun Heo:

 - A file notification racing the file's removal could re-arm the
   notification timer after it was shut down, corrupting the timer wheel
   or firing on freed memory.

 - The v1 freezer could leave an exiting task frozen forever after its
   cgroup was thawed or removed.

 - With memcg built without the block cgroup controller, memcg reclaim
   waited on writeback and could deadlock against a filesystem freeze.
   memcg now selects the controller.

 - cpuset partition state could go wrong when CPUs move between nested
   partitions or go offline: isolated CPUs leaked or went missing,
   invalid partitions kept exclusive CPUs or came back with no usable
   CPU, and expanding a remote partition could fail. Separately, a
   forked child could inherit a corrupted memory node mask.

* tag 'cgroup-for-7.4-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
  cgroup/cpuset: Don't revive invalid partition without active CPU on hotplug
  cgroup/cpuset: Remove redundant WARN_ON_ONCE() in remote_cpus_update()
  memcg: make MEMCG select BLK_CGROUP
  cpuset: generalize the validate_partition() interface
  cpuset: settle isolation state when CPUs are given back to parent
  cgroup/cpuset: Correctly set isolated_cpus when switching partition state
  cgroup/cpuset: Protect current-&gt;mems_allowed read in cpuset_fork()
  selftests/cgroup: Fix "test_cpuset_prs.sh -v" failures
  cpuset: add early empty cpumask check in partition_xcpus_add/del
  cgroup/cpuset: Reset partition data when an invalid partition stays invalid
  cgroup/freezer: Fix exiting tasks left frozen forever after rmdir
  cgroup/freezer: walk exiting tasks in the v1 freezer
  cgroup: arm the notify timer only while the file exists
  cgroup/cpuset: Do housekeeping check when isolated child with root parent may get more xcpus
  cgroup/cpuset: Recompute effective cpumask in update_cpumasks_hier() after calling update_parent_effective_cpumask()
  cgroup/cpuset: Fix incorrect CPU accounting with parent's effective_xcpus expansion
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull cgroup fixes from Tejun Heo:

 - A file notification racing the file's removal could re-arm the
   notification timer after it was shut down, corrupting the timer wheel
   or firing on freed memory.

 - The v1 freezer could leave an exiting task frozen forever after its
   cgroup was thawed or removed.

 - With memcg built without the block cgroup controller, memcg reclaim
   waited on writeback and could deadlock against a filesystem freeze.
   memcg now selects the controller.

 - cpuset partition state could go wrong when CPUs move between nested
   partitions or go offline: isolated CPUs leaked or went missing,
   invalid partitions kept exclusive CPUs or came back with no usable
   CPU, and expanding a remote partition could fail. Separately, a
   forked child could inherit a corrupted memory node mask.

* tag 'cgroup-for-7.4-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup:
  cgroup/cpuset: Don't revive invalid partition without active CPU on hotplug
  cgroup/cpuset: Remove redundant WARN_ON_ONCE() in remote_cpus_update()
  memcg: make MEMCG select BLK_CGROUP
  cpuset: generalize the validate_partition() interface
  cpuset: settle isolation state when CPUs are given back to parent
  cgroup/cpuset: Correctly set isolated_cpus when switching partition state
  cgroup/cpuset: Protect current-&gt;mems_allowed read in cpuset_fork()
  selftests/cgroup: Fix "test_cpuset_prs.sh -v" failures
  cpuset: add early empty cpumask check in partition_xcpus_add/del
  cgroup/cpuset: Reset partition data when an invalid partition stays invalid
  cgroup/freezer: Fix exiting tasks left frozen forever after rmdir
  cgroup/freezer: walk exiting tasks in the v1 freezer
  cgroup: arm the notify timer only while the file exists
  cgroup/cpuset: Do housekeeping check when isolated child with root parent may get more xcpus
  cgroup/cpuset: Recompute effective cpumask in update_cpumasks_hier() after calling update_parent_effective_cpumask()
  cgroup/cpuset: Fix incorrect CPU accounting with parent's effective_xcpus expansion
</pre>
</div>
</content>
</entry>
<entry>
<title>cgroup/cpuset: Don't revive invalid partition without active CPU on hotplug</title>
<updated>2026-11-15T20:15:12+00:00</updated>
<author>
<name>Ridong Chen</name>
<email>chenridong@xiaomi.com</email>
</author>
<published>2026-11-14T12:05:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=acec9637e03ca54bd3c3a0c1a6ad5c6dfa07c0df'/>
<id>acec9637e03ca54bd3c3a0c1a6ad5c6dfa07c0df</id>
<content type='text'>
When a CPU hotplug leaves no CPU outside of the partitions for the top
cpuset, cpuset_handle_hotplug() clears subpartitions_cpus and gives all
the active CPUs back to the top cpuset. cpuset_hotplug_update_tasks()
then walks the hierarchy and invalidates the partitions, as
subpartitions_cpus is empty.

However, an invalid partition visited in the same walk may be revived
if its effective_xcpus is not empty. tasks_nocpu_error() doesn't catch
it when its CPUs are all offline but it has no task. Its CPUs are put
back into subpartitions_cpus, and the valid partitions visited after it
are no longer invalidated, as subpartitions_cpus is not empty any more.
The top cpuset is left with CPUs overlapping with these partitions.

It can be reproduced on a system with 8 CPUs:

  # cd /sys/fs/cgroup
  # echo +cpuset &gt; cgroup.subtree_control
  # mkdir A1 B1
  # echo 1 &gt; A1/cpuset.cpus
  # echo 1 &gt; A1/cpuset.cpus.exclusive
  # echo 0,2-7 &gt; B1/cpuset.cpus
  # echo root &gt; B1/cpuset.cpus.partition
  # echo root &gt; A1/cpuset.cpus.partition
  # cat A1/cpuset.cpus.partition
  root invalid (Parent unable to distribute cpu downstream)
  # echo 0 &gt; /sys/devices/system/cpu/cpu1/online
  # cat A1/cpuset.cpus.partition B1/cpuset.cpus.partition
  root
  root
  # cat cpuset.cpus.effective
  0,2-7

A1 can't take CPU 1, the last CPU of the root cgroup which has tasks.
When CPU 1 is offlined, A1 is revived without any active CPU, and B1
stays valid while its CPUs are also in the effective CPUs of the root
cgroup, which triggers

  WARNING: kernel/cgroup/cpuset.c:919 at rebuild_sched_domains_locked

Only revive an invalid partition in hotplug if its effective_xcpus has
an active CPU, the same as what is required to create a partition with
tasks. With that, A1 and B1 are both invalidated in the above case.

Fixes: 0c7f293efc87 ("cgroup/cpuset: Add cpuset.cpus.exclusive.effective for v2")
Cc: stable@vger.kernel.org # v6.7+
Reported-by: Sashiko &lt;sashiko-bot@kernel.org&gt;
Link: https://sashiko.dev/#/patchset/20261114083124.1340140-1-ridong.chen%40linux.dev?part=11
Signed-off-by: Ridong Chen &lt;chenridong@xiaomi.com&gt;
Reviewed-by: Waiman Long &lt;longman@redhat.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When a CPU hotplug leaves no CPU outside of the partitions for the top
cpuset, cpuset_handle_hotplug() clears subpartitions_cpus and gives all
the active CPUs back to the top cpuset. cpuset_hotplug_update_tasks()
then walks the hierarchy and invalidates the partitions, as
subpartitions_cpus is empty.

However, an invalid partition visited in the same walk may be revived
if its effective_xcpus is not empty. tasks_nocpu_error() doesn't catch
it when its CPUs are all offline but it has no task. Its CPUs are put
back into subpartitions_cpus, and the valid partitions visited after it
are no longer invalidated, as subpartitions_cpus is not empty any more.
The top cpuset is left with CPUs overlapping with these partitions.

It can be reproduced on a system with 8 CPUs:

  # cd /sys/fs/cgroup
  # echo +cpuset &gt; cgroup.subtree_control
  # mkdir A1 B1
  # echo 1 &gt; A1/cpuset.cpus
  # echo 1 &gt; A1/cpuset.cpus.exclusive
  # echo 0,2-7 &gt; B1/cpuset.cpus
  # echo root &gt; B1/cpuset.cpus.partition
  # echo root &gt; A1/cpuset.cpus.partition
  # cat A1/cpuset.cpus.partition
  root invalid (Parent unable to distribute cpu downstream)
  # echo 0 &gt; /sys/devices/system/cpu/cpu1/online
  # cat A1/cpuset.cpus.partition B1/cpuset.cpus.partition
  root
  root
  # cat cpuset.cpus.effective
  0,2-7

A1 can't take CPU 1, the last CPU of the root cgroup which has tasks.
When CPU 1 is offlined, A1 is revived without any active CPU, and B1
stays valid while its CPUs are also in the effective CPUs of the root
cgroup, which triggers

  WARNING: kernel/cgroup/cpuset.c:919 at rebuild_sched_domains_locked

Only revive an invalid partition in hotplug if its effective_xcpus has
an active CPU, the same as what is required to create a partition with
tasks. With that, A1 and B1 are both invalidated in the above case.

Fixes: 0c7f293efc87 ("cgroup/cpuset: Add cpuset.cpus.exclusive.effective for v2")
Cc: stable@vger.kernel.org # v6.7+
Reported-by: Sashiko &lt;sashiko-bot@kernel.org&gt;
Link: https://sashiko.dev/#/patchset/20261114083124.1340140-1-ridong.chen%40linux.dev?part=11
Signed-off-by: Ridong Chen &lt;chenridong@xiaomi.com&gt;
Reviewed-by: Waiman Long &lt;longman@redhat.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cgroup/cpuset: Remove redundant WARN_ON_ONCE() in remote_cpus_update()</title>
<updated>2026-11-15T20:15:02+00:00</updated>
<author>
<name>Ridong Chen</name>
<email>chenridong@xiaomi.com</email>
</author>
<published>2026-11-14T10:06:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=42ef815ff6b282e75248e8e084508fca4a694b70'/>
<id>42ef815ff6b282e75248e8e084508fca4a694b70</id>
<content type='text'>
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-&gt;addmask, subpartitions_cpus));
	if (!capable(CAP_SYS_ADMIN))
		WRITE_ONCE(cs-&gt;prs_err, PERR_ACCESS);
	else if (cpumask_intersects(tmp-&gt;addmask, subpartitions_cpus) ||
		 cpumask_subset(top_cpuset.effective_cpus, tmp-&gt;addmask))
		WRITE_ONCE(cs-&gt;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.

Reported-by: Sashiko &lt;sashiko-bot@kernel.org&gt;
Link: https://sashiko.dev/#/patchset/20261114083124.1340140-1-ridong.chen%40linux.dev?part=6
Signed-off-by: Ridong Chen &lt;chenridong@xiaomi.com&gt;
Reviewed-by: Waiman Long &lt;longman@redhat.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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-&gt;addmask, subpartitions_cpus));
	if (!capable(CAP_SYS_ADMIN))
		WRITE_ONCE(cs-&gt;prs_err, PERR_ACCESS);
	else if (cpumask_intersects(tmp-&gt;addmask, subpartitions_cpus) ||
		 cpumask_subset(top_cpuset.effective_cpus, tmp-&gt;addmask))
		WRITE_ONCE(cs-&gt;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.

Reported-by: Sashiko &lt;sashiko-bot@kernel.org&gt;
Link: https://sashiko.dev/#/patchset/20261114083124.1340140-1-ridong.chen%40linux.dev?part=6
Signed-off-by: Ridong Chen &lt;chenridong@xiaomi.com&gt;
Reviewed-by: Waiman Long &lt;longman@redhat.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cpuset: generalize the validate_partition() interface</title>
<updated>2026-11-13T19:23:33+00:00</updated>
<author>
<name>Ridong Chen</name>
<email>chenridong@xiaomi.com</email>
</author>
<published>2026-11-12T03:19:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e234ed1bb82c96a5643fd70784f16cf3d72eeed3'/>
<id>e234ed1bb82c96a5643fd70784f16cf3d72eeed3</id>
<content type='text'>
Refactor validate_partition() to take the parent partition, the new
partition root state, the new effective exclusive CPUs and the CPUs to
be deleted, instead of a trial cpuset. A NULL parent stands for a
remote partition, whose CPUs come from top_cpuset. This makes the
interface flexible enough to handle both local and remote partition
validation.

This also fixes a false PERR_NOCPUS error when expanding a remote
partition. The no CPU left for tasks check in partition_cpus_change()
is done against the cgroup parent, but the CPUs of a remote partition
come from top_cpuset, not from its parent. For example, on a 4-CPU
system:

  echo 2-3 &gt; P/cpuset.cpus
  echo 2-3 &gt; P/cpuset.cpus.exclusive
  echo 2-3 &gt; P/C/cpuset.cpus
  echo 2 &gt; P/C/cpuset.cpus.exclusive
  echo root &gt; P/C/cpuset.cpus.partition
  (a task in P)
  echo 2-3 &gt; P/C/cpuset.cpus.exclusive
  cat P/C/cpuset.cpus.partition
  root invalid (Parent is not a partition root)

The effective_cpus of P is 3, a subset of the new exclusive CPUs 2-3 of
C, and P has a task, so the expansion is rejected. However, P is not a
partition root and does not give any CPU to C, and top_cpuset still has
CPUs 0-1 for the task. Enabling C directly with exclusive CPUs 2-3
succeeds, as remote_partition_enable() checks top_cpuset instead.

The no CPU left for tasks check now uses the given parent instead of
parent_cs(cs), and top_cpuset for a remote partition, as that is where
its CPUs are taken from.

The housekeeping conflict check is folded into validate_partition(). It
is skipped when the parent is not a valid partition root, as @cs can't
be a valid local partition in that case.

Use the new interface for local partition enablement in
update_parent_effective_cpumask() and in partition_cpus_change(),
replacing the open-coded checks there. The order of the checks is now
the same for both paths: empty CPUs, housekeeping conflict, then no CPU
left for tasks.

Add a test case to test_cpuset_prs.sh for the remote partition
expansion above.

Fixes: 181c8e091aae ("cgroup/cpuset: Introduce remote partition")
Signed-off-by: Ridong Chen &lt;chenridong@xiaomi.com&gt;
Reviewed-by: Guopeng Zhang &lt;zhangguopeng@kylinos.cn&gt;
Reviewed-by: Waiman Long &lt;longman@redhat.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Refactor validate_partition() to take the parent partition, the new
partition root state, the new effective exclusive CPUs and the CPUs to
be deleted, instead of a trial cpuset. A NULL parent stands for a
remote partition, whose CPUs come from top_cpuset. This makes the
interface flexible enough to handle both local and remote partition
validation.

This also fixes a false PERR_NOCPUS error when expanding a remote
partition. The no CPU left for tasks check in partition_cpus_change()
is done against the cgroup parent, but the CPUs of a remote partition
come from top_cpuset, not from its parent. For example, on a 4-CPU
system:

  echo 2-3 &gt; P/cpuset.cpus
  echo 2-3 &gt; P/cpuset.cpus.exclusive
  echo 2-3 &gt; P/C/cpuset.cpus
  echo 2 &gt; P/C/cpuset.cpus.exclusive
  echo root &gt; P/C/cpuset.cpus.partition
  (a task in P)
  echo 2-3 &gt; P/C/cpuset.cpus.exclusive
  cat P/C/cpuset.cpus.partition
  root invalid (Parent is not a partition root)

The effective_cpus of P is 3, a subset of the new exclusive CPUs 2-3 of
C, and P has a task, so the expansion is rejected. However, P is not a
partition root and does not give any CPU to C, and top_cpuset still has
CPUs 0-1 for the task. Enabling C directly with exclusive CPUs 2-3
succeeds, as remote_partition_enable() checks top_cpuset instead.

The no CPU left for tasks check now uses the given parent instead of
parent_cs(cs), and top_cpuset for a remote partition, as that is where
its CPUs are taken from.

The housekeeping conflict check is folded into validate_partition(). It
is skipped when the parent is not a valid partition root, as @cs can't
be a valid local partition in that case.

Use the new interface for local partition enablement in
update_parent_effective_cpumask() and in partition_cpus_change(),
replacing the open-coded checks there. The order of the checks is now
the same for both paths: empty CPUs, housekeeping conflict, then no CPU
left for tasks.

Add a test case to test_cpuset_prs.sh for the remote partition
expansion above.

Fixes: 181c8e091aae ("cgroup/cpuset: Introduce remote partition")
Signed-off-by: Ridong Chen &lt;chenridong@xiaomi.com&gt;
Reviewed-by: Guopeng Zhang &lt;zhangguopeng@kylinos.cn&gt;
Reviewed-by: Waiman Long &lt;longman@redhat.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cpuset: settle isolation state when CPUs are given back to parent</title>
<updated>2026-11-13T19:23:28+00:00</updated>
<author>
<name>Ridong Chen</name>
<email>chenridong@xiaomi.com</email>
</author>
<published>2026-11-12T03:19:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c1ad01173511e8aec378af9f5285f98b767b1381'/>
<id>c1ad01173511e8aec378af9f5285f98b767b1381</id>
<content type='text'>
partition_xcpus_del() only updates isolated_cpus when the partition that
gives back the CPUs has a different state than its parent. CPUs that were
further distributed to descendant isolated partitions are not taken into
account, so isolated_cpus_release() has to be called afterwards in
several places to walk up the ancestors and fix isolated_cpus.

This misses some cases and leaks isolated CPUs, as reported by Guopeng.
An isolated partition can be invalidated after its parent has already
become invalid, and its CPUs are left in isolated_cpus. For example, on a
32-CPU system with all CPUs online and without isolcpus= or nohz_full=
boot parameters:

  cd /sys/fs/cgroup
  echo +cpuset &gt; cgroup.subtree_control
  mkdir A
  echo 0,2-31 &gt; A/cpuset.cpus
  echo root &gt; A/cpuset.cpus.partition
  echo +cpuset &gt; A/cgroup.subtree_control
  mkdir A/B
  echo 2-3 &gt; A/B/cpuset.cpus
  echo isolated &gt; A/B/cpuset.cpus.partition
  cat cpuset.cpus.isolated
  2-3
  echo 0 &gt; /sys/devices/system/cpu/cpu1/online
  cat A/B/cpuset.cpus.partition
  isolated invalid
  cat cpuset.cpus.isolated
  2-3

When A is invalidated, partition_xcpus_del() gives CPUs 0,2-31 back to
top cpuset. Both A and top cpuset are root partitions, so isolated_cpus
is left untouched although CPUs 2-3 were distributed to the isolated B.
B is then invalidated with an invalid parent, and nothing releases CPUs
2-3 either.

Make partition_xcpus_del() always set the isolation state of the given
back CPUs to the state of the parent that receives them. As the
effective_xcpus of a partition covers the CPUs distributed to its
descendants, the isolation state of those CPUs is settled at the same
time. Boot-time isolated CPUs are still preserved by isolated_cpu_update().

compute_partition_effective_cpumask() invalidates a child partition
without going through partition_xcpus_del(), so do the same there: the
CPUs of the invalidated child take the isolation state of its parent.

As the parent may be shrunk and its effective_xcpus not updated yet,
only do so for the CPUs the parent still owns. This is to keep the
isolation state correct for now, the in-place invalidation here will be
removed later in the partition rework.

isolated_cpus_update() assumes the old and new states are different,
which no longer holds now that partition_xcpus_del() proceeds regardless
of the states. Drop its @old_prs argument and the WARN_ON_ONCE() so that
it simply sets the isolation state of the given CPUs, and use it
everywhere. The state check in partition_xcpus_add() is dropped as well,
as setting the state is a no-op when the states are the same.

isolated_cpus_release() is no longer needed and is removed.

Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partitions")
Reported-by: Guopeng Zhang &lt;zhangguopeng@kylinos.cn&gt;
Closes: https://lore.kernel.org/all/20261105130344.664336-4-guopeng.zhang@linux.dev/
Signed-off-by: Ridong Chen &lt;chenridong@xiaomi.com&gt;
Reviewed-by: Guopeng Zhang &lt;zhangguopeng@kylinos.cn&gt;
Reviewed-by: Waiman Long &lt;longman@redhat.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
partition_xcpus_del() only updates isolated_cpus when the partition that
gives back the CPUs has a different state than its parent. CPUs that were
further distributed to descendant isolated partitions are not taken into
account, so isolated_cpus_release() has to be called afterwards in
several places to walk up the ancestors and fix isolated_cpus.

This misses some cases and leaks isolated CPUs, as reported by Guopeng.
An isolated partition can be invalidated after its parent has already
become invalid, and its CPUs are left in isolated_cpus. For example, on a
32-CPU system with all CPUs online and without isolcpus= or nohz_full=
boot parameters:

  cd /sys/fs/cgroup
  echo +cpuset &gt; cgroup.subtree_control
  mkdir A
  echo 0,2-31 &gt; A/cpuset.cpus
  echo root &gt; A/cpuset.cpus.partition
  echo +cpuset &gt; A/cgroup.subtree_control
  mkdir A/B
  echo 2-3 &gt; A/B/cpuset.cpus
  echo isolated &gt; A/B/cpuset.cpus.partition
  cat cpuset.cpus.isolated
  2-3
  echo 0 &gt; /sys/devices/system/cpu/cpu1/online
  cat A/B/cpuset.cpus.partition
  isolated invalid
  cat cpuset.cpus.isolated
  2-3

When A is invalidated, partition_xcpus_del() gives CPUs 0,2-31 back to
top cpuset. Both A and top cpuset are root partitions, so isolated_cpus
is left untouched although CPUs 2-3 were distributed to the isolated B.
B is then invalidated with an invalid parent, and nothing releases CPUs
2-3 either.

Make partition_xcpus_del() always set the isolation state of the given
back CPUs to the state of the parent that receives them. As the
effective_xcpus of a partition covers the CPUs distributed to its
descendants, the isolation state of those CPUs is settled at the same
time. Boot-time isolated CPUs are still preserved by isolated_cpu_update().

compute_partition_effective_cpumask() invalidates a child partition
without going through partition_xcpus_del(), so do the same there: the
CPUs of the invalidated child take the isolation state of its parent.

As the parent may be shrunk and its effective_xcpus not updated yet,
only do so for the CPUs the parent still owns. This is to keep the
isolation state correct for now, the in-place invalidation here will be
removed later in the partition rework.

isolated_cpus_update() assumes the old and new states are different,
which no longer holds now that partition_xcpus_del() proceeds regardless
of the states. Drop its @old_prs argument and the WARN_ON_ONCE() so that
it simply sets the isolation state of the given CPUs, and use it
everywhere. The state check in partition_xcpus_add() is dropped as well,
as setting the state is a no-op when the states are the same.

isolated_cpus_release() is no longer needed and is removed.

Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partitions")
Reported-by: Guopeng Zhang &lt;zhangguopeng@kylinos.cn&gt;
Closes: https://lore.kernel.org/all/20261105130344.664336-4-guopeng.zhang@linux.dev/
Signed-off-by: Ridong Chen &lt;chenridong@xiaomi.com&gt;
Reviewed-by: Guopeng Zhang &lt;zhangguopeng@kylinos.cn&gt;
Reviewed-by: Waiman Long &lt;longman@redhat.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cgroup/cpuset: Correctly set isolated_cpus when switching partition state</title>
<updated>2026-11-10T19:21:40+00:00</updated>
<author>
<name>Waiman Long</name>
<email>longman@redhat.com</email>
</author>
<published>2026-11-10T02:24:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=56681bc448a80bb2473026b41c44c133766bc38d'/>
<id>56681bc448a80bb2473026b41c44c133766bc38d</id>
<content type='text'>
When update_prstate() is called to switch the partition state from
root to isolated or vice versa, the whole effective_xcpus is passed to
isolated_cpus_update(). However, if there are child partitions present,
some of the effective_xcpus are dedicated to those child partitions
and their partition states will remain the same or get invalidated in
the case of child root partition with isolated parent in the latter
update_cpumasks_hier() call. In the latter case, their exclusive CPUs
will be returned to their parent.

Therefore isolated_cpus may be set incorrectly with child partitions
underneath. Fix that by excluding their exclusive CPUs in computing
the correct cpumask of exclusive CPUs used by that partition alone.

Add new test cases into test_cpuset_prs.sh to test for such cases.

Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partitions")
Cc: stable@vger.kernel.org # v6.8+
Signed-off-by: Waiman Long &lt;longman@redhat.com&gt;
Reviewed-by: Ridong Chen &lt;ridong.chen@linux.dev&gt;
Tested-by: Ridong Chen &lt;ridong.chen@linux.dev&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When update_prstate() is called to switch the partition state from
root to isolated or vice versa, the whole effective_xcpus is passed to
isolated_cpus_update(). However, if there are child partitions present,
some of the effective_xcpus are dedicated to those child partitions
and their partition states will remain the same or get invalidated in
the case of child root partition with isolated parent in the latter
update_cpumasks_hier() call. In the latter case, their exclusive CPUs
will be returned to their parent.

Therefore isolated_cpus may be set incorrectly with child partitions
underneath. Fix that by excluding their exclusive CPUs in computing
the correct cpumask of exclusive CPUs used by that partition alone.

Add new test cases into test_cpuset_prs.sh to test for such cases.

Fixes: 11e5f407b64a ("cgroup/cpuset: Keep track of CPUs in isolated partitions")
Cc: stable@vger.kernel.org # v6.8+
Signed-off-by: Waiman Long &lt;longman@redhat.com&gt;
Reviewed-by: Ridong Chen &lt;ridong.chen@linux.dev&gt;
Tested-by: Ridong Chen &lt;ridong.chen@linux.dev&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cgroup/cpuset: Protect current-&gt;mems_allowed read in cpuset_fork()</title>
<updated>2026-11-10T19:21:13+00:00</updated>
<author>
<name>Waiman Long</name>
<email>longman@redhat.com</email>
</author>
<published>2026-11-09T19:09:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a25cc4c75fdd8921f160bc3950665889eba7374b'/>
<id>a25cc4c75fdd8921f160bc3950665889eba7374b</id>
<content type='text'>
Reading mems_allowed of the current task outside of cpuset_mutex critical
section should be protected by using mems_allowed_seq seqlock as the
nodemask can be updated concurrently leading to a torn read. Such
protection is currently not implemented in cpuset_fork() for the
!CLONE_INTO_CGROUP case. As a result, the child task may inherit an empty
or corrupted mems_allowed nodemask. This violates NUMA memory policy
constraints and causes subsequent page allocations to unconditionally
fail, potentially leading to crashes or spurious OOM killer invocations
for the child task.

Fix that by using a read_mems_allowed_begin/read_mems_allowed_retry()
loop to protect the mems_allowed read.

Fixes: 06f4e9489891 ("cpuset: make sure new tasks conform to the current config of the cpuset")
Reported-by: Sashiko &lt;sashiko-bot@kernel.org&gt;
Link: https://sashiko.dev/#/bug/linux-601100b4-fa77-45fd-99f9-bfbd4385201f
Signed-off-by: Waiman Long &lt;longman@redhat.com&gt;
Reviewed-by: Ridong Chen &lt;ridong.chen@linux.dev&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reading mems_allowed of the current task outside of cpuset_mutex critical
section should be protected by using mems_allowed_seq seqlock as the
nodemask can be updated concurrently leading to a torn read. Such
protection is currently not implemented in cpuset_fork() for the
!CLONE_INTO_CGROUP case. As a result, the child task may inherit an empty
or corrupted mems_allowed nodemask. This violates NUMA memory policy
constraints and causes subsequent page allocations to unconditionally
fail, potentially leading to crashes or spurious OOM killer invocations
for the child task.

Fix that by using a read_mems_allowed_begin/read_mems_allowed_retry()
loop to protect the mems_allowed read.

Fixes: 06f4e9489891 ("cpuset: make sure new tasks conform to the current config of the cpuset")
Reported-by: Sashiko &lt;sashiko-bot@kernel.org&gt;
Link: https://sashiko.dev/#/bug/linux-601100b4-fa77-45fd-99f9-bfbd4385201f
Signed-off-by: Waiman Long &lt;longman@redhat.com&gt;
Reviewed-by: Ridong Chen &lt;ridong.chen@linux.dev&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>selftests/cgroup: Fix "test_cpuset_prs.sh -v" failures</title>
<updated>2026-11-10T19:20:58+00:00</updated>
<author>
<name>Waiman Long</name>
<email>longman@redhat.com</email>
</author>
<published>2026-11-09T19:09:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=8ef0c923104b4ba38249b364867d779f5a9b5dbe'/>
<id>8ef0c923104b4ba38249b364867d779f5a9b5dbe</id>
<content type='text'>
When the -v option is used to run test_cpuset_prs.sh, it activates the
use of sched-debug to determine the set of isolated CPUs which will
also consider 1-CPU partition as being isolated though they will not be
reflected in "cpuset.cpus.isolated". As a result, some of the expected
isolated CPUs values have 2 different set of values to correspond to
these two ways of determining isolated CPUs.

Commit 362212853cd0 ("cgroup/cpuset: Fix incorrect CPU accounting with
parent's effective_xcpus expansion") introduces some new test cases
which fail when the -v option is used. Update the test cases to make
them pass with the -v option as well.

Also remove an obsolete comment in update_parent_effective_cpumask()
of cpuset.c.

Reported-by: Tejun Heo &lt;tj@kernel.org&gt;
Link: https://lore.kernel.org/lkml/886a562b52b1c5094142d547a8336457@kernel.org
Fixes: 362212853cd0 ("cgroup/cpuset: Fix incorrect CPU accounting with parent's effective_xcpus expansion")
Signed-off-by: Waiman Long &lt;longman@redhat.com&gt;
Reviewed-by: Ridong Chen &lt;ridong.chen@linux.dev&gt;
Tested-by: Ridong Chen &lt;ridong.chen@linux.dev&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When the -v option is used to run test_cpuset_prs.sh, it activates the
use of sched-debug to determine the set of isolated CPUs which will
also consider 1-CPU partition as being isolated though they will not be
reflected in "cpuset.cpus.isolated". As a result, some of the expected
isolated CPUs values have 2 different set of values to correspond to
these two ways of determining isolated CPUs.

Commit 362212853cd0 ("cgroup/cpuset: Fix incorrect CPU accounting with
parent's effective_xcpus expansion") introduces some new test cases
which fail when the -v option is used. Update the test cases to make
them pass with the -v option as well.

Also remove an obsolete comment in update_parent_effective_cpumask()
of cpuset.c.

Reported-by: Tejun Heo &lt;tj@kernel.org&gt;
Link: https://lore.kernel.org/lkml/886a562b52b1c5094142d547a8336457@kernel.org
Fixes: 362212853cd0 ("cgroup/cpuset: Fix incorrect CPU accounting with parent's effective_xcpus expansion")
Signed-off-by: Waiman Long &lt;longman@redhat.com&gt;
Reviewed-by: Ridong Chen &lt;ridong.chen@linux.dev&gt;
Tested-by: Ridong Chen &lt;ridong.chen@linux.dev&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cpuset: add early empty cpumask check in partition_xcpus_add/del</title>
<updated>2026-11-09T15:23:09+00:00</updated>
<author>
<name>Chen Ridong</name>
<email>chenridong@huawei.com</email>
</author>
<published>2026-11-07T12:00:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=93eb230146f8c6246b0b96e7f1b980ac5e8b8d81'/>
<id>93eb230146f8c6246b0b96e7f1b980ac5e8b8d81</id>
<content type='text'>
Add a check for an empty cpumask at the start of partition_xcpus_add()
and partition_xcpus_del(). This allows the functions to return early,
avoiding unnecessary computation when there is no work to be done. With
these changes, partition_xcpus_add() and partition_xcpus_del() can be
called even if xcpus is empty. The caller no longer needs to check whether
xcpus is empty, eliminating many conditional statements.

Signed-off-by: Chen Ridong &lt;chenridong@huawei.com&gt;
Reviewed-by: Guopeng Zhang &lt;zhangguopeng@kylinos.cn&gt;
Reviewed-by: Waiman Long &lt;longman@redhat.com&gt;
Signed-off-by: Ridong Chen &lt;chenridong@xiaomi.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add a check for an empty cpumask at the start of partition_xcpus_add()
and partition_xcpus_del(). This allows the functions to return early,
avoiding unnecessary computation when there is no work to be done. With
these changes, partition_xcpus_add() and partition_xcpus_del() can be
called even if xcpus is empty. The caller no longer needs to check whether
xcpus is empty, eliminating many conditional statements.

Signed-off-by: Chen Ridong &lt;chenridong@huawei.com&gt;
Reviewed-by: Guopeng Zhang &lt;zhangguopeng@kylinos.cn&gt;
Reviewed-by: Waiman Long &lt;longman@redhat.com&gt;
Signed-off-by: Ridong Chen &lt;chenridong@xiaomi.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cgroup/cpuset: Reset partition data when an invalid partition stays invalid</title>
<updated>2026-11-09T15:23:03+00:00</updated>
<author>
<name>Ridong Chen</name>
<email>chenridong@xiaomi.com</email>
</author>
<published>2026-11-07T12:00:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ba4834fc81ddc0b500843c827c09d3ff95a317a9'/>
<id>ba4834fc81ddc0b500843c827c09d3ff95a317a9</id>
<content type='text'>
When cpuset.cpus or cpuset.cpus.exclusive of a partition root is
changed, update_cpumask() and update_exclusive_cpumask() copy the new
effective_xcpus computed for the trial cpuset into the cpuset, and call
reset_partition_data() only if the partition was valid before and is
invalid now:

	if ((old_prs &gt; 0) &amp;&amp; !is_partition_valid(cs))
		reset_partition_data(cs);

An invalid partition root (old_prs &lt; 0) that stays invalid is not
covered. Its effective_xcpus is then left with the trial value, which
is computed from user_xcpus() and so falls back to cpuset.cpus when
cpuset.cpus.exclusive is cleared. As an invalid partition root does not
own any exclusive CPUs, and rm_siblings_excl_cpus() treats a non-empty
effective_xcpus of a sibling without cpuset.cpus.exclusive as owned,
those CPUs can then no longer be claimed by a sibling:

  # A1: cpuset.cpus=2-3, cpuset.cpus.exclusive=2-3, root, with tasks
  # offline CPUs 2-3 -&gt; A1 becomes invalid
  echo &gt; A1/cpuset.cpus.exclusive
  cat A1/cpuset.cpus.exclusive.effective    # 2-3, expected empty
  echo 3 &gt; B1/cpuset.cpus.exclusive         # -EINVAL

Reset the partition data whenever the cpuset is a partition root, valid
or not, and ends up invalid. As effective_xcpus may be cleared by that,
also force update_cpumasks_hier() to update the subtree, so that the
effective_xcpus of the descendants doesn't keep the released CPUs. Add
test cases for it.

Fixes: de9f15e21c55 ("cpuset: use parse_cpulist for setting cpus.exclusive")
Fixes: c5866c9a007d ("cpuset: refactor CPU mask buffer parsing logic")
Reported-by: Sashiko &lt;sashiko-bot@kernel.org&gt;
Link: https://sashiko.dev/#/patchset/20261101114206.2434398-1-ridong.chen%40linux.dev?part=15
Reviewed-by: Waiman Long &lt;longman@redhat.com&gt;
Signed-off-by: Ridong Chen &lt;chenridong@xiaomi.com&gt;
Reviewed-by: Guopeng Zhang &lt;zhangguopeng@kylinos.cn&gt;
Tested-by: Guopeng Zhang &lt;zhangguopeng@kylinos.cn&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When cpuset.cpus or cpuset.cpus.exclusive of a partition root is
changed, update_cpumask() and update_exclusive_cpumask() copy the new
effective_xcpus computed for the trial cpuset into the cpuset, and call
reset_partition_data() only if the partition was valid before and is
invalid now:

	if ((old_prs &gt; 0) &amp;&amp; !is_partition_valid(cs))
		reset_partition_data(cs);

An invalid partition root (old_prs &lt; 0) that stays invalid is not
covered. Its effective_xcpus is then left with the trial value, which
is computed from user_xcpus() and so falls back to cpuset.cpus when
cpuset.cpus.exclusive is cleared. As an invalid partition root does not
own any exclusive CPUs, and rm_siblings_excl_cpus() treats a non-empty
effective_xcpus of a sibling without cpuset.cpus.exclusive as owned,
those CPUs can then no longer be claimed by a sibling:

  # A1: cpuset.cpus=2-3, cpuset.cpus.exclusive=2-3, root, with tasks
  # offline CPUs 2-3 -&gt; A1 becomes invalid
  echo &gt; A1/cpuset.cpus.exclusive
  cat A1/cpuset.cpus.exclusive.effective    # 2-3, expected empty
  echo 3 &gt; B1/cpuset.cpus.exclusive         # -EINVAL

Reset the partition data whenever the cpuset is a partition root, valid
or not, and ends up invalid. As effective_xcpus may be cleared by that,
also force update_cpumasks_hier() to update the subtree, so that the
effective_xcpus of the descendants doesn't keep the released CPUs. Add
test cases for it.

Fixes: de9f15e21c55 ("cpuset: use parse_cpulist for setting cpus.exclusive")
Fixes: c5866c9a007d ("cpuset: refactor CPU mask buffer parsing logic")
Reported-by: Sashiko &lt;sashiko-bot@kernel.org&gt;
Link: https://sashiko.dev/#/patchset/20261101114206.2434398-1-ridong.chen%40linux.dev?part=15
Reviewed-by: Waiman Long &lt;longman@redhat.com&gt;
Signed-off-by: Ridong Chen &lt;chenridong@xiaomi.com&gt;
Reviewed-by: Guopeng Zhang &lt;zhangguopeng@kylinos.cn&gt;
Tested-by: Guopeng Zhang &lt;zhangguopeng@kylinos.cn&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
