Date: Tue, 23 Jul 2024 13:19:36 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: f5fabf3dcfb6 - stable/14 - socket: Simplify synchronization in soreceive_stream() Message-ID: <202407231319.46NDJaob004475@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f5fabf3dcfb67434d13890b9143a361478e731e2 commit f5fabf3dcfb67434d13890b9143a361478e731e2 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2024-07-09 14:33:53 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-07-23 13:01:53 +0000 socket: Simplify synchronization in soreceive_stream() Now that the socket recv I/O lock is required in order to enable receive-side KTLS, we can move a check from out of the socket buffer lock, which in turn will simplify some further refactoring. Add a __predict_false annotation while here since we already perform a lockless check before acquiring any locks. Reviewed by: gallatin, jhb MFC after: 2 weeks Sponsored by: Klara, Inc. Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D45922 (cherry picked from commit 30f30ccae71ce6b3bbe7b2719a3d588cb46f97ba) --- sys/kern/uipc_socket.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 32a6ff14bb43..479184a87a5e 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -2560,17 +2560,15 @@ soreceive_stream(struct socket *so, struct sockaddr **psa, struct uio *uio, error = SOCK_IO_RECV_LOCK(so, SBLOCKWAIT(flags)); if (error) return (error); - SOCKBUF_LOCK(sb); - #ifdef KERN_TLS - if (sb->sb_tls_info != NULL) { - SOCKBUF_UNLOCK(sb); + if (__predict_false(sb->sb_tls_info != NULL)) { SOCK_IO_RECV_UNLOCK(so); return (soreceive_generic(so, psa, uio, mp0, controlp, flagsp)); } #endif + SOCKBUF_LOCK(sb); /* Easy one, no space to copyout anything. */ if (uio->uio_resid == 0) { error = EINVAL;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202407231319.46NDJaob004475>