Commit ffea59e5 authored by Glauber Costa's avatar Glauber Costa Committed by David S. Miller

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: default avatarGlauber Costa <glommer@parallels.com>
Reviewed-by: default avatarHiroyouki Kamezawa <kamezawa.hiroyu@jp.fujitsu.com>
CC: David S. Miller <davem@davemloft.net>
CC: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5a6dd343
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
static u64 tcp_cgroup_read(struct cgroup *cont, struct cftype *cft); static u64 tcp_cgroup_read(struct cgroup *cont, struct cftype *cft);
static int tcp_cgroup_write(struct cgroup *cont, struct cftype *cft, static int tcp_cgroup_write(struct cgroup *cont, struct cftype *cft,
const char *buffer); const char *buffer);
static int tcp_cgroup_reset(struct cgroup *cont, unsigned int event);
static struct cftype tcp_files[] = { static struct cftype tcp_files[] = {
{ {
...@@ -22,6 +23,12 @@ static struct cftype tcp_files[] = { ...@@ -22,6 +23,12 @@ static struct cftype tcp_files[] = {
.read_u64 = tcp_cgroup_read, .read_u64 = tcp_cgroup_read,
.private = RES_USAGE, .private = RES_USAGE,
}, },
{
.name = "kmem.tcp.failcnt",
.private = RES_FAILCNT,
.trigger = tcp_cgroup_reset,
.read_u64 = tcp_cgroup_read,
},
}; };
static inline struct tcp_memcontrol *tcp_from_cgproto(struct cg_proto *cg_proto) 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,12 +204,36 @@ static u64 tcp_cgroup_read(struct cgroup *cont, struct cftype *cft)
case RES_USAGE: case RES_USAGE:
val = tcp_read_usage(memcg); val = tcp_read_usage(memcg);
break; break;
case RES_FAILCNT:
val = tcp_read_stat(memcg, RES_FAILCNT, 0);
break;
default: default:
BUG(); BUG();
} }
return val; return val;
} }
static int tcp_cgroup_reset(struct cgroup *cont, unsigned int event)
{
struct mem_cgroup *memcg;
struct tcp_memcontrol *tcp;
struct cg_proto *cg_proto;
memcg = mem_cgroup_from_cont(cont);
cg_proto = tcp_prot.proto_cgroup(memcg);
if (!cg_proto)
return 0;
tcp = tcp_from_cgproto(cg_proto);
switch (event) {
case RES_FAILCNT:
res_counter_reset_failcnt(&tcp->tcp_memory_allocated);
break;
}
return 0;
}
unsigned long long tcp_max_memory(const struct mem_cgroup *memcg) unsigned long long tcp_max_memory(const struct mem_cgroup *memcg)
{ {
struct tcp_memcontrol *tcp; struct tcp_memcontrol *tcp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment