Date: Thu, 23 May 2024 12:21:23 -0700 From: Ravi Pokala <rpokala@freebsd.org> To: Gleb Smirnoff <glebius@FreeBSD.org>, <src-committers@FreeBSD.org>, <dev-commits-src-all@FreeBSD.org>, <dev-commits-src-main@FreeBSD.org> Subject: Re: 0d3789584915 - main - ctl: use socket buffer mutexes in struct socket directly Message-ID: <1B513920-69CF-434E-B5A1-45960CB99246@panasas.com> In-Reply-To: <202405231912.44NJCLja032047@gitrepo.freebsd.org> References: <202405231912.44NJCLja032047@gitrepo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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: <owner-src-committers@freebsd.org <mailto:owner-src-committers@freebs= d.org>> on behalf of Gleb Smirnoff <glebius@FreeBSD.org <mailto:glebius@Free= BSD.org>> Date: Thursday, May 23, 2024 at 12:12 To: <src-committers@FreeBSD.org <mailto:src-committers@FreeBSD.org>>, <dev-= commits-src-all@FreeBSD.org <mailto:dev-commits-src-all@FreeBSD.org>>, <dev-= commits-src-main@FreeBSD.org <mailto:dev-commits-src-main@FreeBSD.org>> 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 <https://cgit.FreeBSD.org/src/commit/?id=3D0d37895849150e1646485068= d12c3a8ff26809f9> commit 0d37895849150e1646485068d12c3a8ff26809f9 Author: Gleb Smirnoff <glebius@FreeBSD.org <mailto:glebius@FreeBSD.org>> AuthorDate: 2024-05-23 19:11:54 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org <mailto:glebius@FreeBSD.org>> 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 <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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1B513920-69CF-434E-B5A1-45960CB99246>