]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commit
cgroup, rstat: Don't flush subtree root unless necessary
authorTejun Heo <tj@kernel.org>
Fri, 15 Feb 2019 19:01:31 +0000 (11:01 -0800)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 14 May 2019 18:55:24 +0000 (20:55 +0200)
commit8cae5553ef7ea68cc5de5b3b425b820e98716c14
treee2a5bc25434daf4c596b1d61902d3c8c3936eb9f
parent559529865414550c86fb202c62bb9dfff9782712
cgroup, rstat: Don't flush subtree root unless necessary

BugLink: https://bugs.launchpad.net/bugs/1828410
[ Upstream commit b4ff1b44bcd384d22fcbac6ebaf9cc0d33debe50 ]

cgroup_rstat_cpu_pop_updated() is used to traverse the updated cgroups
on flush.  While it was only visiting updated ones in the subtree, it
was visiting @root unconditionally.  We can easily check whether @root
is updated or not by looking at its ->updated_next just as with the
cgroups in the subtree.

* Remove the unnecessary cgroup_parent() test.  The system root cgroup
  is never updated and thus its ->updated_next is always NULL.  No
  need to test whether cgroup_parent() exists in addition to
  ->updated_next.

* Terminate traverse if ->updated_next is NULL.  This can only happen
  for subtree @root and there's no reason to visit it if it's not
  marked updated.

This reduces cpu consumption when reading a lot of rstat backed files.
In a micro benchmark reading stat from ~1600 cgroups, the sys time was
lowered by >40%.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
kernel/cgroup/rstat.c