linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: davem@davemloft.net, willy@infradead.org
Cc: netdev@vger.kernel.org, linux-mm@kvack.org, ikomyagin@gmail.com,
	Stephen Hemminger <sthemmin@microsoft.com>,
	Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH 2/2] net: mark slab's used by ss as UAPI
Date: Sat, 24 Feb 2018 11:04:54 -0800	[thread overview]
Message-ID: <20180224190454.23716-3-sthemmin@microsoft.com> (raw)
In-Reply-To: <20180224190454.23716-1-sthemmin@microsoft.com>

The iproute2 ss command reads /proc/slabinfo as way to get estimates
for number of open sockets etc. This has been broken since slab
merging went in 3.17.

Mark those kmem caches's as non mergeable with new flag.
The TCP caches's are already not mergeable because of the RCU
flags, but someone might change that and cause surprise later.

Reported-by: Igor Komyagin <ikomyagin@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 net/ipv4/tcp.c      | 3 ++-
 net/ipv4/tcp_ipv4.c | 2 +-
 net/ipv6/tcp_ipv6.c | 2 +-
 net/socket.c        | 6 +++---
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 48636aee23c3..8c0d4cdc601d 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -3617,7 +3617,8 @@ void __init tcp_init(void)
 	tcp_hashinfo.bind_bucket_cachep =
 		kmem_cache_create("tcp_bind_bucket",
 				  sizeof(struct inet_bind_bucket), 0,
-				  SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
+				  SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_VISIBLE_UAPI,
+				  NULL);
 
 	/* Size and allocate the main established and bind bucket
 	 * hash tables.
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index f8ad397e285e..4442f91fab93 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -2434,7 +2434,7 @@ struct proto tcp_prot = {
 	.sysctl_rmem_offset	= offsetof(struct net, ipv4.sysctl_tcp_rmem),
 	.max_header		= MAX_TCP_HEADER,
 	.obj_size		= sizeof(struct tcp_sock),
-	.slab_flags		= SLAB_TYPESAFE_BY_RCU,
+	.slab_flags		= SLAB_TYPESAFE_BY_RCU | SLAB_VISIBLE_UAPI,
 	.twsk_prot		= &tcp_timewait_sock_ops,
 	.rsk_prot		= &tcp_request_sock_ops,
 	.h.hashinfo		= &tcp_hashinfo,
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 412139f4eccd..d6df3b3f401c 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1944,7 +1944,7 @@ struct proto tcpv6_prot = {
 	.sysctl_rmem_offset	= offsetof(struct net, ipv4.sysctl_tcp_rmem),
 	.max_header		= MAX_TCP_HEADER,
 	.obj_size		= sizeof(struct tcp6_sock),
-	.slab_flags		= SLAB_TYPESAFE_BY_RCU,
+	.slab_flags		= SLAB_TYPESAFE_BY_RCU | SLAB_VISIBLE_UAPI,
 	.twsk_prot		= &tcp6_timewait_sock_ops,
 	.rsk_prot		= &tcp6_request_sock_ops,
 	.h.hashinfo		= &tcp_hashinfo,
diff --git a/net/socket.c b/net/socket.c
index a93c99b518ca..f76ae11af8c7 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -286,9 +286,9 @@ static void init_inodecache(void)
 	sock_inode_cachep = kmem_cache_create("sock_inode_cache",
 					      sizeof(struct socket_alloc),
 					      0,
-					      (SLAB_HWCACHE_ALIGN |
-					       SLAB_RECLAIM_ACCOUNT |
-					       SLAB_MEM_SPREAD | SLAB_ACCOUNT),
+					      SLAB_HWCACHE_ALIGN | SLAB_VISIBLE_UAPI |
+					      SLAB_RECLAIM_ACCOUNT |
+					      SLAB_MEM_SPREAD | SLAB_ACCOUNT,
 					      init_once);
 	BUG_ON(sock_inode_cachep == NULL);
 }
-- 
2.16.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2018-02-24 19:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-24 19:04 [PATCH 0/2] mark some slabs as visible not mergeable Stephen Hemminger
2018-02-24 19:04 ` [PATCH 1/2] slab: add flag to block merging of UAPI elements Stephen Hemminger
2018-02-24 19:04 ` Stephen Hemminger [this message]
2018-02-25  3:34   ` [PATCH 2/2] net: mark slab's used by ss as UAPI kbuild test robot
2018-02-25  6:05   ` [net] ba4f5b62a2: kernel_BUG_at_net/socket.c kernel test robot
2018-02-24 21:05 ` [PATCH 0/2] mark some slabs as visible not mergeable Matthew Wilcox
2018-02-25 16:36 ` Stephen Hemminger
2018-02-26 20:15 ` David Miller
2018-02-26 21:46   ` Stephen Hemminger
2018-02-27  1:13     ` David Miller

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=20180224190454.23716-3-sthemmin@microsoft.com \
    --to=stephen@networkplumber.org \
    --cc=davem@davemloft.net \
    --cc=ikomyagin@gmail.com \
    --cc=linux-mm@kvack.org \
    --cc=netdev@vger.kernel.org \
    --cc=sthemmin@microsoft.com \
    --cc=willy@infradead.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