summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2009-08-12 20:02:42 +0000
committerdlg <dlg@openbsd.org>2009-08-12 20:02:42 +0000
commit1f5b91144e18d1a1bda4a89b8b9145d4a0463274 (patch)
treee41d24eb1768f85ac177c523f819b7af3989a47e
parentCrank the /usr sizes in the large configuration (diff)
downloadwireguard-openbsd-1f5b91144e18d1a1bda4a89b8b9145d4a0463274.tar.xz
wireguard-openbsd-1f5b91144e18d1a1bda4a89b8b9145d4a0463274.zip
revert my change to m_cluncount which tries to prevent the system
running out of mbufs for rx rings. if the system low watermark is lower than a rx rings low watermark, we'll never send a packet up the stack, we'll always recycle it. found by thib@ on a bge sadface
-rw-r--r--sys/dev/pci/if_em.c8
-rw-r--r--sys/dev/pci/if_ix.c8
-rw-r--r--sys/kern/uipc_mbuf.c58
-rw-r--r--sys/net/if_ethersubr.c11
-rw-r--r--sys/sys/mbuf.h4
5 files changed, 34 insertions, 55 deletions
diff --git a/sys/dev/pci/if_em.c b/sys/dev/pci/if_em.c
index 9d7ef0b9f13..c15a6be13b7 100644
--- a/sys/dev/pci/if_em.c
+++ b/sys/dev/pci/if_em.c
@@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
-/* $OpenBSD: if_em.c,v 1.218 2009/08/12 14:39:05 dlg Exp $ */
+/* $OpenBSD: if_em.c,v 1.219 2009/08/12 20:02:42 dlg Exp $ */
/* $FreeBSD: if_em.c,v 1.46 2004/09/29 18:28:28 mlaier Exp $ */
#include <dev/pci/if_em.h>
@@ -2649,12 +2649,10 @@ em_rxeof(struct em_softc *sc, int count)
sc->last_rx_desc_filled);
}
+ m_cluncount(m, 1);
sc->rx_ndescs--;
- if (m_cluncount(m) == 0)
- accept_frame = 1;
- else
- accept_frame = 0;
+ accept_frame = 1;
prev_len_adj = 0;
desc_len = letoh16(desc->length);
diff --git a/sys/dev/pci/if_ix.c b/sys/dev/pci/if_ix.c
index 49ba560e01d..b86c61e7595 100644
--- a/sys/dev/pci/if_ix.c
+++ b/sys/dev/pci/if_ix.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ix.c,v 1.28 2009/08/12 16:56:59 jsg Exp $ */
+/* $OpenBSD: if_ix.c,v 1.29 2009/08/12 20:02:42 dlg Exp $ */
/******************************************************************************
@@ -2631,12 +2631,10 @@ ixgbe_rxeof(struct rx_ring *rxr, int count)
rxr->last_rx_desc_filled);
}
+ m_cluncount(m, 1);
rxr->rx_ndescs--;
- if (m_cluncount(m) == 0)
- accept_frame = 1;
- else
- accept_frame = 0;
+ accept_frame = 1;
prev_len_adj = 0;
desc_len = letoh16(rxdesc->wb.upper.length);
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index a357f84a976..26b61162ee6 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.131 2009/08/12 14:39:05 dlg Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.132 2009/08/12 20:02:42 dlg Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -372,26 +372,20 @@ m_clcount(struct ifnet *ifp, int pi)
ifp->if_data.ifi_mclpool[pi].mcl_alive++;
}
-int
-m_cluncount(struct mbuf *m)
+void
+m_cluncount(struct mbuf *m, int all)
{
- struct mbuf_ext *me = &m->m_ext;
- int pi;
-
- splassert(IPL_NET);
-
- if (((m->m_flags & (M_EXT|M_CLUSTER)) != (M_EXT|M_CLUSTER)) ||
- (me->ext_ifp == NULL))
- return (0);
-
- pi = me->ext_backend;
- me->ext_ifp->if_data.ifi_mclpool[pi].mcl_alive--;
- me->ext_ifp = NULL;
-
- if (mclpools[pi].pr_nitems <= mclpools[pi].pr_minitems)
- return (1);
+ struct mbuf_ext *me;
- return (0);
+ do {
+ me = &m->m_ext;
+ if (((m->m_flags & (M_EXT|M_CLUSTER)) != (M_EXT|M_CLUSTER)) ||
+ (me->ext_ifp == NULL))
+ continue;
+
+ me->ext_ifp->if_data.ifi_mclpool[me->ext_backend].mcl_alive--;
+ me->ext_ifp = NULL;
+ } while (all && (m = m->m_next));
}
struct mbuf *
@@ -474,25 +468,21 @@ m_free(struct mbuf *m)
void
m_extfree(struct mbuf *m)
{
- struct mbuf_ext *me = &m->m_ext;
- int pi;
-
if (MCLISREFERENCED(m)) {
- me->ext_nextref->m_ext.ext_prevref = me->ext_prevref;
- me->ext_prevref->m_ext.ext_nextref = me->ext_nextref;
+ m->m_ext.ext_nextref->m_ext.ext_prevref =
+ m->m_ext.ext_prevref;
+ m->m_ext.ext_prevref->m_ext.ext_nextref =
+ m->m_ext.ext_nextref;
} else if (m->m_flags & M_CLUSTER) {
- pi = me->ext_backend;
- if (me->ext_ifp != NULL) {
- me->ext_ifp->if_data.ifi_mclpool[pi].mcl_alive--;
- me->ext_ifp = NULL;
- }
- pool_put(&mclpools[pi], me->ext_buf);
- } else if (me->ext_free)
- me->ext_free(me->ext_buf, me->ext_size, me->ext_arg);
+ m_cluncount(m, 0);
+ pool_put(&mclpools[m->m_ext.ext_backend],
+ m->m_ext.ext_buf);
+ } else if (m->m_ext.ext_free)
+ (*(m->m_ext.ext_free))(m->m_ext.ext_buf,
+ m->m_ext.ext_size, m->m_ext.ext_arg);
else
panic("unknown type of extension buffer");
-
- me->ext_size = 0;
+ m->m_ext.ext_size = 0;
m->m_flags &= ~(M_EXT|M_CLUSTER);
}
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index ba971536e3c..a4ee764bdbe 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ethersubr.c,v 1.134 2009/08/12 14:39:05 dlg Exp $ */
+/* $OpenBSD: if_ethersubr.c,v 1.135 2009/08/12 20:02:42 dlg Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
/*
@@ -542,14 +542,7 @@ ether_input(ifp0, eh, m)
struct ether_header *eh_tmp;
#endif
- /*
- * the cluster is no longer on the ring, so don't count it against the
- * ring. if the system wants the packet back we should give it back.
- */
- if (m_cluncount(m) != 0) {
- m_freem(m);
- return;
- }
+ m_cluncount(m, 1);
/* mark incomming routing domain */
m->m_pkthdr.rdomain = ifp->if_rdomain;
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index a8b21454744..ef6e1cbbcf1 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbuf.h,v 1.132 2009/08/12 14:39:05 dlg Exp $ */
+/* $OpenBSD: mbuf.h,v 1.133 2009/08/12 20:02:42 dlg Exp $ */
/* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */
/*
@@ -420,7 +420,7 @@ struct mbuf *m_clget(struct mbuf *, int, struct ifnet *, u_int);
void m_clsetwms(struct ifnet *, u_int, u_int, u_int);
int m_cldrop(struct ifnet *, int);
void m_clcount(struct ifnet *, int);
-int m_cluncount(struct mbuf *);
+void m_cluncount(struct mbuf *, int);
void m_clinitifp(struct ifnet *);
void m_adj(struct mbuf *, int);
void m_copyback(struct mbuf *, int, int, const void *);