[PATCH 0/2] mark some slabs as visible not mergeable

STALE3115d

10 messages, 6 authors, 2018-02-27 · open the first message on its own page

[PATCH 0/2] mark some slabs as visible not mergeable

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2018-02-24 19:05:03

This fixes an old bug in iproute2's ss command because it was
reading slabinfo to get statistics. There isn't a better API
to do this, and one can argue that /proc is a UAPI that must
not change.

Therefore this patch set adds a flag to slab to give another
reason to prevent merging, and then uses it in network code.

The patches are against davem's linux-net tree and should also
goto stable as well.

Stephen Hemminger (2):
  slab: add flag to block merging of UAPI elements
  net: mark slab's used by ss as UAPI

 include/linux/slab.h | 6 ++++++
 mm/slab_common.c     | 2 +-
 net/ipv4/tcp.c       | 3 ++-
 net/ipv4/tcp_ipv4.c  | 2 +-
 net/ipv6/tcp_ipv6.c  | 2 +-
 net/socket.c         | 6 +++---
 6 files changed, 14 insertions(+), 7 deletions(-)

-- 
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>

[PATCH 1/2] slab: add flag to block merging of UAPI elements

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2018-02-24 19:05:04

The iproute2 program ss reads /proc/slabinfo to get TCP socket
statistics; therefore those kmem cache's can not be merged.
This patch adds a new flag to block merging in these kind
of cases.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 include/linux/slab.h | 6 ++++++
 mm/slab_common.c     | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 231abc8976c5..867acc2ddcbc 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -108,6 +108,12 @@
 #define SLAB_KASAN		0
 #endif
 
+/*
+ * Some old applications may want to read/write particular slab cache
+ * by name and therefore this can not be merged.
+ */
+#define SLAB_VISIBLE_UAPI	0x10000000UL
+
 /* The following flags affect the page allocator grouping pages by mobility */
 /* Objects are reclaimable */
 #define SLAB_RECLAIM_ACCOUNT	((slab_flags_t __force)0x00020000U)
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 10f127b2de7c..71eb5fc63cf8 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -49,7 +49,7 @@ static DECLARE_WORK(slab_caches_to_rcu_destroy_work,
  */
 #define SLAB_NEVER_MERGE (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER | \
 		SLAB_TRACE | SLAB_TYPESAFE_BY_RCU | SLAB_NOLEAKTRACE | \
-		SLAB_FAILSLAB | SLAB_KASAN)
+		SLAB_FAILSLAB | SLAB_KASAN | SLAB_VISIBLE_UAPI)
 
 #define SLAB_MERGE_SAME (SLAB_RECLAIM_ACCOUNT | SLAB_CACHE_DMA | \
 			 SLAB_ACCOUNT)
-- 
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>

[PATCH 2/2] net: mark slab's used by ss as UAPI

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2018-02-24 19:05:06

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 <redacted>
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>

Re: [PATCH 0/2] mark some slabs as visible not mergeable

From: Matthew Wilcox <willy@infradead.org>
Date: 2018-02-24 21:05:19

On Sat, Feb 24, 2018 at 11:04:52AM -0800, Stephen Hemminger wrote:
This fixes an old bug in iproute2's ss command because it was
reading slabinfo to get statistics. There isn't a better API
to do this, and one can argue that /proc is a UAPI that must
not change.

Therefore this patch set adds a flag to slab to give another
reason to prevent merging, and then uses it in network code.
This is exactly the solution I would have suggested.  Note that SLUB
has always had slab merging, so this tool has been broken since 2.6.22
on any kernel with CONFIG_SLUB.

Reviewed-by: Matthew Wilcox <redacted>

--
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>

Re: [PATCH 2/2] net: mark slab's used by ss as UAPI

From: kbuild test robot <hidden>
Date: 2018-02-25 03:34:47

Hi Stephen,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net/master]
[also build test WARNING on v4.16-rc2 next-20180223]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Stephen-Hemminger/mark-some-slabs-as-visible-not-mergeable/20180225-084344
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   include/linux/init.h:134:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/init.h:135:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/init.h:268:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/init.h:269:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/printk.h:200:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:32:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:34:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:37:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:38:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:40:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:42:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:43:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:45:5: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:46:5: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:49:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/qspinlock.h:53:32: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/workqueue.h:646:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/workqueue.h:647:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/memory_hotplug.h:221:13: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/numa.h:34:12: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/numa.h:35:13: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/numa.h:62:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/vmalloc.h:64:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/vmalloc.h:173:8: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/vmalloc.h:174:8: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/fixmap.h:174:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/fixmap.h:176:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/fixmap.h:178:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/fixmap.h:180:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/apic.h:254:13: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/apic.h:430:13: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/io_apic.h:184:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/mmzone.h:1292:15: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/smp.h:113:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/smp.h:125:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/smp.h:126:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/percpu.h:110:33: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/percpu.h:112:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/percpu.h:114:12: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/percpu.h:118:12: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/percpu.h:126:12: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/kmemleak.h:29:33: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/kasan.h:29:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/kasan.h:30:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/pgtable.h:28:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/slab.h:141:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/slab.h:722:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/hrtimer.h:497:13: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/vdso.h:44:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/wait_bit.h:41:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/fs.h:63:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/fs.h:64:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/fs.h:65:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/fs.h:66:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/fs.h:2421:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/fs.h:2422:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/fs.h:3329:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/mm.h:1753:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/mm.h:1941:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/mm.h:2083:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/mm.h:2671:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/swiotlb.h:39:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/swiotlb.h:124:13: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/swiotlb.h:9:12: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/swiotlb.h:10:12: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/swiotlb.h:11:13: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/swiotlb.h:12:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/dma-contiguous.h:85:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/bootmem.h:175:22: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/bootmem.h:183:22: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/bootmem.h:191:22: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/bootmem.h:200:22: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/bootmem.h:208:22: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/bootmem.h:217:22: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/bootmem.h:225:22: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/bootmem.h:232:22: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/bootmem.h:240:20: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/bootmem.h:246:20: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/bootmem.h:252:20: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/io.h:47:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/cred.h:167:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/nsproxy.h:74:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/netdevice.h:302:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/netdevice.h:4056:5: sparse: attribute 'indirect_branch': unknown attribute
   include/net/inetpeer.h:68:27: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/audit.h:90:12: sparse: attribute 'indirect_branch': unknown attribute
   net//ipv4/tcp.c:3577:12: sparse: attribute 'indirect_branch': unknown attribute
   net//ipv4/tcp.c:3592:13: sparse: attribute 'indirect_branch': unknown attribute
   net//ipv4/tcp.c:3602:6: sparse: attribute 'indirect_branch': unknown attribute
quoted
net//ipv4/tcp.c:3620:53: sparse: restricted slab_flags_t degrades to integer
net//ipv4/tcp.c:3620:64: sparse: incorrect type in argument 4 (different base types) @@ expected restricted slab_flags_t flags @@ got t flags @@
   net//ipv4/tcp.c:3620:64: expected restricted slab_flags_t flags
   net//ipv4/tcp.c:3620:64: got unsigned long
   include/net/sock.h:1489:31: sparse: context imbalance in 'tcp_ioctl' - unexpected unlock
   include/net/sock.h:1489:31: sparse: context imbalance in 'tcp_get_info' - unexpected unlock
--
   include/linux/init.h:134:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/init.h:135:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/init.h:268:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/init.h:269:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/printk.h:200:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:32:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:34:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:37:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:38:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:40:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:42:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:43:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:45:5: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:46:5: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/mem_encrypt.h:49:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/qspinlock.h:53:32: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/workqueue.h:646:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/workqueue.h:647:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/memory_hotplug.h:221:13: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/numa.h:34:12: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/numa.h:35:13: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/numa.h:62:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/vmalloc.h:64:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/vmalloc.h:173:8: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/vmalloc.h:174:8: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/fixmap.h:174:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/fixmap.h:176:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/fixmap.h:178:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/fixmap.h:180:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/apic.h:254:13: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/apic.h:430:13: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/io_apic.h:184:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/mmzone.h:1292:15: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/smp.h:113:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/smp.h:125:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/smp.h:126:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/percpu.h:110:33: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/percpu.h:112:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/percpu.h:114:12: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/percpu.h:118:12: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/percpu.h:126:12: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/vdso.h:44:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/kmemleak.h:29:33: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/kasan.h:29:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/kasan.h:30:6: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/pgtable.h:28:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/slab.h:141:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/slab.h:722:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/wait_bit.h:41:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/fs.h:63:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/fs.h:64:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/fs.h:65:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/fs.h:66:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/fs.h:2421:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/fs.h:2422:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/fs.h:3329:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/hrtimer.h:497:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/mm.h:1753:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/mm.h:1941:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/mm.h:2083:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/mm.h:2671:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/swiotlb.h:39:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/swiotlb.h:124:13: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/swiotlb.h:9:12: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/swiotlb.h:10:12: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/swiotlb.h:11:13: sparse: attribute 'indirect_branch': unknown attribute
   arch/x86/include/asm/swiotlb.h:12:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/dma-contiguous.h:85:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/cred.h:167:13: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/nsproxy.h:74:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/io.h:47:6: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/netdevice.h:302:5: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/netdevice.h:4056:5: sparse: attribute 'indirect_branch': unknown attribute
   include/net/inetpeer.h:68:27: sparse: attribute 'indirect_branch': unknown attribute
   include/linux/audit.h:90:12: sparse: attribute 'indirect_branch': unknown attribute
   net//ipv4/tcp_ipv4.c:2392:5: sparse: attribute 'indirect_branch': unknown attribute
   net//ipv4/tcp_ipv4.c:2578:6: sparse: attribute 'indirect_branch': unknown attribute
quoted
net//ipv4/tcp_ipv4.c:2437:35: sparse: restricted slab_flags_t degrades to integer
net//ipv4/tcp_ipv4.c:2437:56: sparse: incorrect type in initializer (different base types) @@ expected restricted slab_flags_t slab_flags @@ got t slab_flags @@
   net//ipv4/tcp_ipv4.c:2437:56: expected restricted slab_flags_t slab_flags
   net//ipv4/tcp_ipv4.c:2437:56: got unsigned long
   net//ipv4/tcp_ipv4.c:2553:50: sparse: incorrect type in assignment (different address spaces) @@ expected struct tcp_congestion_ops const @@ got ps const @@
   net//ipv4/tcp_ipv4.c:2553:50: expected struct tcp_congestion_ops const
   net//ipv4/tcp_ipv4.c:2553:50: got struct tcp_congestion_ops
   net//ipv4/tcp_ipv4.c:1572:17: sparse: context imbalance in 'tcp_add_backlog' - unexpected unlock
   net//ipv4/tcp_ipv4.c:1779:21: sparse: context imbalance in 'tcp_v4_rcv' - different lock contexts for basic block
   net//ipv4/tcp_ipv4.c:1970:20: sparse: context imbalance in 'listening_get_next' - unexpected unlock
   net//ipv4/tcp_ipv4.c:2030:9: sparse: context imbalance in 'established_get_first' - wrong count at exit
   net//ipv4/tcp_ipv4.c:2050:40: sparse: context imbalance in 'established_get_next' - unexpected unlock
   net//ipv4/tcp_ipv4.c:2178:36: sparse: context imbalance in 'tcp_seq_stop' - unexpected unlock
   net//ipv4/tcp_ipv4.c:2454:29: sparse: dereference of noderef expression
   net//ipv4/tcp_ipv4.c:2550:41: sparse: dereference of noderef expression
--
quoted
net//ipv6/tcp_ipv6.c:1947:35: sparse: restricted slab_flags_t degrades to integer
net//ipv6/tcp_ipv6.c:1947:56: sparse: incorrect type in initializer (different base types) @@ expected restricted slab_flags_t slab_flags @@ got t slab_flags @@
   net//ipv6/tcp_ipv6.c:1947:56: expected restricted slab_flags_t slab_flags
   net//ipv6/tcp_ipv6.c:1947:56: got unsigned long
   net//ipv6/tcp_ipv6.c:1551:21: sparse: context imbalance in 'tcp_v6_rcv' - different lock contexts for basic block

vim +3620 net//ipv4/tcp.c

  3575	
  3576	static __initdata unsigned long thash_entries;
3577	static int __init set_thash_entries(char *str)
  3578	{
  3579		ssize_t ret;
  3580	
  3581		if (!str)
  3582			return 0;
  3583	
  3584		ret = kstrtoul(str, 0, &thash_entries);
  3585		if (ret)
  3586			return 0;
  3587	
  3588		return 1;
  3589	}
  3590	__setup("thash_entries=", set_thash_entries);
  3591	
  3592	static void __init tcp_init_mem(void)
  3593	{
  3594		unsigned long limit = nr_free_buffer_pages() / 16;
  3595	
  3596		limit = max(limit, 128UL);
  3597		sysctl_tcp_mem[0] = limit / 4 * 3;		/* 4.68 % */
  3598		sysctl_tcp_mem[1] = limit;			/* 6.25 % */
  3599		sysctl_tcp_mem[2] = sysctl_tcp_mem[0] * 2;	/* 9.37 % */
  3600	}
  3601	
  3602	void __init tcp_init(void)
  3603	{
  3604		int max_rshare, max_wshare, cnt;
  3605		unsigned long limit;
  3606		unsigned int i;
  3607	
  3608		BUILD_BUG_ON(sizeof(struct tcp_skb_cb) >
  3609			     FIELD_SIZEOF(struct sk_buff, cb));
  3610	
  3611		percpu_counter_init(&tcp_sockets_allocated, 0, GFP_KERNEL);
  3612		percpu_counter_init(&tcp_orphan_count, 0, GFP_KERNEL);
  3613		inet_hashinfo_init(&tcp_hashinfo);
  3614		inet_hashinfo2_init(&tcp_hashinfo, "tcp_listen_portaddr_hash",
  3615				    thash_entries, 21,  /* one slot per 2 MB*/
  3616				    0, 64 * 1024);
  3617		tcp_hashinfo.bind_bucket_cachep =
  3618			kmem_cache_create("tcp_bind_bucket",
  3619					  sizeof(struct inet_bind_bucket), 0,
3620					  SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_VISIBLE_UAPI,
---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

--
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>

[net] ba4f5b62a2: kernel_BUG_at_net/socket.c

From: kernel test robot <hidden>
Date: 2018-02-25 06:06:07

FYI, we noticed the following commit (built with gcc-7):

commit: ba4f5b62a2565718cf1b85e736df12da68bbb114 ("net: mark slab's used by ss as UAPI")
url: https://github.com/0day-ci/linux/commits/Stephen-Hemminger/mark-some-slabs-as-visible-not-mergeable/20180225-084344


in testcase: trinity
with following parameters:

	runtime: 300s

test-description: Trinity is a linux system call fuzz tester.
test-url: http://codemonkey.org.uk/projects/trinity/


on test machine: qemu-system-x86_64 -enable-kvm -m 512M

caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):


+------------------------------------------+------------+------------+
|                                          | 679d6c9b78 | ba4f5b62a2 |
+------------------------------------------+------------+------------+
| boot_successes                           | 37         | 0          |
| boot_failures                            | 0          | 6          |
| kernel_BUG_at_net/socket.c               | 0          | 6          |
| invalid_opcode:#[##]                     | 0          | 6          |
| RIP:sock_init                            | 0          | 6          |
| Kernel_panic-not_syncing:Fatal_exception | 0          | 6          |
+------------------------------------------+------------+------------+



[    0.054820] kernel BUG at net/socket.c:293!
[    0.055261] invalid opcode: 0000 [#1] PREEMPT
[    0.055574] CPU: 0 PID: 1 Comm: swapper Not tainted 4.16.0-rc2-00147-gba4f5b6 #1
[    0.056094] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
[    0.056681] RIP: 0010:sock_init+0xc7/0x1a9
[    0.056979] RSP: 0000:ffffc9000000be58 EFLAGS: 00010293
[    0.057351] RAX: 0000000000000000 RBX: cbc1095dc7d516bb RCX: ffff88001f66e040
[    0.057903] RDX: 0000000000000000 RSI: ffffffff833e9787 RDI: ffffffff82df9208
[    0.058401] RBP: ffffc9000000be70 R08: ffffc9000000bf48 R09: 0000000000000000
[    0.058902] R10: 0000000000000002 R11: 0000000000000100 R12: 0000000000000003
[    0.059401] R13: 0000000000000000 R14: ffffffff833e96c0 R15: 9feaf2bde0204734
[    0.059909] FS:  0000000000000000(0000) GS:ffffffff82a42000(0000) knlGS:0000000000000000
[    0.060000] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    0.060000] CR2: 0000000000000000 CR3: 0000000002a1c000 CR4: 00000000000006f0
[    0.060000] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[    0.060000] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[    0.060000] Call Trace:
[    0.060000]  do_one_initcall+0x110/0x30e
[    0.060000]  ? do_early_param+0x1d9/0x1d9
[    0.060000]  kernel_init_freeable+0x191/0x2ff
[    0.060000]  ? rest_init+0x10d/0x10d
[    0.060000]  kernel_init+0x14/0x1ca
[    0.060000]  ? rest_init+0x10d/0x10d
[    0.060000]  ret_from_fork+0x24/0x30
[    0.060000] Code: df 82 31 c9 31 d2 44 89 e6 49 83 c4 02 48 89 05 c0 8a f2 ff e8 16 e2 dc fd 4a ff 04 e5 c8 09 24 83 4d 85 ed 75 07 e8 14 71 d9 fd <0f> 0b 48 b8 66 15 13 7e 02 01 3f 70 48 01 c3 e8 00 71 d9 fd 48 
[    0.060000] RIP: sock_init+0xc7/0x1a9 RSP: ffffc9000000be58
[    0.060043] ---[ end trace 7952a3ce7af68811 ]---


To reproduce:

        git clone https://github.com/intel/lkp-tests.git
        cd lkp-tests
        bin/lkp qemu -k <bzImage> job-script  # job-script is attached in this email



Thanks,
lkp

Re: [PATCH 0/2] mark some slabs as visible not mergeable

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2018-02-25 16:36:48

On Sat, 24 Feb 2018 11:04:52 -0800
Stephen Hemminger [off-list ref] wrote:
This fixes an old bug in iproute2's ss command because it was
reading slabinfo to get statistics. There isn't a better API
to do this, and one can argue that /proc is a UAPI that must
not change.

Therefore this patch set adds a flag to slab to give another
reason to prevent merging, and then uses it in network code.

The patches are against davem's linux-net tree and should also
goto stable as well.

Stephen Hemminger (2):
  slab: add flag to block merging of UAPI elements
  net: mark slab's used by ss as UAPI

 include/linux/slab.h | 6 ++++++
 mm/slab_common.c     | 2 +-
 net/ipv4/tcp.c       | 3 ++-
 net/ipv4/tcp_ipv4.c  | 2 +-
 net/ipv6/tcp_ipv6.c  | 2 +-
 net/socket.c         | 6 +++---
 6 files changed, 14 insertions(+), 7 deletions(-)
The kbuild reports need more root cause investigation before applying.

--
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>

Re: [PATCH 0/2] mark some slabs as visible not mergeable

From: David Miller <hidden>
Date: 2018-02-26 20:15:04

From: Stephen Hemminger <stephen@networkplumber.org>
Date: Sat, 24 Feb 2018 11:04:52 -0800
This fixes an old bug in iproute2's ss command because it was
reading slabinfo to get statistics. There isn't a better API
to do this, and one can argue that /proc is a UAPI that must
not change.
Please elaborate what kind of statistics are needed.
Therefore this patch set adds a flag to slab to give another
reason to prevent merging, and then uses it in network code.

The patches are against davem's linux-net tree and should also
goto stable as well.
Well, as has been pointed out this never worked with SLUB so
in some sense this was always broken.

And the "UAPI" of slabinfo is to show the state of the various
slab caches.  And that's it.

If the implementation does merging or whatever, the UAPI is expressing
that and it's perfectly legitimate and not breaking UAPI in my
opinion.

I think the better solution is to grab the information from somewhere
else, so let's move this conversation along with the answer to my
question about asking for more details about what is needed by
iproute2.

Thank you.

--
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>

Re: [PATCH 0/2] mark some slabs as visible not mergeable

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2018-02-26 21:46:22

On Mon, 26 Feb 2018 15:15:02 -0500 (EST)
David Miller [off-list ref] wrote:
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Sat, 24 Feb 2018 11:04:52 -0800
quoted
This fixes an old bug in iproute2's ss command because it was
reading slabinfo to get statistics. There isn't a better API
to do this, and one can argue that /proc is a UAPI that must
not change.  
Please elaborate what kind of statistics are needed.
This is ancient original iproute2 code that dumpster dives into
slabinfo to get summary statistics on active objects.

	1) open sockets (sock_inode_cache)
	2) TCP ports bound (tcp_bind_buckets) [*]
	3) TCP time wait sockets (tw_sock_TCP) [*]
	4) TCP syn sockets (request_sock_TCP) [*]

From man page:

       -s, --summary
              Print summary statistics. This option does not parse socket lists  obtaining  summary  from
              various  sources. It is useful when amount of sockets is so huge that parsing /proc/net/tcp
              is painful.


The items with * are currently broken. See 0 for timewait, synrecv, and ports.

$ sudo ss -s

Total: 1089 (kernel 1093)
TCP:   33 (estab 4, closed 1, orphaned 0, synrecv 0, timewait 0/0), ports 0

Transport Total     IP        IPv6
*	  1093      -         -        
RAW	  0         0         0        
UDP	  21        13        8        
TCP	  32        24        8        
INET	  53        37        16       
FRAG	  0         0         0        
quoted
Therefore this patch set adds a flag to slab to give another
reason to prevent merging, and then uses it in network code.

The patches are against davem's linux-net tree and should also
goto stable as well.  
Well, as has been pointed out this never worked with SLUB so
in some sense this was always broken.

And the "UAPI" of slabinfo is to show the state of the various
slab caches.  And that's it.

If the implementation does merging or whatever, the UAPI is expressing
that and it's perfectly legitimate and not breaking UAPI in my
opinion.

I think the better solution is to grab the information from somewhere
else, so let's move this conversation along with the answer to my
question about asking for more details about what is needed by
iproute2.

Thank you.
There is no where else that gives summary information.

Both /proc/net/tcp and sock diag info require user space to
read all the data, which is what I think Alexey was trying to avoid.
Ideally there would be network namespace aware API to do this, but
the code (iproute2 and kernel) are currently broken. Some values
are missing (because they are merged) and some values have wrong
cache name (because of acme's changes to make this generic).


--
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>

Re: [PATCH 0/2] mark some slabs as visible not mergeable

From: David Miller <davem@davemloft.net>
Date: 2018-02-27 01:13:59

From: Stephen Hemminger <stephen@networkplumber.org>
Date: Mon, 26 Feb 2018 13:46:13 -0800
This is ancient original iproute2 code that dumpster dives into
slabinfo to get summary statistics on active objects.

	1) open sockets (sock_inode_cache)
The sockets inuse counter from /proc/net/sockstat is really
sufficient for this.
	2) TCP ports bound (tcp_bind_buckets) [*]
	3) TCP time wait sockets (tw_sock_TCP) [*]
Time wait is provided by /proc/net/sockstat as well.
	4) TCP syn sockets (request_sock_TCP) [*]
It shouldn't be too hard to fill in the last two gaps, maintaining a
counter for bind buckets and request socks, and exporting them in new
/proc/net/sockstat field.

That would be so much better than disabling a useful optimization
in the SLAB allocator.

Thank you.

--
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>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help