tcp memory pressure controls
This patch introduces memory pressure controls for the tcp protocol. It uses the generic socket memory pressure code introduced in earlier patches, and fills in the necessary data in cg_proto struct. Signed-off-by: Glauber Costa <glommer@parallels.com> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujtisu.com> CC: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
e1aab161e0
commit
d1a4c0b37c
@@ -136,6 +136,46 @@
|
||||
#include <net/tcp.h>
|
||||
#endif
|
||||
|
||||
static DEFINE_RWLOCK(proto_list_lock);
|
||||
static LIST_HEAD(proto_list);
|
||||
|
||||
#ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM
|
||||
int mem_cgroup_sockets_init(struct cgroup *cgrp, struct cgroup_subsys *ss)
|
||||
{
|
||||
struct proto *proto;
|
||||
int ret = 0;
|
||||
|
||||
read_lock(&proto_list_lock);
|
||||
list_for_each_entry(proto, &proto_list, node) {
|
||||
if (proto->init_cgroup) {
|
||||
ret = proto->init_cgroup(cgrp, ss);
|
||||
if (ret)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
read_unlock(&proto_list_lock);
|
||||
return ret;
|
||||
out:
|
||||
list_for_each_entry_continue_reverse(proto, &proto_list, node)
|
||||
if (proto->destroy_cgroup)
|
||||
proto->destroy_cgroup(cgrp, ss);
|
||||
read_unlock(&proto_list_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void mem_cgroup_sockets_destroy(struct cgroup *cgrp, struct cgroup_subsys *ss)
|
||||
{
|
||||
struct proto *proto;
|
||||
|
||||
read_lock(&proto_list_lock);
|
||||
list_for_each_entry_reverse(proto, &proto_list, node)
|
||||
if (proto->destroy_cgroup)
|
||||
proto->destroy_cgroup(cgrp, ss);
|
||||
read_unlock(&proto_list_lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Each address family might have different locking rules, so we have
|
||||
* one slock key per address family:
|
||||
@@ -2291,9 +2331,6 @@ void sk_common_release(struct sock *sk)
|
||||
}
|
||||
EXPORT_SYMBOL(sk_common_release);
|
||||
|
||||
static DEFINE_RWLOCK(proto_list_lock);
|
||||
static LIST_HEAD(proto_list);
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
#define PROTO_INUSE_NR 64 /* should be enough for the first time */
|
||||
struct prot_inuse {
|
||||
|
Reference in New Issue
Block a user