int tcp_init_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss) { /* * The root cgroup does not use res_counters, but rather, * rely on the data already collected by the network * subsystem */ struct res_counter *res_parent = NULL; struct cg_proto *cg_proto, *parent_cg; struct tcp_memcontrol *tcp; struct mem_cgroup *memcg = mem_cgroup_from_cont(cgrp); struct mem_cgroup *parent = parent_mem_cgroup(memcg); struct net *net = current->nsproxy->net_ns; cg_proto = tcp_prot.proto_cgroup(memcg); if (!cg_proto) goto create_files; tcp = tcp_from_cgproto(cg_proto); tcp->tcp_prot_mem[0] = net->ipv4.sysctl_tcp_mem[0]; tcp->tcp_prot_mem[1] = net->ipv4.sysctl_tcp_mem[1]; tcp->tcp_prot_mem[2] = net->ipv4.sysctl_tcp_mem[2]; tcp->tcp_memory_pressure = 0; parent_cg = tcp_prot.proto_cgroup(parent); if (parent_cg) res_parent = parent_cg->memory_allocated; res_counter_init(&tcp->tcp_memory_allocated, res_parent); percpu_counter_init(&tcp->tcp_sockets_allocated, 0); cg_proto->enter_memory_pressure = memcg_tcp_enter_memory_pressure; cg_proto->memory_pressure = &tcp->tcp_memory_pressure; cg_proto->sysctl_mem = tcp->tcp_prot_mem; cg_proto->memory_allocated = &tcp->tcp_memory_allocated; cg_proto->sockets_allocated = &tcp->tcp_sockets_allocated; cg_proto->memcg = memcg; create_files: return cgroup_add_files(cgrp, ss, tcp_files, ARRAY_SIZE(tcp_files)); }
static int shinpei_populate(struct cgroup_subsys *ss, struct cgroup *cont) { return cgroup_add_files(cont, ss, files, ARRAY_SIZE(files)); }
static int cgrp_populate(struct cgroup_subsys *ss, struct cgroup *cgrp) { return cgroup_add_files(cgrp, ss, ss_files, ARRAY_SIZE(ss_files)); }