]> Pileus Git - ~andy/linux/commitdiff
tcp_memcontrol: Remove the per netns control.
authorEric W. Biederman <ebiederm@xmission.com>
Sat, 19 Oct 2013 23:25:36 +0000 (16:25 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 21 Oct 2013 22:43:02 +0000 (18:43 -0400)
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>
include/net/netns/ipv4.h
include/net/tcp.h
net/ipv4/af_inet.c
net/ipv4/sysctl_net_ipv4.c
net/ipv4/tcp.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_memcontrol.c
net/ipv6/af_inet6.c
net/ipv6/tcp_ipv6.c

index 5dbd232e12ffce75dbcbb9cbfcac2ccdf5cf1cec..ee520cba2ec2f9f1ce1f011b985524946085fb60 100644 (file)
@@ -71,7 +71,6 @@ struct netns_ipv4 {
        int sysctl_tcp_ecn;
 
        kgid_t sysctl_ping_group_range[2];
-       long sysctl_tcp_mem[3];
 
        atomic_t dev_addr_genid;
 
index b12e29a7659044623b51b729d524a5ecde7e6a8e..2d7b4bdc972ff38ac5a0a0f357c8c081c7d09014 100644 (file)
@@ -259,6 +259,7 @@ extern int sysctl_tcp_max_orphans;
 extern int sysctl_tcp_fack;
 extern int sysctl_tcp_reordering;
 extern int sysctl_tcp_dsack;
+extern long sysctl_tcp_mem[3];
 extern int sysctl_tcp_wmem[3];
 extern int sysctl_tcp_rmem[3];
 extern int sysctl_tcp_app_win;
@@ -348,8 +349,6 @@ extern struct proto tcp_prot;
 #define TCP_ADD_STATS_USER(net, field, val) SNMP_ADD_STATS_USER((net)->mib.tcp_statistics, field, val)
 #define TCP_ADD_STATS(net, field, val) SNMP_ADD_STATS((net)->mib.tcp_statistics, field, val)
 
-void tcp_init_mem(struct net *net);
-
 void tcp_tasklet_init(void);
 
 void tcp_v4_err(struct sk_buff *skb, u32);
index 9433a6186f5415587cfb030c504225b2e5016e49..24a53fc275b0ae8c1dabaa4e5e8495f0d3d9fd1d 100644 (file)
@@ -1697,8 +1697,6 @@ static int __init inet_init(void)
        ip_static_sysctl_init();
 #endif
 
-       tcp_prot.sysctl_mem = init_net.ipv4.sysctl_tcp_mem;
-
        /*
         *      Add all the base protocols.
         */
index 8457f7bc4d89234f408366625754425f29c5be72..69c6a8dbe09dab14f32225f76e1241eb87be5353 100644 (file)
@@ -200,14 +200,6 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
        return ret;
 }
 
-static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
-                          void __user *buffer, size_t *lenp,
-                          loff_t *ppos)
-{
-       ctl->data = &current->nsproxy->net_ns->ipv4.sysctl_tcp_mem;
-       return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
-}
-
 static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
                                 void __user *buffer, size_t *lenp,
                                 loff_t *ppos)
@@ -521,6 +513,13 @@ static struct ctl_table ipv4_table[] = {
                .mode           = 0644,
                .proc_handler   = proc_dointvec
        },
+       {
+               .procname       = "tcp_mem",
+               .maxlen         = sizeof(sysctl_tcp_mem),
+               .data           = &sysctl_tcp_mem,
+               .mode           = 0644,
+               .proc_handler   = proc_doulongvec_minmax,
+       },
        {
                .procname       = "tcp_wmem",
                .data           = &sysctl_tcp_wmem,
@@ -830,12 +829,6 @@ static struct ctl_table ipv4_net_table[] = {
                .mode           = 0644,
                .proc_handler   = ipv4_local_port_range,
        },
-       {
-               .procname       = "tcp_mem",
-               .maxlen         = sizeof(init_net.ipv4.sysctl_tcp_mem),
-               .mode           = 0644,
-               .proc_handler   = ipv4_tcp_mem,
-       },
        { }
 };
 
@@ -887,8 +880,6 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
        net->ipv4.sysctl_local_ports.range[0] =  32768;
        net->ipv4.sysctl_local_ports.range[1] =  61000;
 
-       tcp_init_mem(net);
-
        net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
        if (net->ipv4.ipv4_hdr == NULL)
                goto err_reg;
index be4b161802e8abcbccbbd5580155275b810e2111..8e8529d3c8c92a4473a3ed9fd8db876ca83533bd 100644 (file)
@@ -288,9 +288,11 @@ int sysctl_tcp_min_tso_segs __read_mostly = 2;
 struct percpu_counter tcp_orphan_count;
 EXPORT_SYMBOL_GPL(tcp_orphan_count);
 
+long sysctl_tcp_mem[3] __read_mostly;
 int sysctl_tcp_wmem[3] __read_mostly;
 int sysctl_tcp_rmem[3] __read_mostly;
 
+EXPORT_SYMBOL(sysctl_tcp_mem);
 EXPORT_SYMBOL(sysctl_tcp_rmem);
 EXPORT_SYMBOL(sysctl_tcp_wmem);
 
@@ -3097,13 +3099,13 @@ static int __init set_thash_entries(char *str)
 }
 __setup("thash_entries=", set_thash_entries);
 
-void tcp_init_mem(struct net *net)
+static void tcp_init_mem(void)
 {
        unsigned long limit = nr_free_buffer_pages() / 8;
        limit = max(limit, 128UL);
-       net->ipv4.sysctl_tcp_mem[0] = limit / 4 * 3;
-       net->ipv4.sysctl_tcp_mem[1] = limit;
-       net->ipv4.sysctl_tcp_mem[2] = net->ipv4.sysctl_tcp_mem[0] * 2;
+       sysctl_tcp_mem[0] = limit / 4 * 3;
+       sysctl_tcp_mem[1] = limit;
+       sysctl_tcp_mem[2] = sysctl_tcp_mem[0] * 2;
 }
 
 void __init tcp_init(void)
@@ -3165,7 +3167,7 @@ void __init tcp_init(void)
        sysctl_tcp_max_orphans = cnt / 2;
        sysctl_max_syn_backlog = max(128, cnt / 256);
 
-       tcp_init_mem(&init_net);
+       tcp_init_mem();
        /* Set per-socket limits to no more than 1/128 the pressure threshold */
        limit = nr_free_buffer_pages() << (PAGE_SHIFT - 7);
        max_wshare = min(4UL*1024*1024, limit);
index 114d1b748cbb723aab97e27111eeeeda8718006c..300ab2c93f29270d4dbdd2d1b65b64d8dc82200a 100644 (file)
@@ -2749,6 +2749,7 @@ struct proto tcp_prot = {
        .orphan_count           = &tcp_orphan_count,
        .memory_allocated       = &tcp_memory_allocated,
        .memory_pressure        = &tcp_memory_pressure,
+       .sysctl_mem             = sysctl_tcp_mem,
        .sysctl_wmem            = sysctl_tcp_wmem,
        .sysctl_rmem            = sysctl_tcp_rmem,
        .max_header             = MAX_TCP_HEADER,
index e7c01fcf57162acf7a8d73f2a6d55530904316ef..86feaa0d6d703c5231978fed12b5762c2a8ebb63 100644 (file)
@@ -29,7 +29,6 @@ int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
        struct cg_proto *cg_proto, *parent_cg;
        struct tcp_memcontrol *tcp;
        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)
@@ -37,9 +36,9 @@ int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
 
        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_prot_mem[0] = sysctl_tcp_mem[0];
+       tcp->tcp_prot_mem[1] = sysctl_tcp_mem[1];
+       tcp->tcp_prot_mem[2] = sysctl_tcp_mem[2];
        tcp->tcp_memory_pressure = 0;
 
        parent_cg = tcp_prot.proto_cgroup(parent);
@@ -76,7 +75,6 @@ EXPORT_SYMBOL(tcp_destroy_cgroup);
 
 static int tcp_update_limit(struct mem_cgroup *memcg, u64 val)
 {
-       struct net *net = current->nsproxy->net_ns;
        struct tcp_memcontrol *tcp;
        struct cg_proto *cg_proto;
        u64 old_lim;
@@ -99,7 +97,7 @@ static int tcp_update_limit(struct mem_cgroup *memcg, u64 val)
 
        for (i = 0; i < 3; i++)
                tcp->tcp_prot_mem[i] = min_t(long, val >> PAGE_SHIFT,
-                                            net->ipv4.sysctl_tcp_mem[i]);
+                                            sysctl_tcp_mem[i]);
 
        if (val == RES_COUNTER_MAX)
                clear_bit(MEMCG_SOCK_ACTIVE, &cg_proto->flags);
index 20af1fb81c837ad0a4b328642e958210c6d01f3d..6468bda1f2b94c382fe7212135ed1245f71e221f 100644 (file)
@@ -865,8 +865,6 @@ static int __init inet6_init(void)
        if (err)
                goto out_sock_register_fail;
 
-       tcpv6_prot.sysctl_mem = init_net.ipv4.sysctl_tcp_mem;
-
        /*
         *      ipngwg API draft makes clear that the correct semantics
         *      for TCP and UDP is to consider one TCP and UDP instance
index b996ee2005a97ed971a4493a3323e224018685c2..0740f93a114a26ac09150638576f523bcd53694c 100644 (file)
@@ -1929,6 +1929,7 @@ struct proto tcpv6_prot = {
        .memory_allocated       = &tcp_memory_allocated,
        .memory_pressure        = &tcp_memory_pressure,
        .orphan_count           = &tcp_orphan_count,
+       .sysctl_mem             = sysctl_tcp_mem,
        .sysctl_wmem            = sysctl_tcp_wmem,
        .sysctl_rmem            = sysctl_tcp_rmem,
        .max_header             = MAX_TCP_HEADER,