Date: Thu, 15 Aug 2013 00:17:31 +0000 (UTC) From: Navdeep Parhar <np@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r254345 - user/np/cxl_tuning/sys/sys Message-ID: <201308150017.r7F0HVgl037893@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: np Date: Thu Aug 15 00:17:31 2013 New Revision: 254345 URL: http://svnweb.freebsd.org/changeset/base/254345 Log: Add a helper for attaching an mbuf to a buffer with an external refcount. This one is willing to work with buffers that may already be referenced. MEXTADD/m_extadd are suitable only for the first attachment to a cluster -- they initialize the refcount to 1. Modified: user/np/cxl_tuning/sys/sys/mbuf.h Modified: user/np/cxl_tuning/sys/sys/mbuf.h ============================================================================== --- user/np/cxl_tuning/sys/sys/mbuf.h Thu Aug 15 00:13:25 2013 (r254344) +++ user/np/cxl_tuning/sys/sys/mbuf.h Thu Aug 15 00:17:31 2013 (r254345) @@ -396,6 +396,28 @@ m_gettype(int size) return (type); } +/* + * Associated an external reference counted buffer with an mbuf. + */ +static __inline void +m_extaddref(struct mbuf *m, caddr_t buf, u_int size, u_int *ref_cnt, + void (*freef)(void *, void *), void *arg1, void *arg2) +{ + + KASSERT(ref_cnt != NULL, ("%s: ref_cnt not provided", __func__)); + + atomic_add_int(ref_cnt, 1); + m->m_flags |= M_EXT; + m->m_ext.ext_buf = buf; + m->m_ext.ref_cnt = ref_cnt; + m->m_data = m->m_ext.ext_buf; + m->m_ext.ext_size = size; + m->m_ext.ext_free = freef; + m->m_ext.ext_arg1 = arg1; + m->m_ext.ext_arg2 = arg2; + m->m_ext.ext_type = EXT_EXTREF; +} + static __inline uma_zone_t m_getzone(int size) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308150017.r7F0HVgl037893>