Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Apr 2013 21:02:21 +0000 (UTC)
From:      Andre Oppermann <andre@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r249318 - in head/sys: kern net netinet
Message-ID:  <201304092102.r39L2LrO047044@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andre
Date: Tue Apr  9 21:02:20 2013
New Revision: 249318
URL: http://svnweb.freebsd.org/changeset/base/249318

Log:
  Change certain heavily used network related mutexes and rwlocks to
  reside on their own cache line to prevent false sharing with other
  nearby structures, especially for those in the .bss segment.
  
  NB: Those mutexes and rwlocks with variables next to them that get
  changed on every invocation do not benefit from their own cache line.
  Actually it may be net negative because two cache misses would be
  incurred in those cases.

Modified:
  head/sys/kern/uipc_socket.c
  head/sys/net/if.c
  head/sys/net/if_llatbl.c
  head/sys/net/if_var.h
  head/sys/netinet/in_pcb.h
  head/sys/netinet/ip_id.c
  head/sys/netinet/ip_input.c
  head/sys/netinet/tcp_subr.c

Modified: head/sys/kern/uipc_socket.c
==============================================================================
--- head/sys/kern/uipc_socket.c	Tue Apr  9 20:52:26 2013	(r249317)
+++ head/sys/kern/uipc_socket.c	Tue Apr  9 21:02:20 2013	(r249318)
@@ -240,14 +240,14 @@ SYSCTL_INT(_kern_ipc_zero_copy, OID_AUTO
  * accept_mtx locks down per-socket fields relating to accept queues.  See
  * socketvar.h for an annotation of the protected fields of struct socket.
  */
-struct mtx accept_mtx;
+struct mtx_padalign accept_mtx;
 MTX_SYSINIT(accept_mtx, &accept_mtx, "accept", MTX_DEF);
 
 /*
  * so_global_mtx protects so_gencnt, numopensockets, and the per-socket
  * so_gencnt field.
  */
-static struct mtx so_global_mtx;
+static struct so_global_mtx so_global_mtx;
 MTX_SYSINIT(so_global_mtx, &so_global_mtx, "so_glabel", MTX_DEF);
 
 /*

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c	Tue Apr  9 20:52:26 2013	(r249317)
+++ head/sys/net/if.c	Tue Apr  9 21:02:20 2013	(r249318)
@@ -206,7 +206,7 @@ VNET_DEFINE(struct ifindex_entry *, ifin
  * also to stablize it over long-running ioctls, without introducing priority
  * inversions and deadlocks.
  */
-struct rwlock ifnet_rwlock;
+struct rwlock_padalign ifnet_rwlock;
 struct sx ifnet_sxlock;
 
 /*

Modified: head/sys/net/if_llatbl.c
==============================================================================
--- head/sys/net/if_llatbl.c	Tue Apr  9 20:52:26 2013	(r249317)
+++ head/sys/net/if_llatbl.c	Tue Apr  9 21:02:20 2013	(r249318)
@@ -67,7 +67,7 @@ static VNET_DEFINE(SLIST_HEAD(, lltable)
 
 static void vnet_lltable_init(void);
 
-struct rwlock lltable_rwlock;
+struct rwlock_padalign lltable_rwlock;
 RW_SYSINIT(lltable_rwlock, &lltable_rwlock, "lltable_rwlock");
 
 /*

Modified: head/sys/net/if_var.h
==============================================================================
--- head/sys/net/if_var.h	Tue Apr  9 20:52:26 2013	(r249317)
+++ head/sys/net/if_var.h	Tue Apr  9 21:02:20 2013	(r249318)
@@ -191,9 +191,9 @@ struct ifnet {
 	void	*if_unused[2];
 	void	*if_afdata[AF_MAX];
 	int	if_afdata_initialized;
-	struct	rwlock if_afdata_lock;
 	struct	task if_linktask;	/* task for link change events */
-	struct	rwlock if_addr_lock;	/* lock to protect address lists */
+	struct	rwlock_padalign if_afdata_lock;
+	struct	rwlock_padalign if_addr_lock;	/* lock to protect address lists */
 
 	LIST_ENTRY(ifnet) if_clones;	/* interfaces of a cloner */
 	TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per if */

Modified: head/sys/netinet/in_pcb.h
==============================================================================
--- head/sys/netinet/in_pcb.h	Tue Apr  9 20:52:26 2013	(r249317)
+++ head/sys/netinet/in_pcb.h	Tue Apr  9 21:02:20 2013	(r249318)
@@ -330,7 +330,7 @@ struct inpcbinfo {
 	/*
 	 * Global lock protecting non-pcbgroup hash lookup tables.
 	 */
-	struct rwlock		 ipi_hash_lock;
+	struct rwlock_padalign	 ipi_hash_lock;
 
 	/*
 	 * Global hash of inpcbs, hashed by local and foreign addresses and

Modified: head/sys/netinet/ip_id.c
==============================================================================
--- head/sys/netinet/ip_id.c	Tue Apr  9 20:52:26 2013	(r249317)
+++ head/sys/netinet/ip_id.c	Tue Apr  9 21:02:20 2013	(r249318)
@@ -97,7 +97,7 @@ static int		 array_ptr = 0;
 static int		 array_size = 8192;
 static int		 random_id_collisions = 0;
 static int		 random_id_total = 0;
-static struct mtx	 ip_id_mtx;
+static struct mtx_padalign  ip_id_mtx;
 
 static void	ip_initid(void);
 static int	sysctl_ip_id_change(SYSCTL_HANDLER_ARGS);

Modified: head/sys/netinet/ip_input.c
==============================================================================
--- head/sys/netinet/ip_input.c	Tue Apr  9 20:52:26 2013	(r249317)
+++ head/sys/netinet/ip_input.c	Tue Apr  9 21:02:20 2013	(r249318)
@@ -85,7 +85,7 @@ __FBSDID("$FreeBSD$");
 CTASSERT(sizeof(struct ip) == 20);
 #endif
 
-struct	rwlock in_ifaddr_lock;
+struct rwlock_padalign	in_ifaddr_lock;
 RW_SYSINIT(in_ifaddr_lock, &in_ifaddr_lock, "in_ifaddr_lock");
 
 VNET_DEFINE(int, rsvp_on);
@@ -155,7 +155,7 @@ VNET_DEFINE(u_long, in_ifaddrhmask);		/*
 
 static VNET_DEFINE(uma_zone_t, ipq_zone);
 static VNET_DEFINE(TAILQ_HEAD(ipqhead, ipq), ipq[IPREASS_NHASH]);
-static struct mtx ipqlock;
+static struct mtx_padalign	ipqlock;
 
 #define	V_ipq_zone		VNET(ipq_zone)
 #define	V_ipq			VNET(ipq)

Modified: head/sys/netinet/tcp_subr.c
==============================================================================
--- head/sys/netinet/tcp_subr.c	Tue Apr  9 20:52:26 2013	(r249317)
+++ head/sys/netinet/tcp_subr.c	Tue Apr  9 21:02:20 2013	(r249318)
@@ -255,7 +255,7 @@ static VNET_DEFINE(uma_zone_t, tcpcb_zon
 #define	V_tcpcb_zone			VNET(tcpcb_zone)
 
 MALLOC_DEFINE(M_TCPLOG, "tcplog", "TCP address and flags print buffers");
-static struct mtx isn_mtx;
+static struct mtx_padalign	isn_mtx;
 
 #define	ISN_LOCK_INIT()	mtx_init(&isn_mtx, "isn_mtx", NULL, MTX_DEF)
 #define	ISN_LOCK()	mtx_lock(&isn_mtx)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304092102.r39L2LrO047044>