Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Dec 2020 18:15:07 +0000 (UTC)
From:      Aleksandr Fedorov <afedorov@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r368727 - head/sys/netgraph
Message-ID:  <202012171815.0BHIF7x1017245@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: afedorov
Date: Thu Dec 17 18:15:07 2020
New Revision: 368727
URL: https://svnweb.freebsd.org/changeset/base/368727

Log:
  [ng_socket] Don't take the SOCKBUF_LOCK() twice in the RX data path.
  
  This is just a minor optimization, but it's sensitive. This gives an improvement of 30-50 kpps.
  
  Reviewed by:	kp, markj, glebius, lutz_donnerhacke.de
  Approved by:	vmaffione (mentor)
  Sponsored by:	vstack.com
  Differential Revision:	https://reviews.freebsd.org/D27382

Modified:
  head/sys/netgraph/ng_socket.c

Modified: head/sys/netgraph/ng_socket.c
==============================================================================
--- head/sys/netgraph/ng_socket.c	Thu Dec 17 17:21:12 2020	(r368726)
+++ head/sys/netgraph/ng_socket.c	Thu Dec 17 18:15:07 2020	(r368727)
@@ -987,6 +987,8 @@ ngs_rcvmsg(node_p node, item_p item, hook_p lasthook)
 		m_freem(m);
 		return (ENOBUFS);
 	}
+
+	/* sorwakeup_locked () releases the lock internally. */
 	sorwakeup_locked(so);
 
 	return (error);
@@ -1025,12 +1027,17 @@ ngs_rcvdata(hook_p hook, item_p item)
 	addr->sg_data[addrlen] = '\0';
 
 	/* Try to tell the socket which hook it came in on. */
-	if (sbappendaddr(&so->so_rcv, (struct sockaddr *)addr, m, NULL) == 0) {
+	SOCKBUF_LOCK(&so->so_rcv);
+	if (sbappendaddr_locked(&so->so_rcv, (struct sockaddr *)addr, m,
+	    NULL) == 0) {
+		SOCKBUF_UNLOCK(&so->so_rcv);
 		m_freem(m);
 		TRAP_ERROR;
 		return (ENOBUFS);
 	}
-	sorwakeup(so);
+
+	/* sorwakeup_locked () releases the lock internally. */
+	sorwakeup_locked(so);
 	return (0);
 }
 



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