Skip to content

Commit 822bc9b

Browse files
shakeelbhtejun
authored andcommitted
cgroup: no need for cgroup_mutex for /proc/cgroups
On the real systems, the cgroups hierarchies are setup early and just once by the node controller, so, other than number of cgroups, all information in /proc/cgroups remain same for the system uptime. Let's remove the cgroup_mutex usage on reading /proc/cgroups. There is a chance of inconsistent number of cgroups for co-mounted cgroups while printing the information from /proc/cgroups but that is not a big issue. In addition /proc/cgroups is a v1 specific interface, so the dependency on it should reduce over time. The main motivation for removing the cgroup_mutex from /proc/cgroups is to reduce the avenues of its contention. On our fleet, we have observed buggy application hammering on /proc/cgroups and drastically slowing down the node controller on the system which have many negative consequences on other workloads running on the system. Signed-off-by: Shakeel Butt <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent bb75842 commit 822bc9b

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

kernel/cgroup/cgroup-v1.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -659,19 +659,16 @@ int proc_cgroupstats_show(struct seq_file *m, void *v)
659659

660660
seq_puts(m, "#subsys_name\thierarchy\tnum_cgroups\tenabled\n");
661661
/*
662-
* ideally we don't want subsystems moving around while we do this.
663-
* cgroup_mutex is also necessary to guarantee an atomic snapshot of
664-
* subsys/hierarchy state.
662+
* Grab the subsystems state racily. No need to add avenue to
663+
* cgroup_mutex contention.
665664
*/
666-
mutex_lock(&cgroup_mutex);
667665

668666
for_each_subsys(ss, i)
669667
seq_printf(m, "%s\t%d\t%d\t%d\n",
670668
ss->legacy_name, ss->root->hierarchy_id,
671669
atomic_read(&ss->root->nr_cgrps),
672670
cgroup_ssid_enabled(i));
673671

674-
mutex_unlock(&cgroup_mutex);
675672
return 0;
676673
}
677674

0 commit comments

Comments
 (0)