Commit 5faaf05f authored by Tejun Heo's avatar Tejun Heo

cgroup: Explicitly remove core interface files

The "cgroup." core interface files bypass the usual interface removal
path and get removed recursively along with the cgroup itself.  While
this works now, the subtle discrepancy gets in the way of implementing
common mechanisms.

This patch updates cgroup core interface file handling so that it's
consistent with controller interface files.  When added, the css is
marked CSS_VISIBLE and they're explicitly removed before the cgroup is
destroyed.

This doesn't cause user-visible behavior changes.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent fe03a759
...@@ -1573,8 +1573,17 @@ static void css_clear_dir(struct cgroup_subsys_state *css) ...@@ -1573,8 +1573,17 @@ static void css_clear_dir(struct cgroup_subsys_state *css)
css->flags &= ~CSS_VISIBLE; css->flags &= ~CSS_VISIBLE;
if (!css->ss) {
if (cgroup_on_dfl(cgrp))
cfts = cgroup_base_files;
else
cfts = cgroup1_base_files;
cgroup_addrm_files(css, cgrp, cfts, false);
} else {
list_for_each_entry(cfts, &css->ss->cfts, node) list_for_each_entry(cfts, &css->ss->cfts, node)
cgroup_addrm_files(css, cgrp, cfts, false); cgroup_addrm_files(css, cgrp, cfts, false);
}
} }
/** /**
...@@ -1598,9 +1607,10 @@ static int css_populate_dir(struct cgroup_subsys_state *css) ...@@ -1598,9 +1607,10 @@ static int css_populate_dir(struct cgroup_subsys_state *css)
else else
cfts = cgroup1_base_files; cfts = cgroup1_base_files;
return cgroup_addrm_files(&cgrp->self, cgrp, cfts, true); ret = cgroup_addrm_files(&cgrp->self, cgrp, cfts, true);
} if (ret < 0)
return ret;
} else {
list_for_each_entry(cfts, &css->ss->cfts, node) { list_for_each_entry(cfts, &css->ss->cfts, node) {
ret = cgroup_addrm_files(css, cgrp, cfts, true); ret = cgroup_addrm_files(css, cgrp, cfts, true);
if (ret < 0) { if (ret < 0) {
...@@ -1608,6 +1618,7 @@ static int css_populate_dir(struct cgroup_subsys_state *css) ...@@ -1608,6 +1618,7 @@ static int css_populate_dir(struct cgroup_subsys_state *css)
goto err; goto err;
} }
} }
}
css->flags |= CSS_VISIBLE; css->flags |= CSS_VISIBLE;
...@@ -5090,10 +5101,8 @@ static int cgroup_destroy_locked(struct cgroup *cgrp) ...@@ -5090,10 +5101,8 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
for_each_css(css, ssid, cgrp) for_each_css(css, ssid, cgrp)
kill_css(css); kill_css(css);
/* /* clear and remove @cgrp dir, @cgrp has an extra ref on its kn */
* Remove @cgrp directory along with the base files. @cgrp has an css_clear_dir(&cgrp->self);
* extra ref on its kn.
*/
kernfs_remove(cgrp->kn); kernfs_remove(cgrp->kn);
if (parent && cgroup_is_threaded(cgrp)) if (parent && cgroup_is_threaded(cgrp))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment