diff options
-rw-r--r-- | include/net/sock.h | 12 | ||||
-rw-r--r-- | include/net/tcp_memcontrol.h | 4 | ||||
-rw-r--r-- | mm/memcontrol.c | 24 | ||||
-rw-r--r-- | net/core/sock.c | 10 | ||||
-rw-r--r-- | net/ipv4/tcp_memcontrol.c | 6 |
5 files changed, 24 insertions, 32 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index a6ba1f8871fd..b3ebe6b3e7db 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -70,16 +70,16 @@ | |||
70 | struct cgroup; | 70 | struct cgroup; |
71 | struct cgroup_subsys; | 71 | struct cgroup_subsys; |
72 | #ifdef CONFIG_NET | 72 | #ifdef CONFIG_NET |
73 | int mem_cgroup_sockets_init(struct cgroup *cgrp, struct cgroup_subsys *ss); | 73 | int mem_cgroup_sockets_init(struct mem_cgroup *memcg, struct cgroup_subsys *ss); |
74 | void mem_cgroup_sockets_destroy(struct cgroup *cgrp); | 74 | void mem_cgroup_sockets_destroy(struct mem_cgroup *memcg); |
75 | #else | 75 | #else |
76 | static inline | 76 | static inline |
77 | int mem_cgroup_sockets_init(struct cgroup *cgrp, struct cgroup_subsys *ss) | 77 | int mem_cgroup_sockets_init(struct mem_cgroup *memcg, struct cgroup_subsys *ss) |
78 | { | 78 | { |
79 | return 0; | 79 | return 0; |
80 | } | 80 | } |
81 | static inline | 81 | static inline |
82 | void mem_cgroup_sockets_destroy(struct cgroup *cgrp) | 82 | void mem_cgroup_sockets_destroy(struct mem_cgroup *memcg) |
83 | { | 83 | { |
84 | } | 84 | } |
85 | #endif | 85 | #endif |
@@ -900,9 +900,9 @@ struct proto { | |||
900 | * This function has to setup any files the protocol want to | 900 | * This function has to setup any files the protocol want to |
901 | * appear in the kmem cgroup filesystem. | 901 | * appear in the kmem cgroup filesystem. |
902 | */ | 902 | */ |
903 | int (*init_cgroup)(struct cgroup *cgrp, | 903 | int (*init_cgroup)(struct mem_cgroup *memcg, |
904 | struct cgroup_subsys *ss); | 904 | struct cgroup_subsys *ss); |
905 | void (*destroy_cgroup)(struct cgroup *cgrp); | 905 | void (*destroy_cgroup)(struct mem_cgroup *memcg); |
906 | struct cg_proto *(*proto_cgroup)(struct mem_cgroup *memcg); | 906 | struct cg_proto *(*proto_cgroup)(struct mem_cgroup *memcg); |
907 | #endif | 907 | #endif |
908 | }; | 908 | }; |
diff --git a/include/net/tcp_memcontrol.h b/include/net/tcp_memcontrol.h index 48410ff25c9e..7df18bc43a97 100644 --- a/include/net/tcp_memcontrol.h +++ b/include/net/tcp_memcontrol.h | |||
@@ -12,8 +12,8 @@ struct tcp_memcontrol { | |||
12 | }; | 12 | }; |
13 | 13 | ||
14 | struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg); | 14 | struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg); |
15 | int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss); | 15 | int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss); |
16 | void tcp_destroy_cgroup(struct cgroup *cgrp); | 16 | void tcp_destroy_cgroup(struct mem_cgroup *memcg); |
17 | unsigned long long tcp_max_memory(const struct mem_cgroup *memcg); | 17 | unsigned long long tcp_max_memory(const struct mem_cgroup *memcg); |
18 | void tcp_prot_mem(struct mem_cgroup *memcg, long val, int idx); | 18 | void tcp_prot_mem(struct mem_cgroup *memcg, long val, int idx); |
19 | #endif /* _TCP_MEMCG_H */ | 19 | #endif /* _TCP_MEMCG_H */ |
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 |
4643 | static int register_kmem_files(struct cgroup *cont, struct cgroup_subsys *ss) | 4643 | static 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 | ||
4655 | static void kmem_cgroup_destroy(struct cgroup *cont) | 4648 | static 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 |
4660 | static int register_kmem_files(struct cgroup *cont, struct cgroup_subsys *ss) | 4653 | static int register_kmem_files(struct mem_cgroup *memcg, struct cgroup_subsys *ss) |
4661 | { | 4654 | { |
4662 | return 0; | 4655 | return 0; |
4663 | } | 4656 | } |
4664 | 4657 | ||
4665 | static void kmem_cgroup_destroy(struct cgroup *cont) | 4658 | static 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) | |||
5042 | static int mem_cgroup_populate(struct cgroup_subsys *ss, | 5035 | static 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 |
diff --git a/net/core/sock.c b/net/core/sock.c index b2e14c07d920..878f7447cf61 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -140,7 +140,7 @@ static DEFINE_MUTEX(proto_list_mutex); | |||
140 | static LIST_HEAD(proto_list); | 140 | static LIST_HEAD(proto_list); |
141 | 141 | ||
142 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM | 142 | #ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM |
143 | int mem_cgroup_sockets_init(struct cgroup *cgrp, struct cgroup_subsys *ss) | 143 | int mem_cgroup_sockets_init(struct mem_cgroup *memcg, struct cgroup_subsys *ss) |
144 | { | 144 | { |
145 | struct proto *proto; | 145 | struct proto *proto; |
146 | int ret = 0; | 146 | int ret = 0; |
@@ -148,7 +148,7 @@ int mem_cgroup_sockets_init(struct cgroup *cgrp, struct cgroup_subsys *ss) | |||
148 | mutex_lock(&proto_list_mutex); | 148 | mutex_lock(&proto_list_mutex); |
149 | list_for_each_entry(proto, &proto_list, node) { | 149 | list_for_each_entry(proto, &proto_list, node) { |
150 | if (proto->init_cgroup) { | 150 | if (proto->init_cgroup) { |
151 | ret = proto->init_cgroup(cgrp, ss); | 151 | ret = proto->init_cgroup(memcg, ss); |
152 | if (ret) | 152 | if (ret) |
153 | goto out; | 153 | goto out; |
154 | } | 154 | } |
@@ -159,19 +159,19 @@ int mem_cgroup_sockets_init(struct cgroup *cgrp, struct cgroup_subsys *ss) | |||
159 | out: | 159 | out: |
160 | list_for_each_entry_continue_reverse(proto, &proto_list, node) | 160 | list_for_each_entry_continue_reverse(proto, &proto_list, node) |
161 | if (proto->destroy_cgroup) | 161 | if (proto->destroy_cgroup) |
162 | proto->destroy_cgroup(cgrp); | 162 | proto->destroy_cgroup(memcg); |
163 | mutex_unlock(&proto_list_mutex); | 163 | mutex_unlock(&proto_list_mutex); |
164 | return ret; | 164 | return ret; |
165 | } | 165 | } |
166 | 166 | ||
167 | void mem_cgroup_sockets_destroy(struct cgroup *cgrp) | 167 | void mem_cgroup_sockets_destroy(struct mem_cgroup *memcg) |
168 | { | 168 | { |
169 | struct proto *proto; | 169 | struct proto *proto; |
170 | 170 | ||
171 | mutex_lock(&proto_list_mutex); | 171 | mutex_lock(&proto_list_mutex); |
172 | list_for_each_entry_reverse(proto, &proto_list, node) | 172 | list_for_each_entry_reverse(proto, &proto_list, node) |
173 | if (proto->destroy_cgroup) | 173 | if (proto->destroy_cgroup) |
174 | proto->destroy_cgroup(cgrp); | 174 | proto->destroy_cgroup(memcg); |
175 | mutex_unlock(&proto_list_mutex); | 175 | mutex_unlock(&proto_list_mutex); |
176 | } | 176 | } |
177 | #endif | 177 | #endif |
diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c index 8f1753defa5c..151703791bb0 100644 --- a/net/ipv4/tcp_memcontrol.c +++ b/net/ipv4/tcp_memcontrol.c | |||
@@ -18,7 +18,7 @@ static void memcg_tcp_enter_memory_pressure(struct sock *sk) | |||
18 | } | 18 | } |
19 | EXPORT_SYMBOL(memcg_tcp_enter_memory_pressure); | 19 | EXPORT_SYMBOL(memcg_tcp_enter_memory_pressure); |
20 | 20 | ||
21 | int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss) | 21 | int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss) |
22 | { | 22 | { |
23 | /* | 23 | /* |
24 | * The root cgroup does not use res_counters, but rather, | 24 | * The root cgroup does not use res_counters, but rather, |
@@ -28,7 +28,6 @@ int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss) | |||
28 | struct res_counter *res_parent = NULL; | 28 | struct res_counter *res_parent = NULL; |
29 | struct cg_proto *cg_proto, *parent_cg; | 29 | struct cg_proto *cg_proto, *parent_cg; |
30 | struct tcp_memcontrol *tcp; | 30 | struct tcp_memcontrol *tcp; |
31 | struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp); | ||
32 | struct mem_cgroup *parent = parent_mem_cgroup(memcg); | 31 | struct mem_cgroup *parent = parent_mem_cgroup(memcg); |
33 | struct net *net = current->nsproxy->net_ns; | 32 | struct net *net = current->nsproxy->net_ns; |
34 | 33 | ||
@@ -61,9 +60,8 @@ int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss) | |||
61 | } | 60 | } |
62 | EXPORT_SYMBOL(tcp_init_cgroup); | 61 | EXPORT_SYMBOL(tcp_init_cgroup); |
63 | 62 | ||
64 | void tcp_destroy_cgroup(struct cgroup *cgrp) | 63 | void tcp_destroy_cgroup(struct mem_cgroup *memcg) |
65 | { | 64 | { |
66 | struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp); | ||
67 | struct cg_proto *cg_proto; | 65 | struct cg_proto *cg_proto; |
68 | struct tcp_memcontrol *tcp; | 66 | struct tcp_memcontrol *tcp; |
69 | u64 val; | 67 | u64 val; |