diff options
author | gallatin <gallatin@FreeBSD.org> | 2003-01-02 21:16:50 +0000 |
---|---|---|
committer | gallatin <gallatin@FreeBSD.org> | 2003-01-02 21:16:50 +0000 |
commit | 53ffe07705f6bdc395a2ddc795e9fffeb642ec8a (patch) | |
tree | 305909f8cd1b7a3f67c4c8e6df82c22c2a21b7f8 /sys/kern/subr_mbuf.c | |
parent | a33543dd9281563dbf12b04862c79e090d59086b (diff) | |
download | FreeBSD-src-53ffe07705f6bdc395a2ddc795e9fffeb642ec8a.zip FreeBSD-src-53ffe07705f6bdc395a2ddc795e9fffeb642ec8a.tar.gz |
o Introduce a new external mbuf type, EXT_EXTREF.
o Allow callers of m_extadd() to allocate their own reference
m_ext.ref_cnt pointer, rather than having the mbuf system allocate it
with a malloc() in the critical path. This speeds m_extadd() up, and
also simplifies locking (malloc() may need Giant).
A driver or subsystem wishing to take use its own ref counter must
initialize m_ext.ref_cnt to point to its ref counter prior to
calling m_extadd(), and it must use EXT_EXTREF as its external type.
Eg:
m->m_ext.ref_cnt = my_ref_cnt_ptr;
m_extadd(.....,EXT_EXTREF);
Reviewed by: bosko
Diffstat (limited to 'sys/kern/subr_mbuf.c')
-rw-r--r-- | sys/kern/subr_mbuf.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kern/subr_mbuf.c b/sys/kern/subr_mbuf.c index 02ad99a..21e1a40 100644 --- a/sys/kern/subr_mbuf.c +++ b/sys/kern/subr_mbuf.c @@ -1062,7 +1062,8 @@ mb_reclaim(void) (((uintptr_t)(cl) - (uintptr_t)cl_refcntmap) >> MCLSHIFT) #define _mext_dealloc_ref(m) \ - free((m)->m_ext.ref_cnt, M_MBUF) + if ((m)->m_ext.ext_type != EXT_EXTREF) \ + free((m)->m_ext.ref_cnt, M_MBUF) /****************************************************************************** * Internal routines. @@ -1508,9 +1509,13 @@ void m_extadd(struct mbuf *mb, caddr_t buf, u_int size, void (*freef)(void *, void *), void *args, int flags, int type) { + u_int *ref_cnt = NULL; - _mext_init_ref(mb, ((type != EXT_CLUSTER) ? - NULL : &cl_refcntmap[cl2ref(mb->m_ext.ext_buf)])); + if (type == EXT_CLUSTER) + ref_cnt = &cl_refcntmap[cl2ref(mb->m_ext.ext_buf)]; + else if (type == EXT_EXTREF) + ref_cnt = mb->m_ext.ref_cnt; + _mext_init_ref(mb, ref_cnt); if (mb->m_ext.ref_cnt != NULL) { mb->m_flags |= (M_EXT | flags); mb->m_ext.ext_buf = buf; |