summaryrefslogtreecommitdiffstats
path: root/kernel/cgroup/cgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2018-04-26 17:29:04 -0400
committerTejun Heo <tj@kernel.org>2018-04-26 17:29:04 -0400
commit5faaf05f2976fd9ec0ecd582bcfb3a41cde4c65e (patch)
tree85c27210cddbf635eb8ae4ed6a94825826710c9d /kernel/cgroup/cgroup.c
parentfe03a7594d86e0754f05e604cd803a6a9aae3c1c (diff)
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: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup/cgroup.c')
-rw-r--r--kernel/cgroup/cgroup.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index a662bfcbea0e..25309c868728 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -1573,8 +1573,17 @@ static void css_clear_dir(struct cgroup_subsys_state *css)
1573 1573
1574 css->flags &= ~CSS_VISIBLE; 1574 css->flags &= ~CSS_VISIBLE;
1575 1575
1576 list_for_each_entry(cfts, &css->ss->cfts, node) 1576 if (!css->ss) {
1577 if (cgroup_on_dfl(cgrp))
1578 cfts = cgroup_base_files;
1579 else
1580 cfts = cgroup1_base_files;
1581
1577 cgroup_addrm_files(css, cgrp, cfts, false); 1582 cgroup_addrm_files(css, cgrp, cfts, false);
1583 } else {
1584 list_for_each_entry(cfts, &css->ss->cfts, node)
1585 cgroup_addrm_files(css, cgrp, cfts, false);
1586 }
1578} 1587}
1579 1588
1580/** 1589/**
@@ -1598,14 +1607,16 @@ static int css_populate_dir(struct cgroup_subsys_state *css)
1598 else 1607 else
1599 cfts = cgroup1_base_files; 1608 cfts = cgroup1_base_files;
1600 1609
1601 return cgroup_addrm_files(&cgrp->self, cgrp, cfts, true); 1610 ret = cgroup_addrm_files(&cgrp->self, cgrp, cfts, true);
1602 } 1611 if (ret < 0)
1603 1612 return ret;
1604 list_for_each_entry(cfts, &css->ss->cfts, node) { 1613 } else {
1605 ret = cgroup_addrm_files(css, cgrp, cfts, true); 1614 list_for_each_entry(cfts, &css->ss->cfts, node) {
1606 if (ret < 0) { 1615 ret = cgroup_addrm_files(css, cgrp, cfts, true);
1607 failed_cfts = cfts; 1616 if (ret < 0) {
1608 goto err; 1617 failed_cfts = cfts;
1618 goto err;
1619 }
1609 } 1620 }
1610 } 1621 }
1611 1622
@@ -5090,10 +5101,8 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
5090 for_each_css(css, ssid, cgrp) 5101 for_each_css(css, ssid, cgrp)
5091 kill_css(css); 5102 kill_css(css);
5092 5103
5093 /* 5104 /* clear and remove @cgrp dir, @cgrp has an extra ref on its kn */
5094 * Remove @cgrp directory along with the base files. @cgrp has an 5105 css_clear_dir(&cgrp->self);
5095 * extra ref on its kn.
5096 */
5097 kernfs_remove(cgrp->kn); 5106 kernfs_remove(cgrp->kn);
5098 5107
5099 if (parent && cgroup_is_threaded(cgrp)) 5108 if (parent && cgroup_is_threaded(cgrp))