From nobody Fri May 23 22:52:50 2025 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 4b40mf6FF1z5whLx; Fri, 23 May 2025 22:52: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 4b40mf5LNjz3ssw; Fri, 23 May 2025 22:52:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1748040770; 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=IA8e1PcoElAy27jc+TTul5I7zSDeCFJniDdJ6sAFHqw=; b=YcH8fsDc51bF3pEGATUNGj1bZNDyA2Hf5by/9WKkxzYv3bUr3LjGN6whk2x/ri8S9Z9csk Ydc3GkQUCMIJrpIfo3GVxvse3S3IrQ+IWnsS/mQoRCUHlyYdU46Dg9nabbTHDbyONdJe7A NXMawY7z097iovLnCQuRtcYtg019qE/of0eKjhkXU+ZVvOYHEIU7rmXxdyqY0+05xaHJBD 9cfL5ZXrrctjoC+2vS8suadqSClamDu1ButVFnEnxFZ9CTSYlJ+1dkZlHEMLOR9OXCLVh1 bWfdPVZzb/Q5mQmUPf5rwflXRoV2qmxvHB8Hj+ohG6FZsPqesTrnFGLL/B6KKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1748040770; 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=IA8e1PcoElAy27jc+TTul5I7zSDeCFJniDdJ6sAFHqw=; b=sx4q9uox4o2GjLGznOSwcFhFjL2+WNLPQaV6tcon+xaL+HmSlxRLcVSsX/pbTqmrhoOJ+0 4MeuOApsMlyxMCtSOl6fIX+cLVN4Cunj+2UKjc+I4x2yNhnKrehjhkP10jUG2Lb60RPkAC SSmq/wVKccCVYcZ3wnrFWocpQPqD/5N/pdbVDyw8dFVBjtjpJPJ2w7JEaDrAYeI0ripHyz HS6umxU8BpSPOAMLlJEaAegEWrgBDiwE1cX4/kQC2gV39NhR4gfBeEIScqy5FaYK7uYnCn K9SYgEadxANH/IaPFjXt785gJG8efVBdHBFLDO8zC25wS/9d2hjTUYRsByVjKw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1748040770; a=rsa-sha256; cv=none; b=ci3I8KwSjciTeoGxYZ1PC/eoaG+GTEJW40DFBf73Nwb0yNuwhOZtP7o92lPt7yyrjRNFVu tXx6XmW9XChi+rrhNnUkfr7WsTApmefPjDv+cPk3fBV8nxlEkY3yVz0NJIUdoHWtb5Gsvs Rfo3ncy46vvDrcnSG4xEA3krYYyVs/j+mLL9ptGbm/5T0C4wyIgHLw7/TH5Xsj446aeY4j vKw9AHUyRb3EXblgEKQkQ0Sc0x3xHbnWjolKWlY14osgHmda1pCyJH/PN0q7prbDQBt3uU Reggk2bdLltVIPmytUsES+ZMREhKlkWDFtfouwd9QkaeYIu7fgnaTKdABpkunA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4b40mf4rpmz1NxC; Fri, 23 May 2025 22:52: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 54NMqoI3050656; Fri, 23 May 2025 22:52:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 54NMqoI9050653; Fri, 23 May 2025 22:52:50 GMT (envelope-from git) Date: Fri, 23 May 2025 22:52:50 GMT Message-Id: <202505232252.54NMqoI9050653@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 0b52d6c6cc4a - main - unix/stream: factor out uipc_wakeup() from pr_soreceive method 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: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0b52d6c6cc4a0b3c6e04d114c57df2b1c1e098ae Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=0b52d6c6cc4a0b3c6e04d114c57df2b1c1e098ae commit 0b52d6c6cc4a0b3c6e04d114c57df2b1c1e098ae Author: Gleb Smirnoff AuthorDate: 2025-05-23 20:19:09 +0000 Commit: Gleb Smirnoff CommitDate: 2025-05-23 22:04:38 +0000 unix/stream: factor out uipc_wakeup() from pr_soreceive method It is also needed for shutdown(2). No functional change. --- sys/kern/uipc_usrreq.c | 62 +++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 3181868175a8..a855c47d2e5a 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1304,6 +1304,43 @@ out: return (error); } +/* + * Our version of sowakeup(), used by recv(2) and shutdown(2). + * + * @param so Points to a connected stream socket with receive buffer locked + * + * In a blocking mode peer is sleeping on our receive buffer, and we need just + * wakeup(9) on it. But to wake up various event engines, we need to reach + * over to peer's selinfo. This can be safely done as the socket buffer + * receive lock is protecting us from the peer going away. + */ +static void +uipc_wakeup(struct socket *so) +{ + struct sockbuf *sb = &so->so_rcv; + struct selinfo *sel; + + SOCK_RECVBUF_LOCK_ASSERT(so); + MPASS(sb->uxst_peer != NULL); + + sel = &sb->uxst_peer->so_wrsel; + + if (sb->uxst_flags & UXST_PEER_SEL) { + selwakeuppri(sel, PSOCK); + /* + * XXXGL: sowakeup() does SEL_WAITING() without locks. + */ + if (!SEL_WAITING(sel)) + sb->uxst_flags &= ~UXST_PEER_SEL; + } + if (sb->sb_flags & SB_WAIT) { + sb->sb_flags &= ~SB_WAIT; + wakeup(&sb->sb_acc); + } + KNOTE_LOCKED(&sel->si_note, 0); + SOCK_RECVBUF_UNLOCK(so); +} + static int uipc_soreceive_stream_or_seqpacket(struct socket *so, struct sockaddr **psa, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp) @@ -1448,35 +1485,14 @@ restart: MPASS(sb->sb_mbcnt >= mbcnt); sb->sb_mbcnt -= mbcnt; UIPC_STREAM_SBCHECK(sb); - /* - * In a blocking mode peer is sleeping on our receive buffer, - * and we need just wakeup(9) on it. But to wake up various - * event engines, we need to reach over to peer's selinfo. - * This can be safely done as the socket buffer receive lock - * is protecting us from the peer going away. - */ if (__predict_true(sb->uxst_peer != NULL)) { - struct selinfo *sel = &sb->uxst_peer->so_wrsel; struct unpcb *unp2; bool aio; if ((aio = sb->uxst_flags & UXST_PEER_AIO)) sb->uxst_flags &= ~UXST_PEER_AIO; - if (sb->uxst_flags & UXST_PEER_SEL) { - selwakeuppri(sel, PSOCK); - /* - * XXXGL: sowakeup() does SEL_WAITING() without - * locks. - */ - if (!SEL_WAITING(sel)) - sb->uxst_flags &= ~UXST_PEER_SEL; - } - if (sb->sb_flags & SB_WAIT) { - sb->sb_flags &= ~SB_WAIT; - wakeup(&sb->sb_acc); - } - KNOTE_LOCKED(&sel->si_note, 0); - SOCK_RECVBUF_UNLOCK(so); + + uipc_wakeup(so); /* * XXXGL: need to go through uipc_lock_peer() after * the receive buffer lock dropped, it was protecting