You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the cgroup_propagate_frozen function, during unfreezing (when frozen is false), the code subtracts desc (which increments for each unfrozen parent) from each ancestor's nr_frozen_descendants. This results in over-subtraction, leading to negative counts and incorrect frozen states.
kernel/cgroup/freezer.c
Example Scenario:
Hierarchy: A -> B -> C
All cgroups (A, B, C) are frozen.
Unfreeze C:
Current Code: Subtracts desc=1 from B's count (correctly setting it to 0). Then subtracts desc=2 from A's count, reducing it from 2 to 0. If A has another frozen child D, this incorrectly sets A's count to 0 instead of 1 (since D is still frozen).
Additional Considerations
Negative Count Prevention: Added WARN_ON_ONCE to catch underflows, though proper decrement by 1 should prevent negatives.
Propagation Continuation: The loop continues upwards until all affected ancestors are updated.
The identified bug leads to incorrect frozen state propagation, particularly in hierarchical cgroups. The proposed fix corrects the decrement logic during unfreezing, ensuring accurate nr_frozen_descendants counts and proper state transitions. This issue warrants a kernel patch to prevent system instability from incorrect cgroup freezing.
Steps to reproduce the behaviour
Test Case: Incorrect unfreezing of parent cgroup when one of multiple frozen descendants is unfrozen.
# Freeze C and D (A and B will auto-freeze via propagation)echo 1 > /sys/fs/cgroup/A/B/C/cgroup.freeze
echo 1 > /sys/fs/cgroup/A/D/cgroup.freeze
Verify All Cgroups Are Frozen:
cat /sys/fs/cgroup/A/cgroup.freeze # Should show 1 (frozen)
cat /sys/fs/cgroup/A/B/cgroup.freeze # Should show 1 (frozen)
cat /sys/fs/cgroup/A/B/C/cgroup.freeze # Should show 1 (frozen)
cat /sys/fs/cgroup/A/D/cgroup.freeze # Should show 1 (frozen)
kernel/cgroup/freezer.c is unchanged from upstream.
I think you'll have better luck reporting this issue upstream - it is unlikely to be a Pi specific issue,
and there may be developers of this actual code who can comment.
Your detailed report should be helpful to the maintainers.
Describe the bug
In the
cgroup_propagate_frozen
function, during unfreezing (whenfrozen
is false), the code subtractsdesc
(which increments for each unfrozen parent) from each ancestor'snr_frozen_descendants
. This results in over-subtraction, leading to negative counts and incorrect frozen states.kernel/cgroup/freezer.c
Example Scenario:
desc=1
from B's count (correctly setting it to 0). Then subtractsdesc=2
from A's count, reducing it from 2 to 0. If A has another frozen child D, this incorrectly sets A's count to 0 instead of 1 (since D is still frozen).Additional Considerations
WARN_ON_ONCE
to catch underflows, though proper decrement by 1 should prevent negatives.The identified bug leads to incorrect frozen state propagation, particularly in hierarchical cgroups. The proposed fix corrects the decrement logic during unfreezing, ensuring accurate
nr_frozen_descendants
counts and proper state transitions. This issue warrants a kernel patch to prevent system instability from incorrect cgroup freezing.Steps to reproduce the behaviour
Test Case: Incorrect unfreezing of parent cgroup when one of multiple frozen descendants is unfrozen.
# Create cgroups mkdir /sys/fs/cgroup/A mkdir /sys/fs/cgroup/A/B mkdir /sys/fs/cgroup/A/D mkdir /sys/fs/cgroup/A/B/C
Expected Behavior:
A
should remain frozen because its descendantD
is still frozen.B
should unfreeze (correctly) because its only descendantC
was unfrozen.Actual Behavior (with Bug):
A
incorrectly unfreezes due to over-decrement innr_frozen_descendants
.Debugging Tips:
ftrace
to monitorcgroup_propagate_frozen
calls:Device (s)
Other
System
rpi-6.6.y
Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: