diff options
author | Tejun Heo <tj@kernel.org> | 2015-08-18 16:58:16 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2015-08-18 16:58:16 -0400 |
commit | 3e1d2eed39d804e48282931835c7203fa47fe1d9 (patch) | |
tree | bb9fb11d59686da511a018f318d9d826727c009f | |
parent | d98817d4961b9ef75062d1e129829d283b3dac57 (diff) |
cgroup: introduce cgroup_subsys->legacy_name
This allows cgroup subsystems to use a different name on the unified
hierarchy. cgroup_subsys->name is used on the unified hierarchy,
->legacy_name elsewhere. If ->legacy_name is not explicitly set, it's
automatically set to ->name and the userland visible behavior remains
unchanged.
v2: Make parse_cgroupfs_options() only consider ->legacy_name as mount
options are used only on legacy hierarchies. Suggested by Li
Zefan.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: cgroups@vger.kernel.org
-rw-r--r-- | include/linux/cgroup-defs.h | 3 | ||||
-rw-r--r-- | kernel/cgroup.c | 29 |
2 files changed, 21 insertions, 11 deletions
diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index 8f5770a7d85a..7d0bb53e4553 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h | |||
@@ -434,6 +434,9 @@ struct cgroup_subsys { | |||
434 | int id; | 434 | int id; |
435 | const char *name; | 435 | const char *name; |
436 | 436 | ||
437 | /* optional, initialized automatically during boot if not set */ | ||
438 | const char *legacy_name; | ||
439 | |||
437 | /* link to parent, protected by cgroup_lock() */ | 440 | /* link to parent, protected by cgroup_lock() */ |
438 | struct cgroup_root *root; | 441 | struct cgroup_root *root; |
439 | 442 | ||
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index d9f854defa78..9c8eb17d593a 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -1028,10 +1028,13 @@ static const struct file_operations proc_cgroupstats_operations; | |||
1028 | static char *cgroup_file_name(struct cgroup *cgrp, const struct cftype *cft, | 1028 | static char *cgroup_file_name(struct cgroup *cgrp, const struct cftype *cft, |
1029 | char *buf) | 1029 | char *buf) |
1030 | { | 1030 | { |
1031 | struct cgroup_subsys *ss = cft->ss; | ||
1032 | |||
1031 | if (cft->ss && !(cft->flags & CFTYPE_NO_PREFIX) && | 1033 | if (cft->ss && !(cft->flags & CFTYPE_NO_PREFIX) && |
1032 | !(cgrp->root->flags & CGRP_ROOT_NOPREFIX)) | 1034 | !(cgrp->root->flags & CGRP_ROOT_NOPREFIX)) |
1033 | snprintf(buf, CGROUP_FILE_NAME_MAX, "%s.%s", | 1035 | snprintf(buf, CGROUP_FILE_NAME_MAX, "%s.%s", |
1034 | cft->ss->name, cft->name); | 1036 | cgroup_on_dfl(cgrp) ? ss->name : ss->legacy_name, |
1037 | cft->name); | ||
1035 | else | 1038 | else |
1036 | strncpy(buf, cft->name, CGROUP_FILE_NAME_MAX); | 1039 | strncpy(buf, cft->name, CGROUP_FILE_NAME_MAX); |
1037 | return buf; | 1040 | return buf; |
@@ -1336,7 +1339,7 @@ static int cgroup_show_options(struct seq_file *seq, | |||
1336 | if (root != &cgrp_dfl_root) | 1339 | if (root != &cgrp_dfl_root) |
1337 | for_each_subsys(ss, ssid) | 1340 | for_each_subsys(ss, ssid) |
1338 | if (root->subsys_mask & (1 << ssid)) | 1341 | if (root->subsys_mask & (1 << ssid)) |
1339 | seq_printf(seq, ",%s", ss->name); | 1342 | seq_printf(seq, ",%s", ss->legacy_name); |
1340 | if (root->flags & CGRP_ROOT_NOPREFIX) | 1343 | if (root->flags & CGRP_ROOT_NOPREFIX) |
1341 | seq_puts(seq, ",noprefix"); | 1344 | seq_puts(seq, ",noprefix"); |
1342 | if (root->flags & CGRP_ROOT_XATTR) | 1345 | if (root->flags & CGRP_ROOT_XATTR) |
@@ -1449,7 +1452,7 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts) | |||
1449 | } | 1452 | } |
1450 | 1453 | ||
1451 | for_each_subsys(ss, i) { | 1454 | for_each_subsys(ss, i) { |
1452 | if (strcmp(token, ss->name)) | 1455 | if (strcmp(token, ss->legacy_name)) |
1453 | continue; | 1456 | continue; |
1454 | if (ss->disabled) | 1457 | if (ss->disabled) |
1455 | continue; | 1458 | continue; |
@@ -4995,6 +4998,8 @@ int __init cgroup_init_early(void) | |||
4995 | 4998 | ||
4996 | ss->id = i; | 4999 | ss->id = i; |
4997 | ss->name = cgroup_subsys_name[i]; | 5000 | ss->name = cgroup_subsys_name[i]; |
5001 | if (!ss->legacy_name) | ||
5002 | ss->legacy_name = cgroup_subsys_name[i]; | ||
4998 | 5003 | ||
4999 | if (ss->early_init) | 5004 | if (ss->early_init) |
5000 | cgroup_init_subsys(ss, true); | 5005 | cgroup_init_subsys(ss, true); |
@@ -5142,7 +5147,7 @@ int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns, | |||
5142 | for_each_subsys(ss, ssid) | 5147 | for_each_subsys(ss, ssid) |
5143 | if (root->subsys_mask & (1 << ssid)) | 5148 | if (root->subsys_mask & (1 << ssid)) |
5144 | seq_printf(m, "%s%s", count++ ? "," : "", | 5149 | seq_printf(m, "%s%s", count++ ? "," : "", |
5145 | ss->name); | 5150 | ss->legacy_name); |
5146 | if (strlen(root->name)) | 5151 | if (strlen(root->name)) |
5147 | seq_printf(m, "%sname=%s", count ? "," : "", | 5152 | seq_printf(m, "%sname=%s", count ? "," : "", |
5148 | root->name); | 5153 | root->name); |
@@ -5182,7 +5187,7 @@ static int proc_cgroupstats_show(struct seq_file *m, void *v) | |||
5182 | 5187 | ||
5183 | for_each_subsys(ss, i) | 5188 | for_each_subsys(ss, i) |
5184 | seq_printf(m, "%s\t%d\t%d\t%d\n", | 5189 | seq_printf(m, "%s\t%d\t%d\t%d\n", |
5185 | ss->name, ss->root->hierarchy_id, | 5190 | ss->legacy_name, ss->root->hierarchy_id, |
5186 | atomic_read(&ss->root->nr_cgrps), !ss->disabled); | 5191 | atomic_read(&ss->root->nr_cgrps), !ss->disabled); |
5187 | 5192 | ||
5188 | mutex_unlock(&cgroup_mutex); | 5193 | mutex_unlock(&cgroup_mutex); |
@@ -5404,12 +5409,14 @@ static int __init cgroup_disable(char *str) | |||
5404 | continue; | 5409 | continue; |
5405 | 5410 | ||
5406 | for_each_subsys(ss, i) { | 5411 | for_each_subsys(ss, i) { |
5407 | if (!strcmp(token, ss->name)) { | 5412 | if (strcmp(token, ss->name) && |
5408 | ss->disabled = 1; | 5413 | strcmp(token, ss->legacy_name)) |
5409 | printk(KERN_INFO "Disabling %s control group" | 5414 | continue; |
5410 | " subsystem\n", ss->name); | 5415 | |
5411 | break; | 5416 | ss->disabled = 1; |
5412 | } | 5417 | printk(KERN_INFO "Disabling %s control group subsystem\n", |
5418 | ss->name); | ||
5419 | break; | ||
5413 | } | 5420 | } |
5414 | } | 5421 | } |
5415 | return 1; | 5422 | return 1; |