]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
cgroup/dmem: Don't open-code css_for_each_descendant_pre
authorFriedrich Vock <friedrich.vock@gmx.de>
Mon, 27 Jan 2025 15:27:52 +0000 (16:27 +0100)
committerMaarten Lankhorst <dev@lankhorst.se>
Wed, 19 Feb 2025 08:50:37 +0000 (09:50 +0100)
commit8821f36333e27c8355d4a730649923f938e1e4b9
tree6a10cabce67885683958d9608718c2425b689371
parentb3fefbb30a1691533cb905006b69b2a474660744
cgroup/dmem: Don't open-code css_for_each_descendant_pre

The current implementation has a bug: If the current css doesn't
contain any pool that is a descendant of the "pool" (i.e. when
found_descendant == false), then "pool" will point to some unrelated
pool. If the current css has a child, we'll overwrite parent_pool with
this unrelated pool on the next iteration.

Since we can just check whether a pool refers to the same region to
determine whether or not it's related, all the additional pool tracking
is unnecessary, so just switch to using css_for_each_descendant_pre for
traversal.

Fixes: b168ed458dde ("kernel/cgroup: Add "dmem" memory accounting cgroup")
Signed-off-by: Friedrich Vock <friedrich.vock@gmx.de>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250127152754.21325-1-friedrich.vock@gmx.de
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
kernel/cgroup/dmem.c