aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorGlauber Costa <glommer@parallels.com>2011-12-11 16:47:04 -0500
committerDavid S. Miller <davem@davemloft.net>2011-12-12 19:04:10 -0500
commitd1a4c0b37c296e600ffe08edb0db2dc1b8f550d7 (patch)
tree5c3675582cbbdc99f720aa1dcc1821e26c2be1ab /net/core
parente1aab161e0135aafcd439be20b4f35e4b0922d95 (diff)
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>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/sock.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index 6a871b8fdd20..5a6a90620656 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -136,6 +136,46 @@
136#include <net/tcp.h> 136#include <net/tcp.h>
137#endif 137#endif
138 138
139static DEFINE_RWLOCK(proto_list_lock);
140static LIST_HEAD(proto_list);
141
142#ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM
143int mem_cgroup_sockets_init(struct cgroup *cgrp, struct cgroup_subsys *ss)
144{
145 struct proto *proto;
146 int ret = 0;
147
148 read_lock(&proto_list_lock);
149 list_for_each_entry(proto, &proto_list, node) {
150 if (proto->init_cgroup) {
151 ret = proto->init_cgroup(cgrp, ss);
152 if (ret)
153 goto out;
154 }
155 }
156
157 read_unlock(&proto_list_lock);
158 return ret;
159out:
160 list_for_each_entry_continue_reverse(proto, &proto_list, node)
161 if (proto->destroy_cgroup)
162 proto->destroy_cgroup(cgrp, ss);
163 read_unlock(&proto_list_lock);
164 return ret;
165}
166
167void mem_cgroup_sockets_destroy(struct cgroup *cgrp, struct cgroup_subsys *ss)
168{
169 struct proto *proto;
170
171 read_lock(&proto_list_lock);
172 list_for_each_entry_reverse(proto, &proto_list, node)
173 if (proto->destroy_cgroup)
174 proto->destroy_cgroup(cgrp, ss);
175 read_unlock(&proto_list_lock);
176}
177#endif
178
139/* 179/*
140 * Each address family might have different locking rules, so we have 180 * Each address family might have different locking rules, so we have
141 * one slock key per address family: 181 * one slock key per address family:
@@ -2291,9 +2331,6 @@ void sk_common_release(struct sock *sk)
2291} 2331}
2292EXPORT_SYMBOL(sk_common_release); 2332EXPORT_SYMBOL(sk_common_release);
2293 2333
2294static DEFINE_RWLOCK(proto_list_lock);
2295static LIST_HEAD(proto_list);
2296
2297#ifdef CONFIG_PROC_FS 2334#ifdef CONFIG_PROC_FS
2298#define PROTO_INUSE_NR 64 /* should be enough for the first time */ 2335#define PROTO_INUSE_NR 64 /* should be enough for the first time */
2299struct prot_inuse { 2336struct prot_inuse {