Skip to content

Commit

Permalink
cgroup: Make cgroup_rstat_updated() ready for root cgroup usage
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
htejun authored and xxmustafacooTR committed Apr 22, 2023
1 parent 9e5fc06 commit e3ba9c4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/cgroup/rstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ void cgroup_rstat_updated(struct cgroup *cgrp, int cpu)
struct cgroup *parent;
unsigned long flags;

/* nothing to do for root */
if (!cgroup_parent(cgrp))
return;

/*
* Paired with the one in cgroup_rstat_cpu_pop_upated(). Either we
* see NULL updated_next or they see our updated stat.
Expand Down

0 comments on commit e3ba9c4

Please sign in to comment.