aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/ipv4/tcp_memcontrol.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c
index 9481f235803e..d438fba31ba8 100644
--- a/net/ipv4/tcp_memcontrol.c
+++ b/net/ipv4/tcp_memcontrol.c
@@ -9,6 +9,7 @@
9static u64 tcp_cgroup_read(struct cgroup *cont, struct cftype *cft); 9static u64 tcp_cgroup_read(struct cgroup *cont, struct cftype *cft);
10static int tcp_cgroup_write(struct cgroup *cont, struct cftype *cft, 10static int tcp_cgroup_write(struct cgroup *cont, struct cftype *cft,
11 const char *buffer); 11 const char *buffer);
12static int tcp_cgroup_reset(struct cgroup *cont, unsigned int event);
12 13
13static struct cftype tcp_files[] = { 14static struct cftype tcp_files[] = {
14 { 15 {
@@ -22,6 +23,12 @@ static struct cftype tcp_files[] = {
22 .read_u64 = tcp_cgroup_read, 23 .read_u64 = tcp_cgroup_read,
23 .private = RES_USAGE, 24 .private = RES_USAGE,
24 }, 25 },
26 {
27 .name = "kmem.tcp.failcnt",
28 .private = RES_FAILCNT,
29 .trigger = tcp_cgroup_reset,
30 .read_u64 = tcp_cgroup_read,
31 },
25}; 32};
26 33
27static inline struct tcp_memcontrol *tcp_from_cgproto(struct cg_proto *cg_proto) 34static inline struct tcp_memcontrol *tcp_from_cgproto(struct cg_proto *cg_proto)
@@ -197,12 +204,36 @@ static u64 tcp_cgroup_read(struct cgroup *cont, struct cftype *cft)
197 case RES_USAGE: 204 case RES_USAGE:
198 val = tcp_read_usage(memcg); 205 val = tcp_read_usage(memcg);
199 break; 206 break;
207 case RES_FAILCNT:
208 val = tcp_read_stat(memcg, RES_FAILCNT, 0);
209 break;
200 default: 210 default:
201 BUG(); 211 BUG();
202 } 212 }
203 return val; 213 return val;
204} 214}
205 215
216static int tcp_cgroup_reset(struct cgroup *cont, unsigned int event)
217{
218 struct mem_cgroup *memcg;
219 struct tcp_memcontrol *tcp;
220 struct cg_proto *cg_proto;
221
222 memcg = mem_cgroup_from_cont(cont);
223 cg_proto = tcp_prot.proto_cgroup(memcg);
224 if (!cg_proto)
225 return 0;
226 tcp = tcp_from_cgproto(cg_proto);
227
228 switch (event) {
229 case RES_FAILCNT:
230 res_counter_reset_failcnt(&tcp->tcp_memory_allocated);
231 break;
232 }
233
234 return 0;
235}
236
206unsigned long long tcp_max_memory(const struct mem_cgroup *memcg) 237unsigned long long tcp_max_memory(const struct mem_cgroup *memcg)
207{ 238{
208 struct tcp_memcontrol *tcp; 239 struct tcp_memcontrol *tcp;