From nobody Tue Jul 23 13:19:36 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 4WSyRX3bXzz5Rx7K; Tue, 23 Jul 2024 13:19:36 +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 4WSyRX2hnXz4HfV; Tue, 23 Jul 2024 13:19:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721740776; 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=C7/j+s2uQzJ/rhMYfFJ6Th2hX2/wMH6IqcZ2QrcL3ss=; b=efXoFm86G/OlGKM3hRDHClRCjinQ6XOPFCMVoxlFPMIaV7dpYx2+DPczvoZCWzbXw53ub2 pAmGiMiHRyHqUWKNEUtN2TvjMGV2qWORWvyJhW9PWzKliWlhhg/gtCEFpehZe17E12DPlp 8ncSlDHas+Rzs4gc19qpWt5jg8iYYTX58YN7+IPKsCfjtO0FVtKlQJHIMpyS/XZTZayLUm sFFflGnVYsnJD0PFYxlr0eWmUc4Wby+y3gZbGaVpJntJ4KYUJTiyTfMpldo1DJXnomHbCB SxW0eZif6pV31WHdVDu+huXqFYEM0x0JmAjbk+8MHcNGbfXd5J7j6g4lqMud0g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721740776; a=rsa-sha256; cv=none; b=nR6P60m/08d/JxnBeyOiVTREwttUUq6itTIcQBVWD4k3DOIgqIihRFwQ3n8W0IDYlWfdsX vKh2FjLBVUXCknZ2TBbDTN8O0Hq2ujA8URg4/z/uneXKQ7BUJqbVC24M4ceT6SQTSe/V7u 94Yf4kZsEQiXKs5JKurkCO9gkLBVx+h0qirlc37jH3dwaaCuhSj11bgPT49k09FhBRpjPS oT87sivKU6MqA5pJFwp4dAHyDdUcamfFnT33OGvZoSvX9hWjcVl3SzOPuoEzf2jwX9v9mJ tIpWvFgAjKbs0gJEZ5w7DGgiDFeHP02TbIrD7RQ94yXzZllyRpxszl8IgIfOSw== 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=1721740776; 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=C7/j+s2uQzJ/rhMYfFJ6Th2hX2/wMH6IqcZ2QrcL3ss=; b=Pu64Bb+kLmmDrishkJQSyIGZJU5cDJU15Eod6xrujhbm9E26udCEh3NeCcXy4YrJn0dQ6l 8342h63gcRKH/9J684IeUVXtUQssqErqjWWz+5rC9gefFzZZIhTrX5oZdsi1CCbhUBbwEb 7lpjyOiHUcq7pGZCRp1GK3LNvhacg+z5fntZEe0wSAvh867ZI+Jc/0oojJZNU7TjWYlKiI Nyz7g8xK27AadyFfe27DZ5C69SDMMZk85dmMy4NIFVO/rtAcaUeXAAjt/InIvIow34dkan pPXwcAW3WjKVJ8PUWwoLK8DCUnJ8Nxa6Qq1oMjnkFfNUi5gFQCGJrAyp0KFcFw== 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 4WSyRX20SJzW3Z; Tue, 23 Jul 2024 13:19:36 +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 46NDJag6004478; Tue, 23 Jul 2024 13:19:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46NDJaob004475; Tue, 23 Jul 2024 13:19:36 GMT (envelope-from git) Date: Tue, 23 Jul 2024 13:19:36 GMT Message-Id: <202407231319.46NDJaob004475@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: f5fabf3dcfb6 - stable/14 - socket: Simplify synchronization in soreceive_stream() 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: f5fabf3dcfb67434d13890b9143a361478e731e2 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f5fabf3dcfb67434d13890b9143a361478e731e2 commit f5fabf3dcfb67434d13890b9143a361478e731e2 Author: Mark Johnston AuthorDate: 2024-07-09 14:33:53 +0000 Commit: Mark Johnston 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;