aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2013-10-19 19:25:36 -0400
committerDavid S. Miller <davem@davemloft.net>2013-10-21 18:43:02 -0400
commita4fe34bf902b8f709c635ab37f1f39de0b86cff2 (patch)
tree955c388e64c320eda8759bd970a5284473c8e1d5
parentf594d63199688ad568fb69f6a790b11d6d6d1ba5 (diff)
tcp_memcontrol: Remove the per netns control.
The code that is implemented is per memory cgroup not per netns, and having per netns bits is just confusing. Remove the per netns bits to make it easier to see what is really going on. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/netns/ipv4.h1
-rw-r--r--include/net/tcp.h3
-rw-r--r--net/ipv4/af_inet.c2
-rw-r--r--net/ipv4/sysctl_net_ipv4.c23
-rw-r--r--net/ipv4/tcp.c12
-rw-r--r--net/ipv4/tcp_ipv4.c1
-rw-r--r--net/ipv4/tcp_memcontrol.c10
-rw-r--r--net/ipv6/af_inet6.c2
-rw-r--r--net/ipv6/tcp_ipv6.c1
9 files changed, 21 insertions, 34 deletions
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index 5dbd232e12ff..ee520cba2ec2 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -71,7 +71,6 @@ struct netns_ipv4 {
71 int sysctl_tcp_ecn; 71 int sysctl_tcp_ecn;
72 72
73 kgid_t sysctl_ping_group_range[2]; 73 kgid_t sysctl_ping_group_range[2];
74 long sysctl_tcp_mem[3];
75 74
76 atomic_t dev_addr_genid; 75 atomic_t dev_addr_genid;
77 76
diff --git a/include/net/tcp.h b/include/net/tcp.h
index b12e29a76590..2d7b4bdc972f 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -259,6 +259,7 @@ extern int sysctl_tcp_max_orphans;
259extern int sysctl_tcp_fack; 259extern int sysctl_tcp_fack;
260extern int sysctl_tcp_reordering; 260extern int sysctl_tcp_reordering;
261extern int sysctl_tcp_dsack; 261extern int sysctl_tcp_dsack;
262extern long sysctl_tcp_mem[3];
262extern int sysctl_tcp_wmem[3]; 263extern int sysctl_tcp_wmem[3];
263extern int sysctl_tcp_rmem[3]; 264extern int sysctl_tcp_rmem[3];
264extern int sysctl_tcp_app_win; 265extern int sysctl_tcp_app_win;
@@ -348,8 +349,6 @@ extern struct proto tcp_prot;
348#define TCP_ADD_STATS_USER(net, field, val) SNMP_ADD_STATS_USER((net)->mib.tcp_statistics, field, val) 349#define TCP_ADD_STATS_USER(net, field, val) SNMP_ADD_STATS_USER((net)->mib.tcp_statistics, field, val)
349#define TCP_ADD_STATS(net, field, val) SNMP_ADD_STATS((net)->mib.tcp_statistics, field, val) 350#define TCP_ADD_STATS(net, field, val) SNMP_ADD_STATS((net)->mib.tcp_statistics, field, val)
350 351
351void tcp_init_mem(struct net *net);
352
353void tcp_tasklet_init(void); 352void tcp_tasklet_init(void);
354 353
355void tcp_v4_err(struct sk_buff *skb, u32); 354void tcp_v4_err(struct sk_buff *skb, u32);
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 9433a6186f54..24a53fc275b0 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1697,8 +1697,6 @@ static int __init inet_init(void)
1697 ip_static_sysctl_init(); 1697 ip_static_sysctl_init();
1698#endif 1698#endif
1699 1699
1700 tcp_prot.sysctl_mem = init_net.ipv4.sysctl_tcp_mem;
1701
1702 /* 1700 /*
1703 * Add all the base protocols. 1701 * Add all the base protocols.
1704 */ 1702 */
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 8457f7bc4d89..69c6a8dbe09d 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -200,14 +200,6 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
200 return ret; 200 return ret;
201} 201}
202 202
203static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
204 void __user *buffer, size_t *lenp,
205 loff_t *ppos)
206{
207 ctl->data = &current->nsproxy->net_ns->ipv4.sysctl_tcp_mem;
208 return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
209}
210
211static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write, 203static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
212 void __user *buffer, size_t *lenp, 204 void __user *buffer, size_t *lenp,
213 loff_t *ppos) 205 loff_t *ppos)
@@ -522,6 +514,13 @@ static struct ctl_table ipv4_table[] = {
522 .proc_handler = proc_dointvec 514 .proc_handler = proc_dointvec
523 }, 515 },
524 { 516 {
517 .procname = "tcp_mem",
518 .maxlen = sizeof(sysctl_tcp_mem),
519 .data = &sysctl_tcp_mem,
520 .mode = 0644,
521 .proc_handler = proc_doulongvec_minmax,
522 },
523 {
525 .procname = "tcp_wmem", 524 .procname = "tcp_wmem",
526 .data = &sysctl_tcp_wmem, 525 .data = &sysctl_tcp_wmem,
527 .maxlen = sizeof(sysctl_tcp_wmem), 526 .maxlen = sizeof(sysctl_tcp_wmem),
@@ -830,12 +829,6 @@ static struct ctl_table ipv4_net_table[] = {
830 .mode = 0644, 829 .mode = 0644,
831 .proc_handler = ipv4_local_port_range, 830 .proc_handler = ipv4_local_port_range,
832 }, 831 },
833 {
834 .procname = "tcp_mem",
835 .maxlen = sizeof(init_net.ipv4.sysctl_tcp_mem),
836 .mode = 0644,
837 .proc_handler = ipv4_tcp_mem,
838 },
839 { } 832 { }
840}; 833};
841 834
@@ -887,8 +880,6 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
887 net->ipv4.sysctl_local_ports.range[0] = 32768; 880 net->ipv4.sysctl_local_ports.range[0] = 32768;
888 net->ipv4.sysctl_local_ports.range[1] = 61000; 881 net->ipv4.sysctl_local_ports.range[1] = 61000;
889 882
890 tcp_init_mem(net);
891
892 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table); 883 net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
893 if (net->ipv4.ipv4_hdr == NULL) 884 if (net->ipv4.ipv4_hdr == NULL)
894 goto err_reg; 885 goto err_reg;
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index be4b161802e8..8e8529d3c8c9 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -288,9 +288,11 @@ int sysctl_tcp_min_tso_segs __read_mostly = 2;
288struct percpu_counter tcp_orphan_count; 288struct percpu_counter tcp_orphan_count;
289EXPORT_SYMBOL_GPL(tcp_orphan_count); 289EXPORT_SYMBOL_GPL(tcp_orphan_count);
290 290
291long sysctl_tcp_mem[3] __read_mostly;
291int sysctl_tcp_wmem[3] __read_mostly; 292int sysctl_tcp_wmem[3] __read_mostly;
292int sysctl_tcp_rmem[3] __read_mostly; 293int sysctl_tcp_rmem[3] __read_mostly;
293 294
295EXPORT_SYMBOL(sysctl_tcp_mem);
294EXPORT_SYMBOL(sysctl_tcp_rmem); 296EXPORT_SYMBOL(sysctl_tcp_rmem);
295EXPORT_SYMBOL(sysctl_tcp_wmem); 297EXPORT_SYMBOL(sysctl_tcp_wmem);
296 298
@@ -3097,13 +3099,13 @@ static int __init set_thash_entries(char *str)
3097} 3099}
3098__setup("thash_entries=", set_thash_entries); 3100__setup("thash_entries=", set_thash_entries);
3099 3101
3100void tcp_init_mem(struct net *net) 3102static void tcp_init_mem(void)
3101{ 3103{
3102 unsigned long limit = nr_free_buffer_pages() / 8; 3104 unsigned long limit = nr_free_buffer_pages() / 8;
3103 limit = max(limit, 128UL); 3105 limit = max(limit, 128UL);
3104 net->ipv4.sysctl_tcp_mem[0] = limit / 4 * 3; 3106 sysctl_tcp_mem[0] = limit / 4 * 3;
3105 net->ipv4.sysctl_tcp_mem[1] = limit; 3107 sysctl_tcp_mem[1] = limit;
3106 net->ipv4.sysctl_tcp_mem[2] = net->ipv4.sysctl_tcp_mem[0] * 2; 3108 sysctl_tcp_mem[2] = sysctl_tcp_mem[0] * 2;
3107} 3109}
3108 3110
3109void __init tcp_init(void) 3111void __init tcp_init(void)
@@ -3165,7 +3167,7 @@ void __init tcp_init(void)
3165 sysctl_tcp_max_orphans = cnt / 2; 3167 sysctl_tcp_max_orphans = cnt / 2;
3166 sysctl_max_syn_backlog = max(128, cnt / 256); 3168 sysctl_max_syn_backlog = max(128, cnt / 256);
3167 3169
3168 tcp_init_mem(&init_net); 3170 tcp_init_mem();
3169 /* Set per-socket limits to no more than 1/128 the pressure threshold */ 3171 /* Set per-socket limits to no more than 1/128 the pressure threshold */
3170 limit = nr_free_buffer_pages() << (PAGE_SHIFT - 7); 3172 limit = nr_free_buffer_pages() << (PAGE_SHIFT - 7);
3171 max_wshare = min(4UL*1024*1024, limit); 3173 max_wshare = min(4UL*1024*1024, limit);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 114d1b748cbb..300ab2c93f29 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2749,6 +2749,7 @@ struct proto tcp_prot = {
2749 .orphan_count = &tcp_orphan_count, 2749 .orphan_count = &tcp_orphan_count,
2750 .memory_allocated = &tcp_memory_allocated, 2750 .memory_allocated = &tcp_memory_allocated,
2751 .memory_pressure = &tcp_memory_pressure, 2751 .memory_pressure = &tcp_memory_pressure,
2752 .sysctl_mem = sysctl_tcp_mem,
2752 .sysctl_wmem = sysctl_tcp_wmem, 2753 .sysctl_wmem = sysctl_tcp_wmem,
2753 .sysctl_rmem = sysctl_tcp_rmem, 2754 .sysctl_rmem = sysctl_tcp_rmem,
2754 .max_header = MAX_TCP_HEADER, 2755 .max_header = MAX_TCP_HEADER,
diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c
index e7c01fcf5716..86feaa0d6d70 100644
--- a/net/ipv4/tcp_memcontrol.c
+++ b/net/ipv4/tcp_memcontrol.c
@@ -29,7 +29,6 @@ int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
29 struct cg_proto *cg_proto, *parent_cg; 29 struct cg_proto *cg_proto, *parent_cg;
30 struct tcp_memcontrol *tcp; 30 struct tcp_memcontrol *tcp;
31 struct mem_cgroup *parent = parent_mem_cgroup(memcg); 31 struct mem_cgroup *parent = parent_mem_cgroup(memcg);
32 struct net *net = current->nsproxy->net_ns;
33 32
34 cg_proto = tcp_prot.proto_cgroup(memcg); 33 cg_proto = tcp_prot.proto_cgroup(memcg);
35 if (!cg_proto) 34 if (!cg_proto)
@@ -37,9 +36,9 @@ int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
37 36
38 tcp = tcp_from_cgproto(cg_proto); 37 tcp = tcp_from_cgproto(cg_proto);
39 38
40 tcp->tcp_prot_mem[0] = net->ipv4.sysctl_tcp_mem[0]; 39 tcp->tcp_prot_mem[0] = sysctl_tcp_mem[0];
41 tcp->tcp_prot_mem[1] = net->ipv4.sysctl_tcp_mem[1]; 40 tcp->tcp_prot_mem[1] = sysctl_tcp_mem[1];
42 tcp->tcp_prot_mem[2] = net->ipv4.sysctl_tcp_mem[2]; 41 tcp->tcp_prot_mem[2] = sysctl_tcp_mem[2];
43 tcp->tcp_memory_pressure = 0; 42 tcp->tcp_memory_pressure = 0;
44 43
45 parent_cg = tcp_prot.proto_cgroup(parent); 44 parent_cg = tcp_prot.proto_cgroup(parent);
@@ -76,7 +75,6 @@ EXPORT_SYMBOL(tcp_destroy_cgroup);
76 75
77static int tcp_update_limit(struct mem_cgroup *memcg, u64 val) 76static int tcp_update_limit(struct mem_cgroup *memcg, u64 val)
78{ 77{
79 struct net *net = current->nsproxy->net_ns;
80 struct tcp_memcontrol *tcp; 78 struct tcp_memcontrol *tcp;
81 struct cg_proto *cg_proto; 79 struct cg_proto *cg_proto;
82 u64 old_lim; 80 u64 old_lim;
@@ -99,7 +97,7 @@ static int tcp_update_limit(struct mem_cgroup *memcg, u64 val)
99 97
100 for (i = 0; i < 3; i++) 98 for (i = 0; i < 3; i++)
101 tcp->tcp_prot_mem[i] = min_t(long, val >> PAGE_SHIFT, 99 tcp->tcp_prot_mem[i] = min_t(long, val >> PAGE_SHIFT,
102 net->ipv4.sysctl_tcp_mem[i]); 100 sysctl_tcp_mem[i]);
103 101
104 if (val == RES_COUNTER_MAX) 102 if (val == RES_COUNTER_MAX)
105 clear_bit(MEMCG_SOCK_ACTIVE, &cg_proto->flags); 103 clear_bit(MEMCG_SOCK_ACTIVE, &cg_proto->flags);
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 20af1fb81c83..6468bda1f2b9 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -865,8 +865,6 @@ static int __init inet6_init(void)
865 if (err) 865 if (err)
866 goto out_sock_register_fail; 866 goto out_sock_register_fail;
867 867
868 tcpv6_prot.sysctl_mem = init_net.ipv4.sysctl_tcp_mem;
869
870 /* 868 /*
871 * ipngwg API draft makes clear that the correct semantics 869 * ipngwg API draft makes clear that the correct semantics
872 * for TCP and UDP is to consider one TCP and UDP instance 870 * for TCP and UDP is to consider one TCP and UDP instance
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index b996ee2005a9..0740f93a114a 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1929,6 +1929,7 @@ struct proto tcpv6_prot = {
1929 .memory_allocated = &tcp_memory_allocated, 1929 .memory_allocated = &tcp_memory_allocated,
1930 .memory_pressure = &tcp_memory_pressure, 1930 .memory_pressure = &tcp_memory_pressure,
1931 .orphan_count = &tcp_orphan_count, 1931 .orphan_count = &tcp_orphan_count,
1932 .sysctl_mem = sysctl_tcp_mem,
1932 .sysctl_wmem = sysctl_tcp_wmem, 1933 .sysctl_wmem = sysctl_tcp_wmem,
1933 .sysctl_rmem = sysctl_tcp_rmem, 1934 .sysctl_rmem = sysctl_tcp_rmem,
1934 .max_header = MAX_TCP_HEADER, 1935 .max_header = MAX_TCP_HEADER,