changeset 13345:20c193a013b8

916 False-sharing in TCP hash buckets, plus size increase Reviewed by: Dan McDonald <danmcd@nexenta.com> Reviewed by: Richard Lowe <richlowe@richlowe.net> Approved by: Richard Lowe <richlowe@richlowe.net>
author Jerry Jelinek <jerry.jelinek@joyent.com>
date Thu, 21 Apr 2011 20:06:37 -0400
parents 7691b36f7461
children f3ce1af7c12d
files usr/src/uts/common/inet/tcp.h usr/src/uts/common/inet/tcp/tcp.c usr/src/uts/common/inet/tcp_impl.h
diffstat 3 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/inet/tcp.h	Thu Apr 21 20:06:36 2011 -0400
+++ b/usr/src/uts/common/inet/tcp.h	Thu Apr 21 20:06:37 2011 -0400
@@ -20,6 +20,7 @@
  */
 /*
  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, Joyent, Inc. All rights reserved.
  */
 /* Copyright (c) 1990 Mentat Inc. */
 
@@ -496,6 +497,9 @@
 extern mblk_t	*tcp_snmp_get(queue_t *, mblk_t *, boolean_t);
 extern int	tcp_snmp_set(queue_t *, int, int, uchar_t *, int len);
 
+/* Pad for the tf_t structure to avoid false cache line sharing. */
+#define	TF_CACHEL_PAD	64
+
 /*
  * The TCP Fanout structure for bind and acceptor hashes.
  * The hash tables and their linkage (tcp_*_hash, tcp_ptp*hn) are
@@ -508,6 +512,8 @@
 typedef struct tf_s {
 	tcp_t		*tf_tcp;
 	kmutex_t	tf_lock;
+	unsigned char	tf_pad[TF_CACHEL_PAD -
+	    (sizeof (tcp_t *) + sizeof (kmutex_t))];
 } tf_t;
 
 
--- a/usr/src/uts/common/inet/tcp/tcp.c	Thu Apr 21 20:06:36 2011 -0400
+++ b/usr/src/uts/common/inet/tcp/tcp.c	Thu Apr 21 20:06:37 2011 -0400
@@ -21,6 +21,7 @@
 
 /*
  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, Joyent Inc. All rights reserved.
  */
 /* Copyright (c) 1990 Mentat Inc. */
 
@@ -240,7 +241,7 @@
 /*
  * Size of acceptor hash list.  It has to be a power of 2 for hashing.
  */
-#define	TCP_ACCEPTOR_FANOUT_SIZE		256
+#define	TCP_ACCEPTOR_FANOUT_SIZE		512
 
 #ifdef	_ILP32
 #define	TCP_ACCEPTOR_HASH(accid)					\
--- a/usr/src/uts/common/inet/tcp_impl.h	Thu Apr 21 20:06:36 2011 -0400
+++ b/usr/src/uts/common/inet/tcp_impl.h	Thu Apr 21 20:06:37 2011 -0400
@@ -20,6 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, Joyent Inc. All rights reserved.
  */
 
 #ifndef	_INET_TCP_IMPL_H
@@ -55,7 +56,7 @@
  * Bind hash list size and has function.  It has to be a power of 2 for
  * hashing.
  */
-#define	TCP_BIND_FANOUT_SIZE	512
+#define	TCP_BIND_FANOUT_SIZE	1024
 #define	TCP_BIND_HASH(lport) (ntohs(lport) & (TCP_BIND_FANOUT_SIZE - 1))
 
 /*