Print this page
916 False-sharing in TCP hash buckets, plus size increase
        (originally Joyent OS-299 tcp_bindi() hash lock contention affects
        TCP client performance)

@@ -18,10 +18,11 @@
  *
  * CDDL HEADER END
  */
 /*
  * 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. */
 
 #ifndef _INET_TCP_H
 #define _INET_TCP_H

@@ -494,10 +495,13 @@
 extern void     tcp_ddi_g_destroy(void);
 extern void     *tcp_get_conn(void *arg, tcp_stack_t *);
 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
  * protected by the per-bucket tf_lock.  Each tcp_t
  * inserted in the list points back at this lock using tcp_*_lockp.

@@ -506,10 +510,12 @@
  */
 /* listener hash and acceptor hash queue head */
 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;
 
 
 /* Also used in ipclassifier.c */
 extern struct kmem_cache  *tcp_sack_info_cache;