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)


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.

  23  */
  24 /* Copyright (c) 1990 Mentat Inc. */
  25 
  26 #ifndef _INET_TCP_H
  27 #define _INET_TCP_H
  28 
  29 #ifdef  __cplusplus
  30 extern "C" {
  31 #endif
  32 
  33 #include <sys/inttypes.h>
  34 #include <netinet/ip6.h>
  35 #include <netinet/tcp.h>
  36 #include <sys/socket.h>
  37 #include <sys/socket_proto.h>
  38 #include <sys/md5.h>
  39 #include <inet/common.h>
  40 #include <inet/ip.h>
  41 #include <inet/ip6.h>
  42 #include <inet/mi.h>


 479 #ifdef DEBUG
 480         pc_t                    tcmp_stk[15];
 481 #endif
 482 } tcp_t;
 483 
 484 #ifdef DEBUG
 485 #define TCP_DEBUG_GETPCSTACK(buffer, depth)     ((void) getpcstack(buffer, \
 486                                                     depth))
 487 #else
 488 #define TCP_DEBUG_GETPCSTACK(buffer, depth)
 489 #endif
 490 
 491 extern void     tcp_conn_reclaim(void *);
 492 extern void     tcp_free(tcp_t *tcp);
 493 extern void     tcp_ddi_g_init(void);
 494 extern void     tcp_ddi_g_destroy(void);
 495 extern void     *tcp_get_conn(void *arg, tcp_stack_t *);
 496 extern mblk_t   *tcp_snmp_get(queue_t *, mblk_t *, boolean_t);
 497 extern int      tcp_snmp_set(queue_t *, int, int, uchar_t *, int len);
 498 



 499 /*
 500  * The TCP Fanout structure for bind and acceptor hashes.
 501  * The hash tables and their linkage (tcp_*_hash, tcp_ptp*hn) are
 502  * protected by the per-bucket tf_lock.  Each tcp_t
 503  * inserted in the list points back at this lock using tcp_*_lockp.
 504  *
 505  * The bind and acceptor hash queues are lists of tcp_t.
 506  */
 507 /* listener hash and acceptor hash queue head */
 508 typedef struct tf_s {
 509         tcp_t           *tf_tcp;
 510         kmutex_t        tf_lock;


 511 } tf_t;
 512 
 513 
 514 /* Also used in ipclassifier.c */
 515 extern struct kmem_cache  *tcp_sack_info_cache;
 516 
 517 #endif  /* (defined(_KERNEL) || defined(_KMEMUSER)) */
 518 
 519 /* Contract private interface between TCP and Clustering. */
 520 
 521 #define CL_TCPI_V1      1       /* cl_tcpi_version number */
 522 
 523 typedef struct cl_tcp_info_s {
 524         ushort_t        cl_tcpi_version;        /* cl_tcp_info_t's version no */
 525         ushort_t        cl_tcpi_ipversion;      /* IP version */
 526         int32_t         cl_tcpi_state;          /* TCP state */
 527         in_port_t       cl_tcpi_lport;          /* Local port */
 528         in_port_t       cl_tcpi_fport;          /* Remote port */
 529         in6_addr_t      cl_tcpi_laddr_v6;       /* Local IP address */
 530         in6_addr_t      cl_tcpi_faddr_v6;       /* Remote IP address */




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2011, Joyent, Inc. All rights reserved.
  24  */
  25 /* Copyright (c) 1990 Mentat Inc. */
  26 
  27 #ifndef _INET_TCP_H
  28 #define _INET_TCP_H
  29 
  30 #ifdef  __cplusplus
  31 extern "C" {
  32 #endif
  33 
  34 #include <sys/inttypes.h>
  35 #include <netinet/ip6.h>
  36 #include <netinet/tcp.h>
  37 #include <sys/socket.h>
  38 #include <sys/socket_proto.h>
  39 #include <sys/md5.h>
  40 #include <inet/common.h>
  41 #include <inet/ip.h>
  42 #include <inet/ip6.h>
  43 #include <inet/mi.h>


 480 #ifdef DEBUG
 481         pc_t                    tcmp_stk[15];
 482 #endif
 483 } tcp_t;
 484 
 485 #ifdef DEBUG
 486 #define TCP_DEBUG_GETPCSTACK(buffer, depth)     ((void) getpcstack(buffer, \
 487                                                     depth))
 488 #else
 489 #define TCP_DEBUG_GETPCSTACK(buffer, depth)
 490 #endif
 491 
 492 extern void     tcp_conn_reclaim(void *);
 493 extern void     tcp_free(tcp_t *tcp);
 494 extern void     tcp_ddi_g_init(void);
 495 extern void     tcp_ddi_g_destroy(void);
 496 extern void     *tcp_get_conn(void *arg, tcp_stack_t *);
 497 extern mblk_t   *tcp_snmp_get(queue_t *, mblk_t *, boolean_t);
 498 extern int      tcp_snmp_set(queue_t *, int, int, uchar_t *, int len);
 499 
 500 /* Pad for the tf_t structure to avoid false cache line sharing. */
 501 #define TF_CACHEL_PAD   64
 502 
 503 /*
 504  * The TCP Fanout structure for bind and acceptor hashes.
 505  * The hash tables and their linkage (tcp_*_hash, tcp_ptp*hn) are
 506  * protected by the per-bucket tf_lock.  Each tcp_t
 507  * inserted in the list points back at this lock using tcp_*_lockp.
 508  *
 509  * The bind and acceptor hash queues are lists of tcp_t.
 510  */
 511 /* listener hash and acceptor hash queue head */
 512 typedef struct tf_s {
 513         tcp_t           *tf_tcp;
 514         kmutex_t        tf_lock;
 515         unsigned char   tf_pad[TF_CACHEL_PAD -
 516             (sizeof (tcp_t *) + sizeof (kmutex_t))];
 517 } tf_t;
 518 
 519 
 520 /* Also used in ipclassifier.c */
 521 extern struct kmem_cache  *tcp_sack_info_cache;
 522 
 523 #endif  /* (defined(_KERNEL) || defined(_KMEMUSER)) */
 524 
 525 /* Contract private interface between TCP and Clustering. */
 526 
 527 #define CL_TCPI_V1      1       /* cl_tcpi_version number */
 528 
 529 typedef struct cl_tcp_info_s {
 530         ushort_t        cl_tcpi_version;        /* cl_tcp_info_t's version no */
 531         ushort_t        cl_tcpi_ipversion;      /* IP version */
 532         int32_t         cl_tcpi_state;          /* TCP state */
 533         in_port_t       cl_tcpi_lport;          /* Local port */
 534         in_port_t       cl_tcpi_fport;          /* Remote port */
 535         in6_addr_t      cl_tcpi_laddr_v6;       /* Local IP address */
 536         in6_addr_t      cl_tcpi_faddr_v6;       /* Remote IP address */