]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: tcp_memcontrol: remove dead per-memcg count of allocated sockets
authorJohannes Weiner <hannes@cmpxchg.org>
Thu, 14 Jan 2016 23:21:08 +0000 (15:21 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 15 Jan 2016 00:00:49 +0000 (16:00 -0800)
The number of allocated sockets is used for calculations in the soft
limit phase, where packets are accepted but the socket is under memory
pressure.
 Since there is no soft limit phase in tcp_memcontrol, and memory
pressure is only entered when packets are already dropped, this is
actually dead code.  Remove it.

As this is the last user of parent_cg_proto(), remove that too.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: David S. Miller <davem@davemloft.net>
Reviewed-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/memcontrol.h
include/net/sock.h
net/ipv4/tcp_memcontrol.c

index 85c437b0cbc0a96292e57bd5ff0e23af16f79aed..15acc04ebdd38ec994feac9a515c4004425ac37e 100644 (file)
@@ -87,7 +87,6 @@ enum mem_cgroup_events_target {
 
 struct cg_proto {
        struct page_counter     memory_allocated;       /* Current allocated memory. */
-       struct percpu_counter   sockets_allocated;      /* Current number of sockets. */
        int                     memory_pressure;
        bool                    active;
        long                    sysctl_mem[3];
index d3b035c7362b9f96811e5e1e0f439f8589fb7f73..1f15937ec20843c670a97ee4c3afd2e32b48b915 100644 (file)
@@ -1098,19 +1098,9 @@ static inline void sk_refcnt_debug_release(const struct sock *sk)
 
 #if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_NET)
 extern struct static_key memcg_socket_limit_enabled;
-static inline struct cg_proto *parent_cg_proto(struct proto *proto,
-                                              struct cg_proto *cg_proto)
-{
-       return proto->proto_cgroup(parent_mem_cgroup(cg_proto->memcg));
-}
 #define mem_cgroup_sockets_enabled static_key_false(&memcg_socket_limit_enabled)
 #else
 #define mem_cgroup_sockets_enabled 0
-static inline struct cg_proto *parent_cg_proto(struct proto *proto,
-                                              struct cg_proto *cg_proto)
-{
-       return NULL;
-}
 #endif
 
 static inline bool sk_stream_memory_free(const struct sock *sk)
@@ -1236,41 +1226,18 @@ sk_memory_allocated_sub(struct sock *sk, int amt)
 
 static inline void sk_sockets_allocated_dec(struct sock *sk)
 {
-       struct proto *prot = sk->sk_prot;
-
-       if (mem_cgroup_sockets_enabled && sk->sk_cgrp) {
-               struct cg_proto *cg_proto = sk->sk_cgrp;
-
-               for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto))
-                       percpu_counter_dec(&cg_proto->sockets_allocated);
-       }
-
-       percpu_counter_dec(prot->sockets_allocated);
+       percpu_counter_dec(sk->sk_prot->sockets_allocated);
 }
 
 static inline void sk_sockets_allocated_inc(struct sock *sk)
 {
-       struct proto *prot = sk->sk_prot;
-
-       if (mem_cgroup_sockets_enabled && sk->sk_cgrp) {
-               struct cg_proto *cg_proto = sk->sk_cgrp;
-
-               for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto))
-                       percpu_counter_inc(&cg_proto->sockets_allocated);
-       }
-
-       percpu_counter_inc(prot->sockets_allocated);
+       percpu_counter_inc(sk->sk_prot->sockets_allocated);
 }
 
 static inline int
 sk_sockets_allocated_read_positive(struct sock *sk)
 {
-       struct proto *prot = sk->sk_prot;
-
-       if (mem_cgroup_sockets_enabled && sk->sk_cgrp)
-               return percpu_counter_read_positive(&sk->sk_cgrp->sockets_allocated);
-
-       return percpu_counter_read_positive(prot->sockets_allocated);
+       return percpu_counter_read_positive(sk->sk_prot->sockets_allocated);
 }
 
 static inline int
index d07579ada0014952394aa0a52c678757cff038a8..6759e0d6bba1b52815a5517ed4f71d5dd5d9aa0d 100644 (file)
@@ -32,7 +32,6 @@ int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
                counter_parent = &parent_cg->memory_allocated;
 
        page_counter_init(&cg_proto->memory_allocated, counter_parent);
-       percpu_counter_init(&cg_proto->sockets_allocated, 0, GFP_KERNEL);
 
        return 0;
 }
@@ -46,8 +45,6 @@ void tcp_destroy_cgroup(struct mem_cgroup *memcg)
        if (!cg_proto)
                return;
 
-       percpu_counter_destroy(&cg_proto->sockets_allocated);
-
        if (cg_proto->active)
                static_key_slow_dec(&memcg_socket_limit_enabled);