aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/sysctl_net_ipv4.c
diff options
context:
space:
mode:
authorGlauber Costa <glommer@parallels.com>2011-12-11 16:47:06 -0500
committerDavid S. Miller <davem@davemloft.net>2011-12-12 19:04:11 -0500
commit3aaabe2342c36bf48567b88fa78b819eee14bb5e (patch)
tree1364c84c53ba6382f9a9df9d6f42a3bc37427d05 /net/ipv4/sysctl_net_ipv4.c
parent3dc43e3e4d0b52197d3205214fe8f162f9e0c334 (diff)
tcp buffer limitation: per-cgroup limit
This patch uses the "tcp.limit_in_bytes" field of the kmem_cgroup to effectively control the amount of kernel memory pinned by a cgroup. This value is ignored in the root cgroup, and in all others, caps the value specified by the admin in the net namespaces' view of tcp_sysctl_mem. If namespaces are being used, the admin is allowed to set a value bigger than cgroup's maximum, the same way it is allowed to set pretty much unlimited values in a real box. 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/sysctl_net_ipv4.c')
-rw-r--r--net/ipv4/sysctl_net_ipv4.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index bbd67abcb51d..fe9bf915676c 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -24,6 +24,7 @@
24#include <net/cipso_ipv4.h> 24#include <net/cipso_ipv4.h>
25#include <net/inet_frag.h> 25#include <net/inet_frag.h>
26#include <net/ping.h> 26#include <net/ping.h>
27#include <net/tcp_memcontrol.h>
27 28
28static int zero; 29static int zero;
29static int tcp_retr1_max = 255; 30static int tcp_retr1_max = 255;
@@ -182,6 +183,9 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
182 int ret; 183 int ret;
183 unsigned long vec[3]; 184 unsigned long vec[3];
184 struct net *net = current->nsproxy->net_ns; 185 struct net *net = current->nsproxy->net_ns;
186#ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM
187 struct mem_cgroup *memcg;
188#endif
185 189
186 ctl_table tmp = { 190 ctl_table tmp = {
187 .data = &vec, 191 .data = &vec,
@@ -198,6 +202,16 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
198 if (ret) 202 if (ret)
199 return ret; 203 return ret;
200 204
205#ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM
206 rcu_read_lock();
207 memcg = mem_cgroup_from_task(current);
208
209 tcp_prot_mem(memcg, vec[0], 0);
210 tcp_prot_mem(memcg, vec[1], 1);
211 tcp_prot_mem(memcg, vec[2], 2);
212 rcu_read_unlock();
213#endif
214
201 net->ipv4.sysctl_tcp_mem[0] = vec[0]; 215 net->ipv4.sysctl_tcp_mem[0] = vec[0];
202 net->ipv4.sysctl_tcp_mem[1] = vec[1]; 216 net->ipv4.sysctl_tcp_mem[1] = vec[1];
203 net->ipv4.sysctl_tcp_mem[2] = vec[2]; 217 net->ipv4.sysctl_tcp_mem[2] = vec[2];