All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: axboe@kernel.dk
Cc: vgoyal@redhat.com, linux-kernel@vger.kernel.org,
	avanzini.arianna@gmail.com, kernel-team@fb.com,
	hannes@cmpxchg.org, lizefan@huawei.com, cgroups@vger.kernel.org,
	Tejun Heo <tj@kernel.org>
Subject: [PATCH 02/10] cgroup: introduce cgroup_subsys->legacy_name
Date: Fri, 24 Jul 2015 14:43:46 -0400	[thread overview]
Message-ID: <1437763434-28699-3-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1437763434-28699-1-git-send-email-tj@kernel.org>

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.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: cgroups@vger.kernel.org
---
 include/linux/cgroup-defs.h |  3 +++
 kernel/cgroup.c             | 30 +++++++++++++++++++-----------
 2 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
index 8f5770a..7d0bb53 100644
--- a/include/linux/cgroup-defs.h
+++ b/include/linux/cgroup-defs.h
@@ -434,6 +434,9 @@ struct cgroup_subsys {
 	int id;
 	const char *name;
 
+	/* optional, initialized automatically during boot if not set */
+	const char *legacy_name;
+
 	/* link to parent, protected by cgroup_lock() */
 	struct cgroup_root *root;
 
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 6c85e6d..0da2efa 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1027,10 +1027,13 @@ static const struct file_operations proc_cgroupstats_operations;
 static char *cgroup_file_name(struct cgroup *cgrp, const struct cftype *cft,
 			      char *buf)
 {
+	struct cgroup_subsys *ss = cft->ss;
+
 	if (cft->ss && !(cft->flags & CFTYPE_NO_PREFIX) &&
 	    !(cgrp->root->flags & CGRP_ROOT_NOPREFIX))
 		snprintf(buf, CGROUP_FILE_NAME_MAX, "%s.%s",
-			 cft->ss->name, cft->name);
+			 cgroup_on_dfl(cgrp) ? ss->name : ss->legacy_name,
+			 cft->name);
 	else
 		strncpy(buf, cft->name, CGROUP_FILE_NAME_MAX);
 	return buf;
@@ -1335,7 +1338,7 @@ static int cgroup_show_options(struct seq_file *seq,
 	if (root != &cgrp_dfl_root)
 		for_each_subsys(ss, ssid)
 			if (root->subsys_mask & (1 << ssid))
-				seq_printf(seq, ",%s", ss->name);
+				seq_printf(seq, ",%s", ss->legacy_name);
 	if (root->flags & CGRP_ROOT_NOPREFIX)
 		seq_puts(seq, ",noprefix");
 	if (root->flags & CGRP_ROOT_XATTR)
@@ -1448,7 +1451,8 @@ static int parse_cgroupfs_options(char *data, struct cgroup_sb_opts *opts)
 		}
 
 		for_each_subsys(ss, i) {
-			if (strcmp(token, ss->name))
+			if (strcmp(token, ss->name) &&
+			    strcmp(token, ss->legacy_name))
 				continue;
 			if (ss->disabled)
 				continue;
@@ -4994,6 +4998,8 @@ int __init cgroup_init_early(void)
 
 		ss->id = i;
 		ss->name = cgroup_subsys_name[i];
+		if (!ss->legacy_name)
+			ss->legacy_name = cgroup_subsys_name[i];
 
 		if (ss->early_init)
 			cgroup_init_subsys(ss, true);
@@ -5141,7 +5147,7 @@ int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns,
 			for_each_subsys(ss, ssid)
 				if (root->subsys_mask & (1 << ssid))
 					seq_printf(m, "%s%s", count++ ? "," : "",
-						   ss->name);
+						   ss->legacy_name);
 		if (strlen(root->name))
 			seq_printf(m, "%sname=%s", count ? "," : "",
 				   root->name);
@@ -5181,7 +5187,7 @@ static int proc_cgroupstats_show(struct seq_file *m, void *v)
 
 	for_each_subsys(ss, i)
 		seq_printf(m, "%s\t%d\t%d\t%d\n",
-			   ss->name, ss->root->hierarchy_id,
+			   ss->legacy_name, ss->root->hierarchy_id,
 			   atomic_read(&ss->root->nr_cgrps), !ss->disabled);
 
 	mutex_unlock(&cgroup_mutex);
@@ -5403,12 +5409,14 @@ static int __init cgroup_disable(char *str)
 			continue;
 
 		for_each_subsys(ss, i) {
-			if (!strcmp(token, ss->name)) {
-				ss->disabled = 1;
-				printk(KERN_INFO "Disabling %s control group"
-					" subsystem\n", ss->name);
-				break;
-			}
+			if (strcmp(token, ss->name) &&
+			    strcmp(token, ss->legacy_name))
+				continue;
+
+			ss->disabled = 1;
+			printk(KERN_INFO "Disabling %s control group subsystem\n",
+			       ss->name);
+			break;
 		}
 	}
 	return 1;
-- 
2.4.3

  reply	other threads:[~2015-07-24 18:43 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-24 18:43 [PATCHSET block/for-4.3] blkcg: implement interface for the unified hierarchy Tejun Heo
2015-07-24 18:43 ` Tejun Heo
2015-07-24 18:43 ` Tejun Heo [this message]
     [not found]   ` <1437763434-28699-3-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-07-28  6:39     ` [PATCH 02/10] cgroup: introduce cgroup_subsys->legacy_name Zefan Li
2015-07-28  6:39       ` Zefan Li
2015-07-28 15:23       ` Tejun Heo
2015-07-28 17:56   ` [PATCH v2 " Tejun Heo
2015-08-18 21:01     ` Tejun Heo
2015-07-29  1:18   ` [PATCH " Zefan Li
2015-07-29  1:18     ` Zefan Li
2015-07-24 18:43 ` [PATCH 03/10] blkcg: remove unnecessary NULL checks from __cfqg_set_weight_device() Tejun Heo
2015-07-24 18:43 ` [PATCH 04/10] blkcg: refine error codes returned during blkcg configuration Tejun Heo
     [not found] ` <1437763434-28699-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-07-24 18:43   ` [PATCH 01/10] cgroup: don't print subsystems for the default hierarchy Tejun Heo
2015-07-24 18:43     ` Tejun Heo
     [not found]     ` <1437763434-28699-2-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-07-29  1:18       ` Zefan Li
2015-07-29  1:18         ` Zefan Li
2015-08-18 21:01       ` Tejun Heo
2015-08-18 21:01         ` Tejun Heo
2015-07-24 18:43   ` [PATCH 05/10] blkcg: rename subsystem name from blkio to io Tejun Heo
2015-07-24 18:43     ` Tejun Heo
2015-07-24 18:43   ` [PATCH 06/10] blkcg: mark existing cftypes as legacy Tejun Heo
2015-07-24 18:43     ` Tejun Heo
2015-07-27 16:12   ` [PATCHSET block/for-4.3] blkcg: implement interface for the unified hierarchy Vivek Goyal
2015-07-27 16:12     ` Vivek Goyal
     [not found]     ` <20150727161209.GB16064-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-07-27 18:13       ` Tejun Heo
2015-07-27 18:13         ` Tejun Heo
2015-07-24 18:43 ` [PATCH 07/10] blkcg: move body parsing from blkg_conf_prep() to its callers Tejun Heo
2015-07-24 18:43 ` [PATCH 08/10] blkcg: separate out tg_conf_updated() from tg_set_conf() Tejun Heo
2015-07-24 18:43 ` [PATCH 09/10] blkcg: misc preparations for unified hierarchy interface Tejun Heo
2015-07-24 18:43 ` [PATCH 10/10] blkcg: implement interface for the unified hierarchy Tejun Heo
     [not found]   ` <1437763434-28699-11-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-07-30 22:58     ` [PATCH v2 " Tejun Heo
2015-07-30 22:58       ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1437763434-28699-3-git-send-email-tj@kernel.org \
    --to=tj@kernel.org \
    --cc=avanzini.arianna@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=vgoyal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.