svn commit: r261242 - head/sys/netinet

George V. Neville-Neil gnn at FreeBSD.org
Tue Jan 28 20:28:33 UTC 2014


Author: gnn
Date: Tue Jan 28 20:28:32 2014
New Revision: 261242
URL: http://svnweb.freebsd.org/changeset/base/261242

Log:
  Decrease lock contention within the TCP accept case by removing
  the INP_INFO lock from tcp_usr_accept.  As the PR/patch states
  this was following the advice already in the code.
  See the PR below for a full disucssion of this change and its
  measured effects.
  
  PR:		183659
  Submitted by:	Julian Charbon
  Reviewed by:	jhb

Modified:
  head/sys/netinet/tcp_syncache.c
  head/sys/netinet/tcp_usrreq.c

Modified: head/sys/netinet/tcp_syncache.c
==============================================================================
--- head/sys/netinet/tcp_syncache.c	Tue Jan 28 19:12:31 2014	(r261241)
+++ head/sys/netinet/tcp_syncache.c	Tue Jan 28 20:28:32 2014	(r261242)
@@ -682,7 +682,7 @@ syncache_socket(struct syncache *sc, str
 	 * connection when the SYN arrived.  If we can't create
 	 * the connection, abort it.
 	 */
-	so = sonewconn(lso, SS_ISCONNECTED);
+	so = sonewconn(lso, 0);
 	if (so == NULL) {
 		/*
 		 * Drop the connection; we will either send a RST or
@@ -922,6 +922,8 @@ syncache_socket(struct syncache *sc, str
 
 	INP_WUNLOCK(inp);
 
+	soisconnected(so);
+
 	TCPSTAT_INC(tcps_accepts);
 	return (so);
 

Modified: head/sys/netinet/tcp_usrreq.c
==============================================================================
--- head/sys/netinet/tcp_usrreq.c	Tue Jan 28 19:12:31 2014	(r261241)
+++ head/sys/netinet/tcp_usrreq.c	Tue Jan 28 20:28:32 2014	(r261242)
@@ -610,13 +610,6 @@ out:
 /*
  * Accept a connection.  Essentially all the work is done at higher levels;
  * just return the address of the peer, storing through addr.
- *
- * The rationale for acquiring the tcbinfo lock here is somewhat complicated,
- * and is described in detail in the commit log entry for r175612.  Acquiring
- * it delays an accept(2) racing with sonewconn(), which inserts the socket
- * before the inpcb address/port fields are initialized.  A better fix would
- * prevent the socket from being placed in the listen queue until all fields
- * are fully initialized.
  */
 static int
 tcp_usr_accept(struct socket *so, struct sockaddr **nam)
@@ -633,7 +626,6 @@ tcp_usr_accept(struct socket *so, struct
 
 	inp = sotoinpcb(so);
 	KASSERT(inp != NULL, ("tcp_usr_accept: inp == NULL"));
-	INP_INFO_RLOCK(&V_tcbinfo);
 	INP_WLOCK(inp);
 	if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {
 		error = ECONNABORTED;
@@ -653,7 +645,6 @@ tcp_usr_accept(struct socket *so, struct
 out:
 	TCPDEBUG2(PRU_ACCEPT);
 	INP_WUNLOCK(inp);
-	INP_INFO_RUNLOCK(&V_tcbinfo);
 	if (error == 0)
 		*nam = in_sockaddr(port, &addr);
 	return error;


More information about the svn-src-head mailing list