From nobody Thu May 23 19:21:23 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 4VldMD6rFbz5L7nK; Thu, 23 May 2024 19:21:28 +0000 (UTC) (envelope-from rpokala@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VldMD6Kwhz539f; Thu, 23 May 2024 19:21:28 +0000 (UTC) (envelope-from rpokala@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716492088; 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: in-reply-to:in-reply-to:references:references; bh=+qH60lC2f4arBa8mhwnm8nENDQYpQ9nxCIjUfgPZFNU=; b=fW/YHWKOLl/enCX/TofV7lOZvr1MN3/ffXTRVyvHIl94zA6YN//WbQw2Sej1tjiTodnI7I MF/pHoBn2mvp5OIPeCISQ636muuG+oSrg+2CsvUfHJMOgrKRUxbndlthBbftv7XwCE8ngy 3I98xipP4ZmBVeBZ2a8JXmuRjnoyVFt07qTEfdG++l9MMbccWuvhko1gz8JtWzuTFze7+T WLy5iBR61gvJfbBYEpoyHdBPUjUrew5To2qwJUIvsBO/7EnLsRoDmXH5pd1OBxVu1atkFK UxmnGlANTf+hyyJIg0cl+Hs9vRos8MOGYURenawN48qJvwDDEFdysYJchpc9eQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716492088; a=rsa-sha256; cv=none; b=WL/a8ZfUO/b3YIkvzYWpplBi12qrpfno8bTddXblM+NkyFWl0XKIo27m5cZMH1KS8U+lfM raisN9y/1ly3pubNkYW1pMgsrxaHYT5wrJHIFw9o4vOQKDJwwgAIQWaFjcOfqWCA6SPko8 I8TxdXI8R1IFmQeUU86SNmOLGNgBfDlr0Rxl5D4wXbisCjEW3cgwAv/Vig5V71jeC+iDN6 aOD5SFtgYzdvHDOJ8NU6fvTE2qg8jp5r3r4CALxADMp2rHcNkhzoaWXrOO+IdiyfiLn9dk 6jZ/ptWmiNazOgH83oJIJ3ZmExHrnZrKUHfroR5Sha5kB2qIQvqEkJxO+sEFKg== 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=1716492088; 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: in-reply-to:in-reply-to:references:references; bh=+qH60lC2f4arBa8mhwnm8nENDQYpQ9nxCIjUfgPZFNU=; b=df2+ppntazdz/z5JWZ4a6cMdcu39gV+LZA0j10Vna5yt02/aFPXLJEgM2jMKvJXMaqyprF ReY1dX4tcj7Q+hzl6e29WsV95NJPC6O88r+Rm9ogMJo2goVebSiQiHepJueJ7O0eqlPxV8 p7xOEuXkTigwdO/GLBHjVdmqcmZUh/c2/bq/m7Ei8Q46KFO1w2rWsC/zzNYHmLUx1zUeIu DmZ+3wGVZYLA6b4Kr6/EcrBt3l4My2mWCTmQN93JjqQHGlikDXdJnIvBYfu1gubWZ4YaVZ WcjiqqfUcOcJNa18sAfVxAn56JSNIPFhoIE2WStBRjgMCmVYwpuUaF0b3h577g== Received: from [192.168.1.10] (c-73-231-46-254.hsd1.ca.comcast.net [73.231.46.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: rpokala) by smtp.freebsd.org (Postfix) with ESMTPSA id 4VldMD2FR9zLRM; Thu, 23 May 2024 19:21:28 +0000 (UTC) (envelope-from rpokala@freebsd.org) User-Agent: Microsoft-MacOutlook/16.85.24051916 Date: Thu, 23 May 2024 12:21:23 -0700 Subject: Re: 0d3789584915 - main - ctl: use socket buffer mutexes in struct socket directly From: Ravi Pokala To: Gleb Smirnoff , , , Message-ID: <1B513920-69CF-434E-B5A1-45960CB99246@panasas.com> Thread-Topic: 0d3789584915 - main - ctl: use socket buffer mutexes in struct socket directly Thread-Index: AQHarUYcTs2miEsRM02SSnaBkVpxjg== References: <202405231912.44NJCLja032047@gitrepo.freebsd.org> In-Reply-To: <202405231912.44NJCLja032047@gitrepo.freebsd.org> 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: quoted-printable Hi Gleb, Isn't this the exact opposite of the summary? This change *doesn't* use the= mutexes directly, it uses the wrappers to *avoid* using the mutexes directl= y. Thanks, Ravi (rpokala@) =EF=BB=BF-----Original Message----- From: > on behalf of Gleb Smirnoff > Date: Thursday, May 23, 2024 at 12:12 To: >, >, > Subject: git: 0d3789584915 - main - ctl: use socket buffer mutexes in struc= t socket directly The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=3D0d37895849150e1646485068d12c3a= 8ff26809f9 commit 0d37895849150e1646485068d12c3a8ff26809f9 Author: Gleb Smirnoff > AuthorDate: 2024-05-23 19:11:54 +0000 Commit: Gleb Smirnoff > CommitDate: 2024-05-23 19:11:54 +0000 ctl: use socket buffer mutexes in struct socket directly A mechanical change performed with sed(1) script: s/SOCKBUF_LOCK\(&so->so_rcv\)/SOCK_RECVBUF_LOCK(so)/ s/SOCKBUF_UNLOCK\(&so->so_rcv\)/SOCK_RECVBUF_UNLOCK(so)/ s/SOCKBUF_MTX\(&so->so_rcv\)/SOCK_RECVBUF_MTX(so)/ s/SOCKBUF_LOCK\(&so->so_snd\)/SOCK_SENDBUF_LOCK(so)/ s/SOCKBUF_UNLOCK\(&so->so_snd\)/SOCK_SENDBUF_UNLOCK(so)/ s/SOCKBUF_MTX\(&so->so_snd\)/SOCK_SENDBUF_MTX(so)/ Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D45190 --- sys/cam/ctl/ctl_ha.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/sys/cam/ctl/ctl_ha.c b/sys/cam/ctl/ctl_ha.c index 695006ed99e1..e94708028ee4 100644 --- a/sys/cam/ctl/ctl_ha.c +++ b/sys/cam/ctl/ctl_ha.c @@ -164,17 +164,17 @@ ctl_ha_close(struct ha_softc *softc) report =3D 1; } if (so) { - SOCKBUF_LOCK(&so->so_rcv); + SOCK_RECVBUF_LOCK(so); soupcall_clear(so, SO_RCV); while (softc->ha_receiving) { wakeup(&softc->ha_receiving); - msleep(&softc->ha_receiving, SOCKBUF_MTX(&so->so_rcv), + msleep(&softc->ha_receiving, SOCK_RECVBUF_MTX(so), 0, "ha_rx exit", 0); } - SOCKBUF_UNLOCK(&so->so_rcv); - SOCKBUF_LOCK(&so->so_snd); + SOCK_RECVBUF_UNLOCK(so); + SOCK_SENDBUF_LOCK(so); soupcall_clear(so, SO_SND); - SOCKBUF_UNLOCK(&so->so_snd); + SOCK_SENDBUF_UNLOCK(so); softc->ha_so =3D NULL; if (softc->ha_connect) pause("reconnect", hz / 2); @@ -218,7 +218,7 @@ ctl_ha_rx_thread(void *arg) next =3D wire_hdr.length; else next =3D sizeof(wire_hdr); - SOCKBUF_LOCK(&so->so_rcv); + SOCK_RECVBUF_LOCK(so); while (sbavail(&so->so_rcv) < next || softc->ha_disconnect) { if (softc->ha_connected =3D=3D 0 || softc->ha_disconnect || so->so_error || @@ -226,10 +226,10 @@ ctl_ha_rx_thread(void *arg) goto errout; } so->so_rcv.sb_lowat =3D next; - msleep(&softc->ha_receiving, SOCKBUF_MTX(&so->so_rcv), + msleep(&softc->ha_receiving, SOCK_RECVBUF_MTX(so), 0, "-", 0); } - SOCKBUF_UNLOCK(&so->so_rcv); + SOCK_RECVBUF_UNLOCK(so); if (wire_hdr.length =3D=3D 0) { iov.iov_base =3D &wire_hdr; @@ -246,7 +246,7 @@ ctl_ha_rx_thread(void *arg) if (error !=3D 0) { printf("%s: header receive error %d\n", __func__, error); - SOCKBUF_LOCK(&so->so_rcv); + SOCK_RECVBUF_LOCK(so); goto errout; } } else { @@ -259,7 +259,7 @@ ctl_ha_rx_thread(void *arg) errout: softc->ha_receiving =3D 0; wakeup(&softc->ha_receiving); - SOCKBUF_UNLOCK(&so->so_rcv); + SOCK_RECVBUF_UNLOCK(so); ctl_ha_conn_wake(softc); kthread_exit(); } @@ -280,13 +280,13 @@ ctl_ha_send(struct ha_softc *softc) break; } } - SOCKBUF_LOCK(&so->so_snd); + SOCK_SENDBUF_LOCK(so); if (sbspace(&so->so_snd) < softc->ha_sending->m_pkthdr.len) { so->so_snd.sb_lowat =3D softc->ha_sending->m_pkthdr.len; - SOCKBUF_UNLOCK(&so->so_snd); + SOCK_SENDBUF_UNLOCK(so); break; } - SOCKBUF_UNLOCK(&so->so_snd); + SOCK_SENDBUF_UNLOCK(so); error =3D sosend(softc->ha_so, NULL, NULL, softc->ha_sending, NULL, MSG_DONTWAIT, curthread); softc->ha_sending =3D NULL; @@ -309,14 +309,14 @@ ctl_ha_sock_setup(struct ha_softc *softc) if (error) printf("%s: soreserve failed %d\n", __func__, error); - SOCKBUF_LOCK(&so->so_rcv); + SOCK_RECVBUF_LOCK(so); so->so_rcv.sb_lowat =3D sizeof(struct ha_msg_wire); soupcall_set(so, SO_RCV, ctl_ha_rupcall, softc); - SOCKBUF_UNLOCK(&so->so_rcv); - SOCKBUF_LOCK(&so->so_snd); + SOCK_RECVBUF_UNLOCK(so); + SOCK_SENDBUF_LOCK(so); so->so_snd.sb_lowat =3D sizeof(struct ha_msg_wire); soupcall_set(so, SO_SND, ctl_ha_supcall, softc); - SOCKBUF_UNLOCK(&so->so_snd); + SOCK_SENDBUF_UNLOCK(so); bzero(&opt, sizeof(struct sockopt)); opt.sopt_dir =3D SOPT_SET;