diff options
author | jhb <jhb@FreeBSD.org> | 2008-10-01 19:14:05 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2008-10-01 19:14:05 +0000 |
commit | ee566dffaadbc88fa12b821e2f47296daf979809 (patch) | |
tree | d69e8aa29cdcfb7f3e3b8c2243cbf29076955e40 /sys | |
parent | ab1e647ba608ba6da227fbe2bb8767ea4fc86b26 (diff) | |
download | FreeBSD-src-ee566dffaadbc88fa12b821e2f47296daf979809.zip FreeBSD-src-ee566dffaadbc88fa12b821e2f47296daf979809.tar.gz |
Wait until after dropping the receive socket buffer lock to allocate space
to store the socket address stored in the first mbuf in a packet chain.
This reduces contention on the lock and CPU system time in certain UDP
workloads.
Tested by: ps
Reviewed by: rwatson
MFC after: 1 week
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/uipc_socket.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 5f2d7f7..7c69200 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1926,34 +1926,11 @@ soreceive_dgram(struct socket *so, struct sockaddr **psa, struct uio *uio, SBLASTRECORDCHK(&so->so_rcv); SBLASTMBUFCHK(&so->so_rcv); nextrecord = m->m_nextpkt; - if (pr->pr_flags & PR_ADDR) { - KASSERT(m->m_type == MT_SONAME, - ("m->m_type == %d", m->m_type)); - if (psa != NULL) - *psa = sodupsockaddr(mtod(m, struct sockaddr *), - M_NOWAIT); - sbfree(&so->so_rcv, m); - so->so_rcv.sb_mb = m_free(m); - m = so->so_rcv.sb_mb; - sockbuf_pushsync(&so->so_rcv, nextrecord); - } - if (m == NULL) { - /* XXXRW: Can this happen? */ - SOCKBUF_UNLOCK(&so->so_rcv); - return (0); - } - KASSERT(m->m_nextpkt == nextrecord, - ("soreceive_dgram: post-control, nextrecord !sync")); if (nextrecord == NULL) { - KASSERT(so->so_rcv.sb_mb == m, - ("soreceive_dgram: post-control, sb_mb!=m")); KASSERT(so->so_rcv.sb_lastrecord == m, ("soreceive_dgram: lastrecord != m")); } - SBLASTRECORDCHK(&so->so_rcv); - SBLASTMBUFCHK(&so->so_rcv); - KASSERT(m == so->so_rcv.sb_mb, ("soreceive_dgram: m not sb_mb")); KASSERT(so->so_rcv.sb_mb->m_nextpkt == nextrecord, ("soreceive_dgram: m_nextpkt != nextrecord")); @@ -1976,6 +1953,19 @@ soreceive_dgram(struct socket *so, struct sockaddr **psa, struct uio *uio, SBLASTMBUFCHK(&so->so_rcv); SOCKBUF_UNLOCK(&so->so_rcv); + if (pr->pr_flags & PR_ADDR) { + KASSERT(m->m_type == MT_SONAME, + ("m->m_type == %d", m->m_type)); + if (psa != NULL) + *psa = sodupsockaddr(mtod(m, struct sockaddr *), + M_NOWAIT); + m = m_free(m); + } + if (m == NULL) { + /* XXXRW: Can this happen? */ + return (0); + } + /* * Packet to copyout() is now in 'm' and it is disconnected from the * queue. |