WSL2-Linux-Kernel/kernel/cgroup
Johannes Weiner dc26532aed 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: https://lkml.kernel.org/r/20210209163304.77088-6-hannes@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Roman Gushchin <guro@fb.com>
Cc: Shakeel Butt <shakeelb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-04-30 11:20:37 -07:00
..
Makefile cgroup: Add misc cgroup controller 2021-04-04 13:34:46 -04:00
cgroup-internal.h
cgroup-v1.c cgroup: use tsk->in_iowait instead of delayacct_is_task_waiting_on_io() 2021-04-16 16:49:37 -04:00
cgroup.c cgroup: rstat: support cgroup1 2021-04-30 11:20:37 -07:00
cpuset.c cgroup/cpuset: fix typos in comments 2021-04-12 17:20:53 -04:00
debug.c
freezer.c
legacy_freezer.c
misc.c svm/sev: Register SEV and SEV-ES ASIDs to the misc controller 2021-04-04 13:34:46 -04:00
namespace.c
pids.c
rdma.c
rstat.c cgroup: rstat: punt root-level optimization to individual controllers 2021-04-30 11:20:37 -07:00