path: root/mm/memcontrol.c
diff options
authorJohannes Weiner <>2021-04-29 22:56:23 -0700
committerLinus Torvalds <>2021-04-30 11:20:37 -0700
commitdc26532aed0ab25c0801a34640d1f3b9b9098a48 (patch)
tree152e51668c486e29284789fd43e50111fa09baf7 /mm/memcontrol.c
parenta7df69b81aac5bdeb5c5aef9addd680ce22feebf (diff)
cgroup: rstat: punt root-level optimization to individual controllers
Current users of the rstat code can source root-level statistics from the native counters of their respective subsystem, allowing them to forego aggregation at the root level. This optimization is currently implemented inside the generic rstat code, which doesn't track the root cgroup and doesn't invoke the subsystem flush callbacks on it. However, the memory controller cannot do this optimization, because cgroup1 breaks out memory specifically for the local level, including at the root level. In preparation for the memory controller switching to rstat, move the optimization from rstat core to the controllers. Afterwards, rstat will always track the root cgroup for changes and invoke the subsystem callbacks on it; and it's up to the subsystem to special-case and skip aggregation of the root cgroup if it can source this information through other, cheaper means. This is the case for the io controller and the cgroup base stats. In their respective flush callbacks, check whether the parent is the root cgroup, and if so, skip the unnecessary upward propagation. The extra cost of tracking the root cgroup is negligible: on stat changes, we actually remove a branch that checks for the root. The queueing for a flush touches only per-cpu data, and only the first stat change since a flush requires a (per-cpu) lock. Link: Signed-off-by: Johannes Weiner <> Acked-by: Tejun Heo <> Cc: Michal Hocko <> Cc: Michal Koutný <> Cc: Roman Gushchin <> Cc: Shakeel Butt <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'mm/memcontrol.c')
0 files changed, 0 insertions, 0 deletions