diff options
author | Tejun Heo <tj@kernel.org> | 2014-05-16 13:22:48 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-05-16 13:22:48 -0400 |
commit | 5c9d535b893f30266ea29fe377cb9b002fcd76aa (patch) | |
tree | 27b1fd6e16c5b0c0729a93c4924289119033137c /mm | |
parent | 3b514d24e200fcdcde0a57c354a51d3677a86743 (diff) |
cgroup: remove css_parent()
cgroup in general is moving towards using cgroup_subsys_state as the
fundamental structural component and css_parent() was introduced to
convert from using cgroup->parent to css->parent. It was quite some
time ago and we're moving forward with making css more prominent.
This patch drops the trivial wrapper css_parent() and let the users
dereference css->parent. While at it, explicitly mark fields of css
which are public and immutable.
v2: New usage from device_cgroup.c converted.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Michal Hocko <mhocko@suse.cz>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: "David S. Miller" <davem@davemloft.net>
Acked-by: Li Zefan <lizefan@huawei.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/hugetlb_cgroup.c | 2 | ||||
-rw-r--r-- | mm/memcontrol.c | 14 |
2 files changed, 8 insertions, 8 deletions
diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index a380681ab3cf..493f758445e7 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c | |||
@@ -52,7 +52,7 @@ static inline bool hugetlb_cgroup_is_root(struct hugetlb_cgroup *h_cg) | |||
52 | static inline struct hugetlb_cgroup * | 52 | static inline struct hugetlb_cgroup * |
53 | parent_hugetlb_cgroup(struct hugetlb_cgroup *h_cg) | 53 | parent_hugetlb_cgroup(struct hugetlb_cgroup *h_cg) |
54 | { | 54 | { |
55 | return hugetlb_cgroup_from_css(css_parent(&h_cg->css)); | 55 | return hugetlb_cgroup_from_css(h_cg->css.parent); |
56 | } | 56 | } |
57 | 57 | ||
58 | static inline bool hugetlb_cgroup_have_usage(struct hugetlb_cgroup *h_cg) | 58 | static inline bool hugetlb_cgroup_have_usage(struct hugetlb_cgroup *h_cg) |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b638a79209ee..a5e0417b4f9a 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -1540,7 +1540,7 @@ static unsigned long mem_cgroup_margin(struct mem_cgroup *memcg) | |||
1540 | int mem_cgroup_swappiness(struct mem_cgroup *memcg) | 1540 | int mem_cgroup_swappiness(struct mem_cgroup *memcg) |
1541 | { | 1541 | { |
1542 | /* root ? */ | 1542 | /* root ? */ |
1543 | if (!css_parent(&memcg->css)) | 1543 | if (!memcg->css.parent) |
1544 | return vm_swappiness; | 1544 | return vm_swappiness; |
1545 | 1545 | ||
1546 | return memcg->swappiness; | 1546 | return memcg->swappiness; |
@@ -4909,7 +4909,7 @@ static int mem_cgroup_hierarchy_write(struct cgroup_subsys_state *css, | |||
4909 | { | 4909 | { |
4910 | int retval = 0; | 4910 | int retval = 0; |
4911 | struct mem_cgroup *memcg = mem_cgroup_from_css(css); | 4911 | struct mem_cgroup *memcg = mem_cgroup_from_css(css); |
4912 | struct mem_cgroup *parent_memcg = mem_cgroup_from_css(css_parent(&memcg->css)); | 4912 | struct mem_cgroup *parent_memcg = mem_cgroup_from_css(memcg->css.parent); |
4913 | 4913 | ||
4914 | mutex_lock(&memcg_create_mutex); | 4914 | mutex_lock(&memcg_create_mutex); |
4915 | 4915 | ||
@@ -5207,8 +5207,8 @@ static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg, | |||
5207 | if (!memcg->use_hierarchy) | 5207 | if (!memcg->use_hierarchy) |
5208 | goto out; | 5208 | goto out; |
5209 | 5209 | ||
5210 | while (css_parent(&memcg->css)) { | 5210 | while (memcg->css.parent) { |
5211 | memcg = mem_cgroup_from_css(css_parent(&memcg->css)); | 5211 | memcg = mem_cgroup_from_css(memcg->css.parent); |
5212 | if (!memcg->use_hierarchy) | 5212 | if (!memcg->use_hierarchy) |
5213 | break; | 5213 | break; |
5214 | tmp = res_counter_read_u64(&memcg->res, RES_LIMIT); | 5214 | tmp = res_counter_read_u64(&memcg->res, RES_LIMIT); |
@@ -5443,7 +5443,7 @@ static int mem_cgroup_swappiness_write(struct cgroup_subsys_state *css, | |||
5443 | struct cftype *cft, u64 val) | 5443 | struct cftype *cft, u64 val) |
5444 | { | 5444 | { |
5445 | struct mem_cgroup *memcg = mem_cgroup_from_css(css); | 5445 | struct mem_cgroup *memcg = mem_cgroup_from_css(css); |
5446 | struct mem_cgroup *parent = mem_cgroup_from_css(css_parent(&memcg->css)); | 5446 | struct mem_cgroup *parent = mem_cgroup_from_css(memcg->css.parent); |
5447 | 5447 | ||
5448 | if (val > 100 || !parent) | 5448 | if (val > 100 || !parent) |
5449 | return -EINVAL; | 5449 | return -EINVAL; |
@@ -5790,7 +5790,7 @@ static int mem_cgroup_oom_control_write(struct cgroup_subsys_state *css, | |||
5790 | struct cftype *cft, u64 val) | 5790 | struct cftype *cft, u64 val) |
5791 | { | 5791 | { |
5792 | struct mem_cgroup *memcg = mem_cgroup_from_css(css); | 5792 | struct mem_cgroup *memcg = mem_cgroup_from_css(css); |
5793 | struct mem_cgroup *parent = mem_cgroup_from_css(css_parent(&memcg->css)); | 5793 | struct mem_cgroup *parent = mem_cgroup_from_css(memcg->css.parent); |
5794 | 5794 | ||
5795 | /* cannot set to root cgroup and only 0 and 1 are allowed */ | 5795 | /* cannot set to root cgroup and only 0 and 1 are allowed */ |
5796 | if (!parent || !((val == 0) || (val == 1))) | 5796 | if (!parent || !((val == 0) || (val == 1))) |
@@ -6407,7 +6407,7 @@ static int | |||
6407 | mem_cgroup_css_online(struct cgroup_subsys_state *css) | 6407 | mem_cgroup_css_online(struct cgroup_subsys_state *css) |
6408 | { | 6408 | { |
6409 | struct mem_cgroup *memcg = mem_cgroup_from_css(css); | 6409 | struct mem_cgroup *memcg = mem_cgroup_from_css(css); |
6410 | struct mem_cgroup *parent = mem_cgroup_from_css(css_parent(css)); | 6410 | struct mem_cgroup *parent = mem_cgroup_from_css(css->parent); |
6411 | 6411 | ||
6412 | if (css->id > MEM_CGROUP_ID_MAX) | 6412 | if (css->id > MEM_CGROUP_ID_MAX) |
6413 | return -ENOSPC; | 6413 | return -ENOSPC; |