From nobody Tue Jul 09 14:34:50 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WJNmp5dXXz5QVkM; Tue, 09 Jul 2024 14:34:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WJNmp59XZz4PW7; Tue, 9 Jul 2024 14:34:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720535690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Q0pHLloxtyUXTPnxB+3XyjUrOGfR9awe7L6JvQrs8bg=; b=rHkKwJR6W8hXPurErKtkEZdlAY5afakvtfVFlErfFBAObRcQn+j8yChghV9AQCQl2Msu83 qh3HxGzPMprXMYxFSpUoNXcFT+s7CPM5k7Nmdgjg6pt3u/HKpQsR7wyN7glqcVhO50CVv3 lh1mTBhfiOWo/7EM/BCNAXqWLRaguQHpO0rIQzXxA3E4VE2ulhQIzahT/ga2bKjizu+fVk WiFDjzmXwkIlaPlqTgvBu7ELTgKmNH6ngKFot2KGa1p1OlYDJT0vVCC4XlLMeJLPQevIQ7 LfBRl2euvZZfcL2a1NNGt/L8dtvgbieZQO9BzSGucpA/OQSbB4M5HRVEwXAOGw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1720535690; a=rsa-sha256; cv=none; b=nGBGfY8R0dT7dJaODWL8wzF7Vz3wD24Pa0VPRHuHVKgYoB7uWqC3BxkIqJ59G9TfMrgdDN CyxJza5+4vd7nzl6W5DW5QOd6SA3F01eOW1vHX/JY19Zr0291/GmeSXJujgp59/pQ9dOtE BLCESIbYbNMHvQCACMqXKBd+shLhaQh5Z7DS2T5zZqZd024wZJ2HRfotjYxHilFtpK9waL uq+0PGEW+Dpuhi3G+2Di3Xuhgb8ixX/aMuUCsltJpLUX+lrlO6yyZ0z8Q2qx6Yd64X9XGZ cNRHLRFJvC508FkFKSO2qvzANIlEJJ57aUiTrvG9T3aXH617XtIWxNIqz764Xg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720535690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Q0pHLloxtyUXTPnxB+3XyjUrOGfR9awe7L6JvQrs8bg=; b=vct0ULOWDyg/1fTM/kyyicFaxTdrIycHcAWvtCJ9rpIzfFuE+WtGbpIZj+9Bb7JWrIHyP8 zMtipuoUyLfwrnBoGkB665GhsX7lT7qwkMwQ97OkA3oRVdv74WYyqCo2vI2CwBAeGrs8fp RhDYC+sPD3cuYeNV90HgbCl+WTeu7IraVbCWtTZVbGyK4y1aqzmheHj5hJSiwvRBaARuS0 xbSSTHDJ9M7YSVaH1zK0APlAKYqiuEuurjaSUpGPCZ7eewal8IX9wove688nvuEl8uTsoZ YBaHhIBce1mqPBcGAwWssj3WkWNid8ieixQ8m9FPkbsz6/9Sj417anRsEE95Eg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WJNmp4lvkzdcj; Tue, 9 Jul 2024 14:34:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 469EYojS063884; Tue, 9 Jul 2024 14:34:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 469EYo3u063881; Tue, 9 Jul 2024 14:34:50 GMT (envelope-from git) Date: Tue, 9 Jul 2024 14:34:50 GMT Message-Id: <202407091434.469EYo3u063881@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 30f30ccae71c - main - socket: Simplify synchronization in soreceive_stream() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 30f30ccae71ce6b3bbe7b2719a3d588cb46f97ba Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=30f30ccae71ce6b3bbe7b2719a3d588cb46f97ba commit 30f30ccae71ce6b3bbe7b2719a3d588cb46f97ba Author: Mark Johnston AuthorDate: 2024-07-09 14:33:53 +0000 Commit: Mark Johnston CommitDate: 2024-07-09 14:33: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 --- 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 f0d22b3887a4..0350a5eb4d87 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -2609,17 +2609,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;