summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2014-07-08 07:10:13 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2014-07-08 07:10:13 +0000
commit9d14de50f15bae209d0fb94086f9ecf1d4ad4142 (patch)
treee24a5625fbb85712709a3fcffd3c422adb547cc0 /sys
parent3ff18468b901339fd64cc6723531d1f7ec0144e0 (diff)
pull the rx ring accounting out of the mbuf layer now that its all done
via if_rxring things. this effectively deprecates the third argument for MCLGETI and m_clget and makes the mbuf layer no longer care about interfaces and simplifies the allocation paths. the timeout used to measure livelock has been moved to net/if.c. ok mpi@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_sysctl.c6
-rw-r--r--sys/kern/uipc_mbuf.c151
-rw-r--r--sys/net/if.c29
-rw-r--r--sys/net/if_ethersubr.c4
-rw-r--r--sys/sys/mbuf.h7
5 files changed, 29 insertions, 168 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index b7f84b91360..e3371250659 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.253 2014/07/04 05:58:31 guenther Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.254 2014/07/08 07:10:12 dlg Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -110,7 +110,7 @@ extern int nselcoll, fscale;
extern struct disklist_head disklist;
extern fixpt_t ccpu;
extern long numvnodes;
-extern u_int mcllivelocks;
+extern u_int net_livelocks;
extern void nmbclust_update(void);
@@ -591,7 +591,7 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
dev = NODEV;
return sysctl_rdstruct(oldp, oldlenp, newp, &dev, sizeof(dev));
case KERN_NETLIVELOCKS:
- return (sysctl_rdint(oldp, oldlenp, newp, mcllivelocks));
+ return (sysctl_rdint(oldp, oldlenp, newp, net_livelocks));
case KERN_POOL_DEBUG: {
int old_pool_debug = pool_debug;
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 016bd27380f..a03fa007b76 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.187 2014/07/08 05:35:19 dlg Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.188 2014/07/08 07:10:12 dlg Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -118,10 +118,6 @@ int max_linkhdr; /* largest link-level header */
int max_protohdr; /* largest protocol header */
int max_hdr; /* largest link+protocol header */
-struct timeout m_cltick_tmo;
-int m_clticks;
-void m_cltick(void *);
-
void m_extfree(struct mbuf *);
struct mbuf *m_copym0(struct mbuf *, int, int, int, int);
void nmbclust_update(void);
@@ -162,9 +158,6 @@ mbinit(void)
}
nmbclust_update();
-
- timeout_set(&m_cltick_tmo, m_cltick, NULL);
- m_cltick(NULL);
}
void
@@ -298,134 +291,6 @@ m_clpool(u_int pktlen)
return (-1);
}
-u_int mcllivelocks;
-
-void
-m_clinitifp(struct ifnet *ifp)
-{
- struct mclpool *mclp = ifp->if_data.ifi_mclpool;
- int i;
-
- /* Initialize high water marks for use of cluster pools */
- for (i = 0; i < MCLPOOLS; i++) {
- mclp = &ifp->if_data.ifi_mclpool[i];
-
- if (mclp->mcl_lwm == 0)
- mclp->mcl_lwm = 2;
- if (mclp->mcl_hwm == 0)
- mclp->mcl_hwm = 32768;
-
- mclp->mcl_cwm = MAX(4, mclp->mcl_lwm);
- mclp->mcl_livelocks = mcllivelocks;
- }
-}
-
-void
-m_clsetwms(struct ifnet *ifp, u_int pktlen, u_int lwm, u_int hwm)
-{
- int pi;
-
- pi = m_clpool(pktlen);
- if (pi == -1)
- return;
-
- ifp->if_data.ifi_mclpool[pi].mcl_lwm = lwm;
- ifp->if_data.ifi_mclpool[pi].mcl_hwm = hwm;
-}
-
-/*
- * Record when the last timeout has been run. If the delta is
- * too high, m_cldrop() will notice and decrease the interface
- * high water marks.
- */
-void
-m_cltick(void *arg)
-{
- extern int ticks;
-
- if (ticks - m_clticks > 1)
- mcllivelocks++;
-
- m_clticks = ticks;
- timeout_add(&m_cltick_tmo, 1);
-}
-
-int m_livelock;
-
-int
-m_cldrop(struct ifnet *ifp, int pi)
-{
- static int liveticks;
- struct mclpool *mclp;
- extern int ticks;
- u_int diff, adj;
-
- if (ticks - m_clticks > 1) {
- /*
- * Timeout did not run, so we are in some kind of livelock.
- *
- * Increase the livelock counter to tell the interfaces to
- * decrease their cluster allocation high water marks.
- */
- m_livelock = 1;
- m_clticks = liveticks = ticks;
- } else if (m_livelock && (ticks - liveticks) > 4)
- m_livelock = 0; /* Let the high water marks grow again */
-
- mclp = &ifp->if_data.ifi_mclpool[pi];
-
- /*
- * If at least a livelock happened since the last time a cluster
- * was requested, decrease its pool allocation high water mark to
- * prevent it from growth for the very near future.
- *
- * The decrease is proportional to the number of livelocks since
- * the last request for a given pool.
- */
- adj = mcllivelocks - mclp->mcl_livelocks;
- if (adj != 0) {
- diff = max((mclp->mcl_cwm / 8) * adj, 2);
- mclp->mcl_cwm = max(mclp->mcl_lwm, mclp->mcl_cwm - diff);
- }
- mclp->mcl_livelocks = mcllivelocks;
-
- if (m_livelock == 0 && ISSET(ifp->if_flags, IFF_RUNNING) &&
- mclp->mcl_alive <= 4 && mclp->mcl_cwm < mclp->mcl_hwm &&
- mclp->mcl_grown - ticks < 0) {
- /* About to run out, so increase the current watermark */
- mclp->mcl_cwm++;
- mclp->mcl_grown = ticks;
- } else if (mclp->mcl_alive >= mclp->mcl_cwm)
- return (1); /* No more packets given */
-
- return (0);
-}
-
-void
-m_clcount(struct ifnet *ifp, int pi)
-{
- ifp->if_data.ifi_mclpool[pi].mcl_alive++;
-}
-
-void
-m_cluncount(struct mbuf *m, int all)
-{
- struct mbuf_ext *me;
- struct ifnet *ifp;
-
- do {
- me = &m->m_ext;
- if (((m->m_flags & (M_EXT|M_CLUSTER)) != (M_EXT|M_CLUSTER)) ||
- (me->ext_ifidx == 0))
- continue;
-
- ifp = if_get(me->ext_ifidx);
- if (ifp != NULL)
- ifp->if_data.ifi_mclpool[me->ext_backend].mcl_alive--;
- me->ext_ifidx = 0;
- } while (all && (m = m->m_next));
-}
-
struct mbuf *
m_clget(struct mbuf *m, int how, struct ifnet *ifp, u_int pktlen)
{
@@ -440,12 +305,6 @@ m_clget(struct mbuf *m, int how, struct ifnet *ifp, u_int pktlen)
#endif
s = splnet();
-
- if (ifp != NULL && m_cldrop(ifp, pi)) {
- splx(s);
- return (NULL);
- }
-
if (m == NULL) {
MGETHDR(m0, M_DONTWAIT, MT_DATA);
if (m0 == NULL) {
@@ -462,8 +321,6 @@ m_clget(struct mbuf *m, int how, struct ifnet *ifp, u_int pktlen)
splx(s);
return (NULL);
}
- if (ifp != NULL)
- m_clcount(ifp, pi);
splx(s);
m->m_data = m->m_ext.ext_buf;
@@ -472,10 +329,7 @@ m_clget(struct mbuf *m, int how, struct ifnet *ifp, u_int pktlen)
m->m_ext.ext_free = NULL;
m->m_ext.ext_arg = NULL;
m->m_ext.ext_backend = pi;
- if (ifp != NULL)
- m->m_ext.ext_ifidx = ifp->if_index;
- else
- m->m_ext.ext_ifidx = 0;
+ m->m_ext.ext_ifidx = 0;
MCLINITREFERENCE(m);
return (m);
}
@@ -524,7 +378,6 @@ m_extfree(struct mbuf *m)
m->m_ext.ext_prevref->m_ext.ext_nextref =
m->m_ext.ext_nextref;
} else if (m->m_flags & M_CLUSTER) {
- m_cluncount(m, 0);
pool_put(&mclpools[m->m_ext.ext_backend],
m->m_ext.ext_buf);
} else if (m->m_ext.ext_free)
diff --git a/sys/net/if.c b/sys/net/if.c
index fd0e8539ca6..86f0b35d513 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.293 2014/07/08 04:02:14 dlg Exp $ */
+/* $OpenBSD: if.c,v 1.294 2014/07/08 07:10:12 dlg Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -178,6 +178,8 @@ int if_cloners_count;
struct pool ifaddr_item_pl;
+struct timeout net_tick_to;
+void net_tick(void *);
int net_livelocked(void);
/*
@@ -195,8 +197,10 @@ ifinit()
"ifaddritem", NULL);
timeout_set(&if_slowtim, if_slowtimo, &if_slowtim);
+ timeout_set(&net_tick_to, net_tick, &net_tick_to);
if_slowtimo(&if_slowtim);
+ net_tick(&net_tick_to);
}
static unsigned int if_index = 0;
@@ -429,8 +433,6 @@ if_attach(struct ifnet *ifp)
ifp->if_xflags |= IFXF_NOINET6;
#endif
- m_clinitifp(ifp);
-
if_attachsetup(ifp);
}
@@ -1150,8 +1152,6 @@ if_up(struct ifnet *ifp)
#ifndef SMALL_KERNEL
rt_if_track(ifp);
#endif
-
- m_clinitifp(ifp);
}
/*
@@ -2382,13 +2382,28 @@ ifnewlladdr(struct ifnet *ifp)
splx(s);
}
+int net_ticks;
+u_int net_livelocks;
+
+void
+net_tick(void *null)
+{
+ extern int ticks;
+
+ if (ticks - net_ticks > 1)
+ net_livelocks++;
+
+ net_ticks = ticks;
+
+ timeout_add(&net_tick_to, 1);
+}
+
int
net_livelocked()
{
extern int ticks;
- extern int m_clticks;
- return (ticks - m_clticks > 1);
+ return (ticks - net_ticks > 1);
}
void
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 83551fdebf3..7ab15bbeef3 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ethersubr.c,v 1.172 2014/04/22 12:07:20 henning Exp $ */
+/* $OpenBSD: if_ethersubr.c,v 1.173 2014/07/08 07:10:12 dlg Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
/*
@@ -488,8 +488,6 @@ ether_input(struct ifnet *ifp0, struct ether_header *eh, struct mbuf *m)
struct ether_header *eh_tmp;
#endif
- m_cluncount(m, 1);
-
/* mark incoming routing table */
m->m_pkthdr.ph_rtableid = ifp->if_rdomain;
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index e99fe9fe4d7..192cf1c4aee 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbuf.h,v 1.176 2014/04/22 14:41:03 mpi Exp $ */
+/* $OpenBSD: mbuf.h,v 1.177 2014/07/08 07:10:12 dlg Exp $ */
/* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */
/*
@@ -432,11 +432,6 @@ struct mbuf *m_getptr(struct mbuf *, int, int *);
int m_leadingspace(struct mbuf *);
int m_trailingspace(struct mbuf *);
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);
-void m_cluncount(struct mbuf *, int);
-void m_clinitifp(struct ifnet *);
void m_adj(struct mbuf *, int);
int m_copyback(struct mbuf *, int, int, const void *, int);
void m_freem(struct mbuf *);