cgroup/rstat: Improve cgroup_rstat_push_children() documentation
authorWaiman Long <longman@redhat.com>
Fri, 25 Apr 2025 03:16:55 +0000 (23:16 -0400)
committerTejun Heo <tj@kernel.org>
Fri, 25 Apr 2025 19:45:16 +0000 (09:45 -1000)
commit8f52633cf5ebe1fb9c4814b6590f824cf906b346
tree56e2b80a33c854b5e85cf4617fe151f81170933c
parentf304da9134f8c245d198502ad681ffae63b5e29c
cgroup/rstat: Improve cgroup_rstat_push_children() documentation

The cgroup_rstat_push_children() function converts a set of
updated_children lists from different cgroups into a single ordered
list of cgroups to be flushed via the rstat_flush_next pointer.
The algorithm used isn't that well illustrated and it takes time to
grasp what it is doing. Improve the embedded documentation and variable
names to better illustrate the transformation process and make the code
easier to understand.

Also cgroup_rstat_lock must be held for the whole duration
from where the rstat_flush_next list is being constructed in
cgroup_rstat_push_children() to when it is consumed later in
css_rstat_flush(). Otherwise, list corruption can happen leading to
system crash as reported in [1]. In this particular case, the branch
being used has commit 093c8812de2d ("cgroup: rstat: Cleanup flushing
functions and locking") which breaks this rule, but is missing the fix
commit 7d6c63c31914 ("cgroup: rstat: call cgroup_rstat_updated_list
with cgroup_rstat_lock") that fixes it.

This patch has no functional change.

[1] https://lore.kernel.org/lkml/BY5PR04MB68495E9E8A46CA9614D62669BCBB2@BY5PR04MB6849.namprd04.prod.outlook.com/

Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/rstat.c