Allow drivers to free an mbuf without having the mbuf be touched if

the driver has already freed any attached tags

Approved by: re(gnn)
This commit is contained in:
kmacy 2007-10-06 21:13:55 +00:00
parent 880e253277
commit c00108fd67
2 changed files with 15 additions and 2 deletions

View File

@ -339,9 +339,12 @@ static void
mb_dtor_mbuf(void *mem, int size, void *arg)
{
struct mbuf *m;
unsigned long flags;
m = (struct mbuf *)mem;
if ((m->m_flags & M_PKTHDR) != 0)
flags = (unsigned long)arg;
if ((flags & MB_NOTAGS) == 0 && (m->m_flags & M_PKTHDR) != 0)
m_tag_delete_chain(m, NULL);
KASSERT((m->m_flags & M_EXT) == 0, ("%s: M_EXT set", __func__));
#ifdef INVARIANTS
@ -527,7 +530,7 @@ mb_ctor_pack(void *mem, int size, void *arg, int how)
m->m_len = 0;
m->m_flags = (flags | M_EXT);
m->m_type = type;
if (flags & M_PKTHDR) {
m->m_pkthdr.rcvif = NULL;
m->m_pkthdr.len = 0;

View File

@ -254,6 +254,8 @@ struct mbuf {
#define MT_NOINIT 255 /* Not a type but a flag to allocate
a non-initialized mbuf */
#define MB_NOTAGS 0x1UL /* no tags attached to mbuf */
/*
* General mbuf allocator statistics structure.
*
@ -490,6 +492,14 @@ m_getjcl(int how, short type, int flags, int size)
return (m);
}
static __inline void
m_free_fast(struct mbuf *m)
{
KASSERT(SLIST_EMPTY(&m->m_pkthdr.tags), ("doing fast free of mbuf with tags"));
uma_zfree_arg(zone_mbuf, m, (void *)MB_NOTAGS);
}
static __inline struct mbuf *
m_free(struct mbuf *m)
{