linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, netdev@vger.kernel.org,
	cgroups@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 05/14] net: tcp_memcontrol: remove dead per-memcg count of allocated sockets
Date: Tue,  8 Dec 2015 10:30:15 -0500	[thread overview]
Message-ID: <1449588624-9220-6-git-send-email-hannes@cmpxchg.org> (raw)
In-Reply-To: <1449588624-9220-1-git-send-email-hannes@cmpxchg.org>

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>
---
 include/linux/memcontrol.h |  1 -
 include/net/sock.h         | 39 +++------------------------------------
 net/ipv4/tcp_memcontrol.c  |  3 ---
 3 files changed, 3 insertions(+), 40 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index aed64b6..1df8e89 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -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];
diff --git a/include/net/sock.h b/include/net/sock.h
index e27a8bb..7afbdab 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1095,19 +1095,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)
@@ -1233,41 +1223,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
diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c
index d07579a..6759e0d 100644
--- a/net/ipv4/tcp_memcontrol.c
+++ b/net/ipv4/tcp_memcontrol.c
@@ -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);
 
-- 
2.6.3


  parent reply	other threads:[~2015-12-08 15:36 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-08 15:30 [PATCH 00/14] mm: memcontrol: account socket memory in unified hierarchy v4-RESEND Johannes Weiner
2015-12-08 15:30 ` [PATCH 01/14] mm: memcontrol: export root_mem_cgroup Johannes Weiner
2015-12-08 15:30 ` [PATCH 02/14] net: tcp_memcontrol: properly detect ancestor socket pressure Johannes Weiner
2015-12-08 15:30 ` [PATCH 03/14] net: tcp_memcontrol: remove bogus hierarchy pressure propagation Johannes Weiner
2015-12-08 15:30 ` [PATCH 04/14] net: tcp_memcontrol: protect all tcp_memcontrol calls by jump-label Johannes Weiner
2015-12-08 15:30 ` Johannes Weiner [this message]
2015-12-08 15:30 ` [PATCH 06/14] net: tcp_memcontrol: simplify the per-memcg limit access Johannes Weiner
2015-12-08 15:30 ` [PATCH 07/14] net: tcp_memcontrol: sanitize tcp memory accounting callbacks Johannes Weiner
2015-12-08 15:30 ` [PATCH 08/14] net: tcp_memcontrol: simplify linkage between socket and page counter Johannes Weiner
2015-12-08 15:30 ` [PATCH 09/14] mm: memcontrol: generalize the socket accounting jump label Johannes Weiner
2015-12-08 15:30 ` [PATCH 10/14] mm: memcontrol: do not account memory+swap on unified hierarchy Johannes Weiner
2015-12-08 15:30 ` [PATCH 11/14] mm: memcontrol: move socket code for unified hierarchy accounting Johannes Weiner
2015-12-08 15:30 ` [PATCH 12/14] mm: memcontrol: account socket memory in unified hierarchy memory controller Johannes Weiner
2015-12-15 19:50   ` Michal Hocko
2015-12-08 15:30 ` [PATCH 13/14] mm: memcontrol: hook up vmpressure to socket pressure Johannes Weiner
2015-12-08 15:30 ` [PATCH 14/14] mm: memcontrol: switch to the updated jump-label API Johannes Weiner
2015-12-08 16:28   ` David Miller
2015-12-08 16:28 ` [PATCH 00/14] mm: memcontrol: account socket memory in unified hierarchy v4-RESEND David Miller
2015-12-09 16:31 ` Arnd Bergmann
2015-12-09 16:32   ` [PATCH] mm: memcontrol: only manage socket pressure for CONFIG_INET Arnd Bergmann
2015-12-09 18:58     ` Johannes Weiner
2015-12-09 22:28       ` Andrew Morton
2015-12-09 23:05         ` Johannes Weiner
2015-12-09 23:13           ` Andrew Morton
2016-01-22  3:25             ` Masanari Iida
2015-12-09 16:32   ` [PATCH] mm: memcontrol: MEMCG no longer works with SLOB Arnd Bergmann
2015-12-09 20:01     ` Johannes Weiner
2015-12-09 21:03       ` Arnd Bergmann
2015-12-10 11:24       ` Vladimir Davydov
2015-12-09 18:17   ` [PATCH 00/14] mm: memcontrol: account socket memory in unified hierarchy v4-RESEND Johannes Weiner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449588624-9220-6-git-send-email-hannes@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).