From nobody Mon Aug 19 14:56:19 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 4WnbJg64D2z5T9QC; Mon, 19 Aug 2024 14:56:19 +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 4WnbJg5c5jz41GS; Mon, 19 Aug 2024 14:56:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724079379; 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=7EnH0VH+ml+SX/YIw18EIispSbzJ68WGU/wdNb4D+MI=; b=GTjSsDRpNfyK0YLP/0/X8VJnwW19X+ZVx/5w8sjrj59jIkxt85L2eYUM/kIOIpoob46FIo n3MIyzzQQXTlgui9EfB7y/8K3BWR1n+P0XD2a13nPw9rHxQG3tdHrDi3nvQM4AebkXkyjv UzbjntGC/gKWB2s5DDg1e4/QtmyiUgQlvsslnSuJ5HCWPrP7Map/If0OZskREok6wZ/yer P48BbHs2DJJyJGPJaDGCrcdtWTcWXlJ9IqXa/dvXYZr272OMi5jIu9/ca6zqiZrqNe5Ebi jmizzMRLBSYFjk/D1fjHU5/SvZLU6BILKcoc4P/Lv0p5mOxHwePV4VdhElnLPw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724079379; a=rsa-sha256; cv=none; b=VVav2LxHj2oxcPD4oFCWPVfcjXvMQsUwwLkxuT0V843pbrXEbJWsHB6+VCxF3P/uBZ1Yop RrtjyUsyoO0lVrYkDOJa4V2h4IpsL48D0ZNRPxcNTqCmYiRs3Pj2/4Un5ABUkoMHPvw6tV I+gSCKTSb6zJcFp/otRr8p1xzs7FL448lPFD4bHlUViFvOPzVHp9hrKgMnwEkuSQIVnnOQ 3Q9UC5SpnwwUYM1r2tSEaQrGTOTE8WkIuDVQlAWXW9nEgyGdvIzOKltGTPy/aQsu9y1tbX EwTukN3BUyosglMvKUQO+6p/7qFrv9L0D8jDBpieFk+A5BG8O+f+dKtkCb0kqQ== 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=1724079379; 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=7EnH0VH+ml+SX/YIw18EIispSbzJ68WGU/wdNb4D+MI=; b=njf8QDB3WxprufRysCULIUcOiLdTlBQf8LBuAah3vGLwSR3T1WstBd+mPfMr714kEH4LMY rLWKIyVg+hWUeyshsLd48n+jQh/heYOvvbNkE2Dvr3ONl/fvEQCH0sYIVRRUoQg4tILeEY MOq4v7ESWu8WuKfwi7M5sWNfpP3KR6ZCHpxNb0w1tiCKEh/3sOD7o8FpZoFNvgUuh0OZqy hKZ+FBQIolkWyNX5NzVv0jSABS/6vznFNdPNZ0gY1tz6XU2fj9cpvBaa8WUdC7ZWR6Gy3N dKAPTEiedIqmML+4X/svaaANSizi1xncXcSGwx5WnmatTBsVZSreKtZ64hmdMg== 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 4WnbJg5CbXzLT4; Mon, 19 Aug 2024 14:56:19 +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 47JEuJSn027547; Mon, 19 Aug 2024 14:56:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47JEuJXg027544; Mon, 19 Aug 2024 14:56:19 GMT (envelope-from git) Date: Mon, 19 Aug 2024 14:56:19 GMT Message-Id: <202408191456.47JEuJXg027544@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: 6982be38cb7e - main - 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/main X-Git-Reftype: branch X-Git-Commit: 6982be38cb7e4254ff4ffbb334cd7e234b5f6cc2 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=6982be38cb7e4254ff4ffbb334cd7e234b5f6cc2 commit 6982be38cb7e4254ff4ffbb334cd7e234b5f6cc2 Author: Mark Johnston AuthorDate: 2024-07-05 18:01:29 +0000 Commit: Mark Johnston CommitDate: 2024-08-19 14:52:39 +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 --- 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 a5e88fc7ffc6..13b6253bd115 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -2604,14 +2604,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;