summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmacy <kmacy@FreeBSD.org>2007-10-06 21:13:55 +0000
committerkmacy <kmacy@FreeBSD.org>2007-10-06 21:13:55 +0000
commitc00108fd67397129aaed54bbec1d64b7b0cd4259 (patch)
tree6da28a59b2ccdc4d405f3729f74981d6b9c1a58e
parent880e2532778939d3d8a220a03a74a153264d0aa1 (diff)
downloadFreeBSD-src-c00108fd67397129aaed54bbec1d64b7b0cd4259.zip
FreeBSD-src-c00108fd67397129aaed54bbec1d64b7b0cd4259.tar.gz
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)
-rw-r--r--sys/kern/kern_mbuf.c7
-rw-r--r--sys/sys/mbuf.h10
2 files changed, 15 insertions, 2 deletions
diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c
index 8023920..a5e1348 100644
--- a/sys/kern/kern_mbuf.c
+++ b/sys/kern/kern_mbuf.c
@@ -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;
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index bf7c073..dc05c78 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -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)
{
OpenPOWER on IntegriCloud