From owner-freebsd-current@freebsd.org Mon Jul 27 11:01:09 2015 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CD7069AC2C1 for ; Mon, 27 Jul 2015 11:01:09 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (mail.turbocat.net [IPv6:2a01:4f8:d16:4514::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 890CBB1D; Mon, 27 Jul 2015 11:01:09 +0000 (UTC) (envelope-from hps@selasky.org) Received: from laptop015.home.selasky.org (cm-176.74.213.204.customer.telag.net [176.74.213.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 8C1081FE022; Mon, 27 Jul 2015 13:01:07 +0200 (CEST) Message-ID: <55B60FC8.2020003@selasky.org> Date: Mon, 27 Jul 2015 13:02:32 +0200 From: Hans Petter Selasky User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: FreeBSD Current , Sean Bruno Subject: E1000 mbuf leaks Content-Type: multipart/mixed; boundary="------------040406080501020804080904" X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jul 2015 11:01:09 -0000 This is a multi-part message in MIME format. --------------040406080501020804080904 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi, I'm currently doing some busdma work, and possibly stepped over some driver bugs. When "bus_dmamap_load_mbuf_sg()" returns ENOMEM the mbuf chain is not freed. Is there some magic in "bus_dmamap_load_mbuf_sg()" for that error code or is there a possible memory leak in all E1000 drivers? See attached patch. > Index: if_em.c > =================================================================== > --- if_em.c (revision 284591) > +++ if_em.c (working copy) > @@ -2027,9 +2027,6 @@ > /* Try it again, but only once */ > remap = 0; > goto retry; > - } else if (error == ENOMEM) { > - adapter->no_tx_dma_setup++; > - return (error); > } else if (error != 0) { > adapter->no_tx_dma_setup++; > m_freem(*m_headp); > Index: if_igb.c > =================================================================== > --- if_igb.c (revision 284591) > +++ if_igb.c (working copy) > @@ -1905,9 +1905,6 @@ > goto retry; > } else > return (error); > - case ENOMEM: > - txr->no_tx_dma_setup++; > - return (error); > default: > txr->no_tx_dma_setup++; > m_freem(*m_headp); > Index: if_lem.c > =================================================================== > --- if_lem.c (revision 284591) > +++ if_lem.c (working copy) > @@ -1693,6 +1693,8 @@ > } > } else if (error != 0) { > adapter->no_tx_dma_setup++; > + m_freem(*m_headp); > + *m_headp = NULL; > return (error); > } > --HPS --------------040406080501020804080904 Content-Type: text/x-diff; name="e1000-memory-leak.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="e1000-memory-leak.diff" Index: if_em.c =================================================================== --- if_em.c (revision 284591) +++ if_em.c (working copy) @@ -2027,9 +2027,6 @@ /* Try it again, but only once */ remap = 0; goto retry; - } else if (error == ENOMEM) { - adapter->no_tx_dma_setup++; - return (error); } else if (error != 0) { adapter->no_tx_dma_setup++; m_freem(*m_headp); Index: if_igb.c =================================================================== --- if_igb.c (revision 284591) +++ if_igb.c (working copy) @@ -1905,9 +1905,6 @@ goto retry; } else return (error); - case ENOMEM: - txr->no_tx_dma_setup++; - return (error); default: txr->no_tx_dma_setup++; m_freem(*m_headp); Index: if_lem.c =================================================================== --- if_lem.c (revision 284591) +++ if_lem.c (working copy) @@ -1693,6 +1693,8 @@ } } else if (error != 0) { adapter->no_tx_dma_setup++; + m_freem(*m_headp); + *m_headp = NULL; return (error); } --------------040406080501020804080904--