From nobody Tue Sep 03 14:55:07 2024 X-Original-To: dev-commits-src-all@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 4WypZM6Q7sz5TN79; Tue, 03 Sep 2024 14:55:07 +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 4WypZM4NtZz4xJ0; Tue, 3 Sep 2024 14:55:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725375307; 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=+egRtzmR1lmCeDhCU0nY8JPJ0CboUOsInAiZAkJcj/c=; b=m2PJqzBGY/YZcGX1veyWL4A/cPaHHj+LYNVXVUUj7md27kKcCuqcyEV4HE9R7hPmWEMRXo DxNgZo3z+V1nbsJe5a6Pxd72P6hcN1vE1eFUazRqAL8zdHYBIhXrAvy9Sa6Exh1vKAnODR 3j8Ed7rPV3WZeGnTlV+kavZcqqu3YKcp9k90tgptEAIptqGi2Ldz9VEE312hc2Rk1mFZt6 m/R7pyn38UZDPA/SYS6Of+JoV+qOymhke6RSWszcAv2/ZW2kDW4FEkLdFGnMUVl5NFmLHQ F/R+dLt4iOAskyhMXtGTrBiozFapltgMCE0vY5AFqInFEshRJvfk3gdEDzqj2w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725375307; a=rsa-sha256; cv=none; b=n+dPTXqBQcs7gaS3Xl4Ncv839zWosd30SIkKrDdvEucdrGG8jHAbbIU08UEiFB3j8Q/kj2 cYHTiY0Q/qCJYDJdeggHM4p5jGTfoYY5eppMh/dLJXX4J+ivFMEo780A2STe9pgqw/itvn jWdv/1fw8EQrufwI5hpnjCSaBouZK4xgei76IBpv5E0oIQ+0SNt6WoIt8/zB4xvmam6+1f tsdOcpvOlskyHgEC0nw/ja8iAuvMaXl8Ux2w7F2t0v2oYKWBaLH4EoojlDoDfKyFIpydPO 3DHqaueFipNdIf7nJpBpr9fXJjptpubUag51Pdy0+2sRedlOt8BPUOscWm/9wQ== 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=1725375307; 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=+egRtzmR1lmCeDhCU0nY8JPJ0CboUOsInAiZAkJcj/c=; b=ggcwh7vQ5IiEPeC3NJgXcU5P2TLLrapXOBte6un2TGkZYAy80Q6GVeUC13dGUG195XEq8h D2O0sWcJlehOnGra0Joc/wDaSm2ZiZU5rGYQ7qnE7RqmGpBOcdfQTDT8/OvtuQs0o2brWF AOcCN6IseLbFtb1hbMX0FetlSP518jAdbCqOQht5pERmGf6zy/Lfl4DrNA7XCp1Ogs/4wt toMcsEE0xnSsa1193qeI9z9a/y5TiyhKe4QgBqUTZLkbUa2yvsNGB5oLHOmHZxOmolPMBk DlT4YBwS0qI4tbLfpUj5vspdJyM1wrFa2xfUeeTk+JlUx5HFjTJR+6u3FitEdQ== 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 4WypZM40sczlWS; Tue, 3 Sep 2024 14:55:07 +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 483Et7ps070857; Tue, 3 Sep 2024 14:55:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 483Et7wN070854; Tue, 3 Sep 2024 14:55:07 GMT (envelope-from git) Date: Tue, 3 Sep 2024 14:55:07 GMT Message-Id: <202409031455.483Et7wN070854@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 441fc34c6f01 - stable/14 - socket: Microoptimize soreceive_stream_locked() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 441fc34c6f01ffe72278f3ba696a3ec06924743d Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=441fc34c6f01ffe72278f3ba696a3ec06924743d commit 441fc34c6f01ffe72278f3ba696a3ec06924743d Author: Mark Johnston AuthorDate: 2024-07-05 18:01:29 +0000 Commit: Mark Johnston CommitDate: 2024-09-03 14:54:43 +0000 socket: Microoptimize soreceive_stream_locked() There is no need to hold the sockbuf lock while checking uio_resid. No functional change intended. MFC after: 2 weeks Sponsored by: Klara, Inc. Sponsored by: Stormshield (cherry picked from commit 6982be38cb7e4254ff4ffbb334cd7e234b5f6cc2) --- sys/kern/uipc_socket.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index dfe75978ac39..adb11e08a7ac 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -2555,14 +2555,12 @@ soreceive_stream_locked(struct socket *so, struct sockbuf *sb, SOCK_IO_RECV_ASSERT_LOCKED(so); - SOCKBUF_LOCK(sb); /* Easy one, no space to copyout anything. */ - if (uio->uio_resid == 0) { - error = EINVAL; - goto out; - } + if (uio->uio_resid == 0) + return (EINVAL); oresid = uio->uio_resid; + SOCKBUF_LOCK(sb); /* We will never ever get anything unless we are or were connected. */ if (!(so->so_state & (SS_ISCONNECTED|SS_ISDISCONNECTED))) { error = ENOTCONN;