aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorGlauber Costa <glommer@parallels.com>2012-04-09 18:36:33 -0400
committerTejun Heo <tj@kernel.org>2012-04-10 13:04:07 -0400
commit1d62e43657c63a858560c98069706c705d20505d (patch)
tree8b55403e0cf1efaab0c0fd7a2e53751dd21f1ebd /mm
parent48ddbe194623ae089cc0576e60363f2d2e85662a (diff)
cgroup: pass struct mem_cgroup instead of struct cgroup to socket memcg
The only reason cgroup was used, was to be consistent with the populate() interface. Now that we're getting rid of it, not only we no longer need it, but we also *can't* call it this way. Since we will no longer rely on populate(), this will be called from create(). During create, the association between struct mem_cgroup and struct cgroup does not yet exist, since cgroup internals hasn't yet initialized its bookkeeping. This means we would not be able to draw the memcg pointer from the cgroup pointer in these functions, which is highly undesirable. Signed-off-by: Glauber Costa <glommer@parallels.com> Acked-by: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Tejun Heo <tj@kernel.org> CC: Li Zefan <lizefan@huawei.com> CC: Johannes Weiner <hannes@cmpxchg.org> CC: Michal Hocko <mhocko@suse.cz>
Diffstat (limited to 'mm')
-rw-r--r--mm/memcontrol.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d28359cd6b55..785c32367075 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4640,29 +4640,22 @@ static int mem_control_numa_stat_open(struct inode *unused, struct file *file)
4640#endif /* CONFIG_NUMA */ 4640#endif /* CONFIG_NUMA */
4641 4641
4642#ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM 4642#ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM
4643static int register_kmem_files(struct cgroup *cont, struct cgroup_subsys *ss) 4643static int register_kmem_files(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
4644{ 4644{
4645 /* 4645 return mem_cgroup_sockets_init(memcg, ss);
4646 * Part of this would be better living in a separate allocation
4647 * function, leaving us with just the cgroup tree population work.
4648 * We, however, depend on state such as network's proto_list that
4649 * is only initialized after cgroup creation. I found the less
4650 * cumbersome way to deal with it to defer it all to populate time
4651 */
4652 return mem_cgroup_sockets_init(cont, ss);
4653}; 4646};
4654 4647
4655static void kmem_cgroup_destroy(struct cgroup *cont) 4648static void kmem_cgroup_destroy(struct mem_cgroup *memcg)
4656{ 4649{
4657 mem_cgroup_sockets_destroy(cont); 4650 mem_cgroup_sockets_destroy(memcg);
4658} 4651}
4659#else 4652#else
4660static int register_kmem_files(struct cgroup *cont, struct cgroup_subsys *ss) 4653static int register_kmem_files(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
4661{ 4654{
4662 return 0; 4655 return 0;
4663} 4656}
4664 4657
4665static void kmem_cgroup_destroy(struct cgroup *cont) 4658static void kmem_cgroup_destroy(struct mem_cgroup *memcg)
4666{ 4659{
4667} 4660}
4668#endif 4661#endif
@@ -5034,7 +5027,7 @@ static void mem_cgroup_destroy(struct cgroup *cont)
5034{ 5027{
5035 struct mem_cgroup *memcg = mem_cgroup_from_cont(cont); 5028 struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
5036 5029
5037 kmem_cgroup_destroy(cont); 5030 kmem_cgroup_destroy(memcg);
5038 5031
5039 mem_cgroup_put(memcg); 5032 mem_cgroup_put(memcg);
5040} 5033}
@@ -5042,7 +5035,8 @@ static void mem_cgroup_destroy(struct cgroup *cont)
5042static int mem_cgroup_populate(struct cgroup_subsys *ss, 5035static int mem_cgroup_populate(struct cgroup_subsys *ss,
5043 struct cgroup *cont) 5036 struct cgroup *cont)
5044{ 5037{
5045 return register_kmem_files(cont, ss); 5038 struct mem_cgroup *memcg = mem_cgroup_from_cont(cont);
5039 return register_kmem_files(memcg, ss);
5046} 5040}
5047 5041
5048#ifdef CONFIG_MMU 5042#ifdef CONFIG_MMU