diff options
author | Tejun Heo <tj@kernel.org> | 2016-03-03 09:57:58 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2016-03-03 09:57:58 -0500 |
commit | 88cb04b96a1934ecbfd1d324e7cde55890c1a576 (patch) | |
tree | 7dc80e8c3054d07ed8a7cc54c738eeae50a69513 /kernel | |
parent | 6cd0f5bbaf594f40a97d01dbc565dda41f30d37c (diff) | |
download | linux-88cb04b96a1934ecbfd1d324e7cde55890c1a576.tar.gz linux-88cb04b96a1934ecbfd1d324e7cde55890c1a576.tar.bz2 linux-88cb04b96a1934ecbfd1d324e7cde55890c1a576.zip |
cgroup: explicitly track whether a cgroup_subsys_state is visible to userland
Currently, whether a css (cgroup_subsys_state) has its interface files
created is not tracked and assumed to change together with the owning
cgroup's lifecycle. cgroup directory and interface creation is being
separated out from internal object creation to help refactoring and
eventually allow cgroups which are not visible through cgroupfs.
This patch adds CSS_VISIBLE to track whether a css has its interface
files created and perform management operations only when necessary
which helps decoupling interface file handling from internal object
lifecycle. After this patch, all css interface file management
functions can be called regardless of the current state and will
achieve the expected result.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Zefan Li <lizefan@huawei.com>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cgroup.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 4178e45becb4..a9a53ca942f3 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -1421,6 +1421,11 @@ static void css_clear_dir(struct cgroup_subsys_state *css, struct cgroup *cgrp = cgrp_override ?: css->cgroup; struct cftype *cfts; + if (!(css->flags & CSS_VISIBLE)) + return; + + css->flags &= ~CSS_VISIBLE; + list_for_each_entry(cfts, &css->ss->cfts, node) cgroup_addrm_files(css, cgrp, cfts, false); } @@ -1439,6 +1444,9 @@ static int css_populate_dir(struct cgroup_subsys_state *css, struct cftype *cfts, *failed_cfts; int ret; + if (css->flags & CSS_VISIBLE) + return 0; + if (!css->ss) { if (cgroup_on_dfl(cgrp)) cfts = cgroup_dfl_base_files; @@ -1455,6 +1463,9 @@ static int css_populate_dir(struct cgroup_subsys_state *css, goto err; } } + + css->flags |= CSS_VISIBLE; + return 0; err: list_for_each_entry(cfts, &css->ss->cfts, node) { @@ -3403,7 +3414,7 @@ static int cgroup_apply_cftypes(struct cftype *cfts, bool is_add) css_for_each_descendant_pre(css, cgroup_css(root, ss)) { struct cgroup *cgrp = css->cgroup; - if (cgroup_is_dead(cgrp)) + if (!(css->flags & CSS_VISIBLE)) continue; ret = cgroup_addrm_files(css, cgrp, cfts, is_add); |