Skip to content

Commit c43c5ea

Browse files
committed
cgroup: Make cgroup_rstat_updated() ready for root cgroup usage
cgroup_rstat_updated() ensures that the cgroup's rstat is linked to the parent. If there's no parent, it never gets linked and the function ends up grabbing and releasing the cgroup_rstat_lock each time for no reason which can be expensive. This hasn't been a problem till now because nobody was calling the function for the root cgroup but rstat is gonna be exposed to controllers and use cases, so let's get ready. Make cgroup_rstat_updated() an no-op for the root cgroup. Signed-off-by: Tejun Heo <[email protected]>
1 parent 9a9e97b commit c43c5ea

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

kernel/cgroup/rstat.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ void cgroup_rstat_updated(struct cgroup *cgrp, int cpu)
2727
struct cgroup *parent;
2828
unsigned long flags;
2929

30+
/* nothing to do for root */
31+
if (!cgroup_parent(cgrp))
32+
return;
33+
3034
/*
3135
* Paired with the one in cgroup_rstat_cpu_pop_upated(). Either we
3236
* see NULL updated_next or they see our updated stat.

0 commit comments

Comments
 (0)