diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-08-09 12:42:12 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2009-08-09 12:42:12 +0000 |
commit | f39d463c083bc9393fe45f5cccf828cd7d8ae8ce (patch) | |
tree | 1533590b6460a1dd3a73d853b2a6de888cfecf16 | |
parent | 4918c81fd0c99e73e142cfaee9a0aff79415ede2 (diff) |
create a m_free_unlocked which is now used by both m_freem() and m_free().
this lets m_freem() only do one splnet/splx instead of repeating this all
the way down a chain
ok henning claudio dlg
-rw-r--r-- | sys/kern/uipc_mbuf.c | 23 | ||||
-rw-r--r-- | sys/sys/mbuf.h | 3 |
2 files changed, 20 insertions, 6 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 0123f0cee0d..3d4f7547b86 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.124 2009/08/09 12:24:40 deraadt Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.125 2009/08/09 12:42:11 deraadt Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -438,12 +438,10 @@ m_clget(struct mbuf *m, int how, struct ifnet *ifp, u_int pktlen) } struct mbuf * -m_free(struct mbuf *m) +m_free_unlocked(struct mbuf *m) { struct mbuf *n; - int s; - s = splnet(); mbstat.m_mtypes[m->m_type]--; if (m->m_flags & M_PKTHDR) m_tag_delete_chain(m); @@ -451,6 +449,18 @@ m_free(struct mbuf *m) m_extfree(m); n = m->m_next; pool_put(&mbpool, m); + + return (n); +} + +struct mbuf * +m_free(struct mbuf *m) +{ + struct mbuf *n; + int s; + + s = splnet(); + n = m_free_unlocked(m); splx(s); return (n); @@ -481,12 +491,15 @@ void m_freem(struct mbuf *m) { struct mbuf *n; + int s; if (m == NULL) return; + s = splnet(); do { - MFREE(m, n); + n = m_free_unlocked(m); } while ((m = n) != NULL); + splx(s); } /* diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 6da5ee1fa3b..f13314cc666 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mbuf.h,v 1.125 2009/08/09 11:53:54 deraadt Exp $ */ +/* $OpenBSD: mbuf.h,v 1.126 2009/08/09 12:42:09 deraadt Exp $ */ /* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */ /* @@ -407,6 +407,7 @@ void mbinit(void); struct mbuf *m_copym2(struct mbuf *, int, int, int); struct mbuf *m_copym(struct mbuf *, int, int, int); struct mbuf *m_free(struct mbuf *); +struct mbuf *m_free_unlocked(struct mbuf *); struct mbuf *m_get(int, int); struct mbuf *m_getclr(int, int); struct mbuf *m_gethdr(int, int); |