aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2014-07-15 11:05:09 -0400
committerTejun Heo <tj@kernel.org>2014-07-15 11:05:09 -0400
commit2cf669a58dc08fa065a8bd0dca866c0e6cb358cc (patch)
tree2a04b009299fb4262791fb46e08f5623ab471e70
parent5577964e64692e17cc498854b7e0833e6532cd64 (diff)
cgroup: replace cgroup_add_cftypes() with cgroup_add_legacy_cftypes()
Currently, cftypes added by cgroup_add_cftypes() are used for both the unified default hierarchy and legacy ones and subsystems can mark each file with either CFTYPE_ONLY_ON_DFL or CFTYPE_INSANE if it has to appear only on one of them. This is quite hairy and error-prone. Also, we may end up exposing interface files to the default hierarchy without thinking it through. cgroup_subsys will grow two separate cftype addition functions and apply each only on the hierarchies of the matching type. This will allow organizing cftypes in a lot clearer way and encourage subsystems to scrutinize the interface which is being exposed in the new default hierarchy. In preparation, this patch adds cgroup_add_legacy_cftypes() which currently is a simple wrapper around cgroup_add_cftypes() and replaces all cgroup_add_cftypes() usages with it. While at it, this patch drops a completely spurious return from __hugetlb_cgroup_file_init(). This patch doesn't introduce any functional differences. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Neil Horman <nhorman@tuxdriver.com> Acked-by: Li Zefan <lizefan@huawei.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@suse.cz> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
-rw-r--r--block/blk-cgroup.c3
-rw-r--r--include/linux/cgroup.h2
-rw-r--r--kernel/cgroup.c7
-rw-r--r--mm/hugetlb_cgroup.c5
-rw-r--r--mm/memcontrol.c3
-rw-r--r--net/ipv4/tcp_memcontrol.c2
6 files changed, 14 insertions, 8 deletions
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 5cfbc723041c..2541cf043ba8 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1124,7 +1124,8 @@ int __init blkcg_policy_register(struct blkcg_policy *pol)
1124 1124
1125 /* everything is in place, add intf files for the new policy */ 1125 /* everything is in place, add intf files for the new policy */
1126 if (pol->cftypes) 1126 if (pol->cftypes)
1127 WARN_ON(cgroup_add_cftypes(&blkio_cgrp_subsys, pol->cftypes)); 1127 WARN_ON(cgroup_add_legacy_cftypes(&blkio_cgrp_subsys,
1128 pol->cftypes));
1128 ret = 0; 1129 ret = 0;
1129out_unlock: 1130out_unlock:
1130 mutex_unlock(&blkcg_pol_mutex); 1131 mutex_unlock(&blkcg_pol_mutex);
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index a6e9c2eeab89..f5f0feef2701 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -590,7 +590,7 @@ static inline void pr_cont_cgroup_path(struct cgroup *cgrp)
590 590
591char *task_cgroup_path(struct task_struct *task, char *buf, size_t buflen); 591char *task_cgroup_path(struct task_struct *task, char *buf, size_t buflen);
592 592
593int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts); 593int cgroup_add_legacy_cftypes(struct cgroup_subsys *ss, struct cftype *cfts);
594int cgroup_rm_cftypes(struct cftype *cfts); 594int cgroup_rm_cftypes(struct cftype *cfts);
595 595
596bool cgroup_is_descendant(struct cgroup *cgrp, struct cgroup *ancestor); 596bool cgroup_is_descendant(struct cgroup *cgrp, struct cgroup *ancestor);
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 6496a83b0314..c275aa439a6f 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -3170,7 +3170,7 @@ int cgroup_rm_cftypes(struct cftype *cfts)
3170 * function currently returns 0 as long as @cfts registration is successful 3170 * function currently returns 0 as long as @cfts registration is successful
3171 * even if some file creation attempts on existing cgroups fail. 3171 * even if some file creation attempts on existing cgroups fail.
3172 */ 3172 */
3173int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts) 3173static int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
3174{ 3174{
3175 int ret; 3175 int ret;
3176 3176
@@ -3195,6 +3195,11 @@ int cgroup_add_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
3195 return ret; 3195 return ret;
3196} 3196}
3197 3197
3198int cgroup_add_legacy_cftypes(struct cgroup_subsys *ss, struct cftype *cfts)
3199{
3200 return cgroup_add_cftypes(ss, cfts);
3201}
3202
3198/** 3203/**
3199 * cgroup_task_count - count the number of tasks in a cgroup. 3204 * cgroup_task_count - count the number of tasks in a cgroup.
3200 * @cgrp: the cgroup in question 3205 * @cgrp: the cgroup in question
diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
index 493f758445e7..9aae6f47433f 100644
--- a/mm/hugetlb_cgroup.c
+++ b/mm/hugetlb_cgroup.c
@@ -358,9 +358,8 @@ static void __init __hugetlb_cgroup_file_init(int idx)
358 cft = &h->cgroup_files[4]; 358 cft = &h->cgroup_files[4];
359 memset(cft, 0, sizeof(*cft)); 359 memset(cft, 0, sizeof(*cft));
360 360
361 WARN_ON(cgroup_add_cftypes(&hugetlb_cgrp_subsys, h->cgroup_files)); 361 WARN_ON(cgroup_add_legacy_cftypes(&hugetlb_cgrp_subsys,
362 362 h->cgroup_files));
363 return;
364} 363}
365 364
366void __init hugetlb_cgroup_file_init(void) 365void __init hugetlb_cgroup_file_init(void)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 8331f2739e2c..b6b3c6fea509 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -7065,7 +7065,8 @@ __setup("swapaccount=", enable_swap_account);
7065 7065
7066static void __init memsw_file_init(void) 7066static void __init memsw_file_init(void)
7067{ 7067{
7068 WARN_ON(cgroup_add_cftypes(&memory_cgrp_subsys, memsw_cgroup_files)); 7068 WARN_ON(cgroup_add_legacy_cftypes(&memory_cgrp_subsys,
7069 memsw_cgroup_files));
7069} 7070}
7070 7071
7071static void __init enable_swap_cgroup(void) 7072static void __init enable_swap_cgroup(void)
diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c
index f7a2ec3ac584..3af522622fad 100644
--- a/net/ipv4/tcp_memcontrol.c
+++ b/net/ipv4/tcp_memcontrol.c
@@ -222,7 +222,7 @@ static struct cftype tcp_files[] = {
222 222
223static int __init tcp_memcontrol_init(void) 223static int __init tcp_memcontrol_init(void)
224{ 224{
225 WARN_ON(cgroup_add_cftypes(&memory_cgrp_subsys, tcp_files)); 225 WARN_ON(cgroup_add_legacy_cftypes(&memory_cgrp_subsys, tcp_files));
226 return 0; 226 return 0;
227} 227}
228__initcall(tcp_memcontrol_init); 228__initcall(tcp_memcontrol_init);