Author: andre
Date: Sat Aug 24 13:15:42 2013
New Revision: 254780
URL: http://svnweb.freebsd.org/changeset/base/254780
Log:
dd a 24 bits wide ext_flags field to m_ext by reducing ext_type
to 8 bits. ext_type is an enumerator and the number of types we
have is a mere dozen.
A couple of ext_types are renumbered to fit within 8 bits.
EXT_VENDOR[1-4] and EXT_EXP[1-4] types for vendor-internal and
experimental local mapping.
The ext_flags field is currently unused but has a couple of flags
already defined for future use. Again vendor and experimental
flags are provided for local mapping.
EXT_FLAG_BITS is provided for the printf(9) %b identifier.
Initialize and copy ext_flags in the relevant mbuf functions.
Improve alignment and packing of struct m_ext on 32 and 64 archs
by carefully sorting the fields.
Modified:
head/sys/kern/kern_mbuf.c
head/sys/kern/uipc_mbuf.c
head/sys/sys/mbuf.h
Modified: head/sys/kern/kern_mbuf.c
==
--- head/sys/kern/kern_mbuf.c Sat Aug 24 12:24:58 2013(r254779)
+++ head/sys/kern/kern_mbuf.c Sat Aug 24 13:15:42 2013(r254780)
@@ -547,6 +547,7 @@ mb_ctor_clust(void *mem, int size, void
m->m_ext.ext_arg2 = NULL;
m->m_ext.ext_size = size;
m->m_ext.ext_type = type;
+ m->m_ext.ext_flags = 0;
m->m_ext.ref_cnt = refcnt;
}
Modified: head/sys/kern/uipc_mbuf.c
==
--- head/sys/kern/uipc_mbuf.c Sat Aug 24 12:24:58 2013(r254779)
+++ head/sys/kern/uipc_mbuf.c Sat Aug 24 13:15:42 2013(r254780)
@@ -267,6 +267,7 @@ m_extadd(struct mbuf *mb, caddr_t buf, u
mb->m_ext.ext_arg1 = arg1;
mb->m_ext.ext_arg2 = arg2;
mb->m_ext.ext_type = type;
+ mb->m_ext.ext_flags = 0;
return (0);
}
@@ -342,6 +343,7 @@ mb_free_ext(struct mbuf *m)
m->m_ext.ref_cnt = NULL;
m->m_ext.ext_size = 0;
m->m_ext.ext_type = 0;
+ m->m_ext.ext_flags = 0;
m->m_flags &= ~M_EXT;
uma_zfree(zone_mbuf, m);
}
@@ -368,6 +370,7 @@ mb_dupcl(struct mbuf *n, struct mbuf *m)
n->m_ext.ext_size = m->m_ext.ext_size;
n->m_ext.ref_cnt = m->m_ext.ref_cnt;
n->m_ext.ext_type = m->m_ext.ext_type;
+ n->m_ext.ext_flags = m->m_ext.ext_flags;
n->m_flags |= M_EXT;
n->m_flags |= m->m_flags & M_RDONLY;
}
Modified: head/sys/sys/mbuf.h
==
--- head/sys/sys/mbuf.h Sat Aug 24 12:24:58 2013(r254779)
+++ head/sys/sys/mbuf.h Sat Aug 24 13:15:42 2013(r254780)
@@ -138,16 +138,19 @@ struct pkthdr {
/*
* Description of external storage mapped into mbuf; valid only if M_EXT is
* set.
+ * Size ILP32: 28
+ * LP64: 48
*/
struct m_ext {
+ volatile u_int *ref_cnt; /* pointer to ref count info */
caddr_t ext_buf; /* start of buffer */
+ uint32_t ext_size; /* size of buffer, for ext_free */
+ uint32_t ext_type:8,/* type of external storage */
+ext_flags:24; /* external storage mbuf flags */
void(*ext_free) /* free routine if not the usual */
(void *, void *);
void*ext_arg1; /* optional argument pointer */
void*ext_arg2; /* optional argument pointer */
- u_intext_size; /* size of buffer, for ext_free */
- volatile u_int *ref_cnt; /* pointer to ref count info */
- int ext_type; /* type of external storage */
};
/*
@@ -269,7 +272,7 @@ struct mbuf {
M_PROTOFLAGS|M_HASHTYPEBITS)
/*
- * External buffer types: identify ext_buf type.
+ * External mbuf storage buffer types.
*/
#defineEXT_CLUSTER 1 /* mbuf cluster */
#defineEXT_SFBUF 2 /* sendfile(2)'s sf_bufs */
@@ -278,10 +281,48 @@ struct mbuf {
#defineEXT_JUMBO16 5 /* jumbo cluster 16184 bytes */
#defineEXT_PACKET 6 /* mbuf+cluster from packet zone */
#defineEXT_MBUF7 /* external mbuf reference (M_IOVEC) */
-#defineEXT_NET_DRV 100 /* custom ext_buf provided by net
driver(s) */
-#defineEXT_MOD_TYPE200 /* custom module's ext_buf type */
-#defineEXT_DISPOSABLE 300 /* can throw this buffer away w/page
flipping */
-#defineEXT_EXTREF 400 /* has externally maintained ref_cnt
ptr */
+
+#defineEXT_VENDOR1 224 /* for vendor-internal use */
+#defineEXT_VENDOR2 225 /* for vendor-internal use */
+#defineEXT_VENDOR3 226 /* for vendor-internal use */
+#defineEXT_VENDOR4 227 /* for vendor-internal use