diff options
author | Glauber Costa <glommer@parallels.com> | 2011-12-11 16:47:08 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-12-12 19:04:11 -0500 |
commit | ffea59e50494198a0db4d6ad8f6721b8fd994f65 (patch) | |
tree | 371719583a5a14bc1a86e0e6247e9dd04ce79774 /net/ipv4 | |
parent | 5a6dd343770d2ae2c25f7a4b1998c091e6252f42 (diff) |
Display current tcp failcnt in kmem cgroup
This patch introduces kmem.tcp.failcnt file, living in the
kmem_cgroup filesystem. Following the pattern in the other
memcg resources, this files keeps a counter of how many times
allocation failed due to limits being hit in this cgroup.
The root cgroup will always show a failcnt of 0.
Signed-off-by: Glauber Costa <glommer@parallels.com>
Reviewed-by: Hiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com>
CC: David S. Miller <davem@davemloft.net>
CC: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/tcp_memcontrol.c | 31 |
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 @@ | |||
9 | static u64 tcp_cgroup_read(struct cgroup *cont, struct cftype *cft); | 9 | static u64 tcp_cgroup_read(struct cgroup *cont, struct cftype *cft); |
10 | static int tcp_cgroup_write(struct cgroup *cont, struct cftype *cft, | 10 | static int tcp_cgroup_write(struct cgroup *cont, struct cftype *cft, |
11 | const char *buffer); | 11 | const char *buffer); |
12 | static int tcp_cgroup_reset(struct cgroup *cont, unsigned int event); | ||
12 | 13 | ||
13 | static struct cftype tcp_files[] = { | 14 | static 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 | ||
27 | static inline struct tcp_memcontrol *tcp_from_cgproto(struct cg_proto *cg_proto) | 34 | static 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 | ||
216 | static 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 | |||
206 | unsigned long long tcp_max_memory(const struct mem_cgroup *memcg) | 237 | unsigned long long tcp_max_memory(const struct mem_cgroup *memcg) |
207 | { | 238 | { |
208 | struct tcp_memcontrol *tcp; | 239 | struct tcp_memcontrol *tcp; |