diff options
author | bmilekic <bmilekic@FreeBSD.org> | 2003-05-10 18:08:23 +0000 |
---|---|---|
committer | bmilekic <bmilekic@FreeBSD.org> | 2003-05-10 18:08:23 +0000 |
commit | 988354fc06d732a75efc2f137144a82888957a80 (patch) | |
tree | 92998c5567ad04e90fce49788e4339b0a6f5c3f7 /sys/kern | |
parent | a630b57d8b17464e6bb004ae55b254a0f57e2aea (diff) | |
download | FreeBSD-src-988354fc06d732a75efc2f137144a82888957a80.zip FreeBSD-src-988354fc06d732a75efc2f137144a82888957a80.tar.gz |
Make m_freem() just use m_free() instead of duplicating the code. The
reason for the duplication was that m_freem() was meant to eventually
be optimized to hold the lock of the cache being freed to as long as
possible across frees but the difficulty of implementing said
optimization right now is too high, given that in some cases (see MAC
and non-cluster external buffers), we need to call into other subsytems,
something not permissible when the cache lock is held.
This change minimizes code duplication while keeping at least the
atomic mbuf+cluster free optimization.
Suggested by: luigi
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/subr_mbuf.c | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/sys/kern/subr_mbuf.c b/sys/kern/subr_mbuf.c index 5d624f6..8736526 100644 --- a/sys/kern/subr_mbuf.c +++ b/sys/kern/subr_mbuf.c @@ -1422,39 +1422,9 @@ m_free(struct mbuf *mb) void m_freem(struct mbuf *mb) { - struct mbuf *m; - int cchnum; - short persist; - while (mb != NULL) { -#ifdef INVARIANTS - if (mb->m_flags & M_FREELIST) - panic("m_freem detected a mbuf double-free"); - mb->m_flags |= M_FREELIST; -#endif - if ((mb->m_flags & M_PKTHDR) != 0) - m_tag_delete_chain(mb, NULL); - persist = 0; - m = mb; - mb = mb->m_next; - if ((m->m_flags & M_EXT) != 0) { - MEXT_REM_REF(m); - if (atomic_cmpset_int(m->m_ext.ref_cnt, 0, 1)) { - if (m->m_ext.ext_type == EXT_CLUSTER) { - mb_free(&mb_list_clust, - (caddr_t)m->m_ext.ext_buf, - MT_NOTMBUF, MBP_PERSIST, &cchnum); - persist = MBP_PERSISTENT; - } else { - (*(m->m_ext.ext_free))(m->m_ext.ext_buf, - m->m_ext.ext_args); - _mext_dealloc_ref(m); - persist = 0; - } - } - } - mb_free(&mb_list_mbuf, m, m->m_type, persist, &cchnum); - } + while (mb != NULL) + mb = m_free(mb); } /* |