Skip to content

Commit

Permalink
cgroup: Add named hierarchy disabling to cgroup_no_v1 boot param
Browse files Browse the repository at this point in the history
It can be useful to inhibit all cgroup1 hierarchies especially during
transition and for debugging.  cgroup_no_v1 can block hierarchies with
controllers which leaves out the named hierarchies.  Expand it to
cover the named hierarchies so that "cgroup_no_v1=all,named" disables
all cgroup1 hierarchies.

Signed-off-by: Tejun Heo <tj@kernel.org>
Suggested-by: Marcin Pawlowski <mpawlowski@fb.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
htejun committed Dec 28, 2018
1 parent e250d91 commit 3fc9c12
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Documentation/admin-guide/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,14 @@
cut the overhead, others just disable the usage. So
only cgroup_disable=memory is actually worthy}

cgroup_no_v1= [KNL] Disable one, multiple, all cgroup controllers in v1
Format: { controller[,controller...] | "all" }
cgroup_no_v1= [KNL] Disable cgroup controllers and named hierarchies in v1
Format: { { controller | "all" | "named" }
[,{ controller | "all" | "named" }...] }
Like cgroup_disable, but only applies to cgroup v1;
the blacklisted controllers remain available in cgroup2.
"all" blacklists all controllers and "named" disables
named mounts. Specifying both "all" and "named" disables
all v1 hierarchies.

cgroup.memory= [KNL] Pass options to the cgroup memory controller.
Format: <string>
Expand Down
14 changes: 13 additions & 1 deletion kernel/cgroup/cgroup-v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
/* Controllers blocked by the commandline in v1 */
static u16 cgroup_no_v1_mask;

/* disable named v1 mounts */
static bool cgroup_no_v1_named;

/*
* pidlist destructions need to be flushed on cgroup destruction. Use a
* separate workqueue as flush domain.
Expand Down Expand Up @@ -963,6 +966,10 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
}
if (!strncmp(token, "name=", 5)) {
const char *name = token + 5;

/* blocked by boot param? */
if (cgroup_no_v1_named)
return -ENOENT;
/* Can't specify an empty name */
if (!strlen(name))
return -EINVAL;
Expand Down Expand Up @@ -1292,7 +1299,12 @@ static int __init cgroup_no_v1(char *str)

if (!strcmp(token, "all")) {
cgroup_no_v1_mask = U16_MAX;
break;
continue;
}

if (!strcmp(token, "named")) {
cgroup_no_v1_named = true;
continue;
}

for_each_subsys(ss, i) {
Expand Down

0 comments on commit 3fc9c12

Please sign in to comment.