Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Jan 2020 07:35:35 +1100
From:      Peter Jeremy <peter@rulingia.com>
To:        Mark Millard <marklmi@yahoo.com>
Cc:        freebsd-arm <freebsd-arm@freebsd.org>, FreeBSD Current <freebsd-current@freebsd.org>
Subject:   Re: head -r356066 reaching kern.ipc.nmbclusters on Rock64 (CortexA53 with 4GiByte of RAM) while putting files on it via nfs: some evidence
Message-ID:  <20200104203535.GA32966@server.rulingia.com>
In-Reply-To: <65659DD9-335A-40C7-A6DE-B71019BCD6E6@yahoo.com>
References:  <65659DD9-335A-40C7-A6DE-B71019BCD6E6.ref@yahoo.com> <65659DD9-335A-40C7-A6DE-B71019BCD6E6@yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Sorry for the delay in responding.

On 2019-Dec-27 21:59:49 -0800, Mark Millard via freebsd-arm <freebsd-arm@fr=
eebsd.org> wrote:
>The following sort of sequence leads to the Rock64 not
>responding on the console or over ethernet, after notifying
>of nmbclusters having been reached. (This limits what
>information I have of what things were like at the end.)

There's a bug in the dwc(4) driver such that it can leak mbuf clusters.
I've been running with the following patch but need to clean it up
samewhat before I can commit it:

Index: sys/dev/dwc/if_dwc.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- sys/dev/dwc/if_dwc.c	(revision 356350)
+++ sys/dev/dwc/if_dwc.c	(working copy)
@@ -755,7 +755,6 @@
 dwc_rxfinish_locked(struct dwc_softc *sc)
 {
 	struct ifnet *ifp;
-	struct mbuf *m0;
 	struct mbuf *m;
 	int error, idx, len;
 	uint32_t rdes0;
@@ -762,9 +761,8 @@
=20
 	ifp =3D sc->ifp;
=20
-	for (;;) {
+	for (; ; sc->rx_idx =3D next_rxidx(sc, sc->rx_idx)) {
 		idx =3D sc->rx_idx;
-
 		rdes0 =3D sc->rxdesc_ring[idx].tdes0;
 		if ((rdes0 & DDESC_RDES0_OWN) !=3D 0)
 			break;
@@ -773,9 +771,9 @@
 		    BUS_DMASYNC_POSTREAD);
 		bus_dmamap_unload(sc->rxbuf_tag, sc->rxbuf_map[idx].map);
=20
+		m =3D sc->rxbuf_map[idx].mbuf;
 		len =3D (rdes0 >> DDESC_RDES0_FL_SHIFT) & DDESC_RDES0_FL_MASK;
 		if (len !=3D 0) {
-			m =3D sc->rxbuf_map[idx].mbuf;
 			m->m_pkthdr.rcvif =3D ifp;
 			m->m_pkthdr.len =3D len;
 			m->m_len =3D len;
@@ -784,24 +782,33 @@
 			/* Remove trailing FCS */
 			m_adj(m, -ETHER_CRC_LEN);
=20
+			/* Consume the mbuf and mark it as consumed */
+			sc->rxbuf_map[idx].mbuf =3D NULL;
 			DWC_UNLOCK(sc);
 			(*ifp->if_input)(ifp, m);
 			DWC_LOCK(sc);
+			m =3D NULL;
 		} else {
 			/* XXX Zero-length packet ? */
 		}
=20
-		if ((m0 =3D dwc_alloc_mbufcl(sc)) !=3D NULL) {
-			if ((error =3D dwc_setup_rxbuf(sc, idx, m0)) !=3D 0) {
-				/*
-				 * XXX Now what?
-				 * We've got a hole in the rx ring.
-				 */
+		if (m =3D=3D NULL) {
+			if ((m =3D dwc_alloc_mbufcl(sc)) =3D=3D NULL) {
+				if_inc_counter(sc->ifp, IFCOUNTER_IQDROPS, 1);
+				continue;
 			}
-		} else
+		}
+
+		if ((error =3D dwc_setup_rxbuf(sc, idx, m)) !=3D 0) {
+			m_free(m);
+			device_printf(sc->dev,
+			    "dwc_setup_rxbuf returned %d\n", error);
 			if_inc_counter(sc->ifp, IFCOUNTER_IQDROPS, 1);
-
-		sc->rx_idx =3D next_rxidx(sc, sc->rx_idx);
+			/*
+			 * XXX Now what?
+			 * We've got a hole in the rx ring.
+			 */
+		}
 	}
 }

--=20
Peter Jeremy

--J2SCkAp4GZ/dPZZf
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEE7rKYbDBnHnTmXCJ+FqWXoOSiCzQFAl4Q9xJfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEVF
QjI5ODZDMzA2NzFFNzRFNjVDMjI3RTE2QTU5N0EwRTRBMjBCMzQACgkQFqWXoOSi
CzQTpg//WnVv/CeDAL5WlR+xk8ocAbu0G3KymVzUkMjYvCWRJ0Fc3M9c+8yw/IAv
j9p5emq1+APq89fB4edxhPH4nqjZEnuxd47/Gla8QMLQ1I9g0eyZwdb7wg6Oa+bp
23JffW2ovdMzMatKVnC9soB1QflXRCfGEmhJV5L/JV3xB/fjNs5soQrXk45gLDnY
lSDA24IAjnGz8a1ZialujFPf581A4Nts3DMXNvvsIUr4nrEF73ZWs27kZtodEam6
EdkQnfrpW3bzQjca4ubefi6ONAb3dui/VLV4f9IWUUrKaY1IA2NMxcDWa2t8dEzw
c8E88qfycXLpIRbVOWUTEx4WHeyBBf/OdtqoyQzU8TrAbfAU4kxjuTyEBmnaQRF5
NSBkc04iK7R4NbOPcq0GCzhW0lWjLaIwCVBfTAZ2vPPo50QiMeBfU+Y/jLXMxKKu
QvfwFaPsbF1H3yUn3u8T/EJRQ1mX1X4yYSGRd+PG1k8SGjaezmAHZ2zEL/HHawu3
CSrU8CdFn60reZqCrLAvw3js8b2M/cmfNy9S4mkuGdnakPgPYuV0h/e/xd+kt/6Q
IuIfZ6O6HiZCaCGFYRsLr3+McV2dOFhGdL5fPefzBcmNmXnkjJh+Ee3yLQSLizLF
jxijm9qjA3Uo5gdxOkaK2jR9SGztC2XmtF37ly4w69fdPYXG16E=
=iJkU
-----END PGP SIGNATURE-----

--J2SCkAp4GZ/dPZZf--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200104203535.GA32966>