svn commit: r256296 - in user/andre/mbuf_staging: kern sys
Andre Oppermann
andre at FreeBSD.org
Thu Oct 10 20:06:35 UTC 2013
Author: andre
Date: Thu Oct 10 20:06:34 2013
New Revision: 256296
URL: http://svnweb.freebsd.org/changeset/base/256296
Log:
Internalize the various mbuf and cluster UMA zones into kern/kern_mbuf.c.
De-inline m_free() as well.
There is some fallout in dev/cxgb, dev/cxgbe and dev/sfxge who (ab)use
the current (non-)API to some extent. I still have to look at them in
details to determine if one of the existing APIs can be used instead or
if a new allocator function is necessary.
Modified:
user/andre/mbuf_staging/kern/kern_mbuf.c
user/andre/mbuf_staging/sys/mbuf.h
Modified: user/andre/mbuf_staging/kern/kern_mbuf.c
==============================================================================
--- user/andre/mbuf_staging/kern/kern_mbuf.c Thu Oct 10 20:03:54 2013 (r256295)
+++ user/andre/mbuf_staging/kern/kern_mbuf.c Thu Oct 10 20:06:34 2013 (r256296)
@@ -97,6 +97,17 @@ __FBSDID("$FreeBSD$");
*
*/
+/*
+ * Zones from which we allocate.
+ */
+uma_zone_t zone_mbuf;
+uma_zone_t zone_clust;
+uma_zone_t zone_pack;
+uma_zone_t zone_jumbop;
+uma_zone_t zone_jumbo9;
+uma_zone_t zone_jumbo16;
+uma_zone_t zone_ext_refcnt;
+
int nmbufs; /* limits number of mbufs */
int nmbclusters; /* limits number of mbuf clusters */
int nmbjumbop; /* limits number of page size jumbo clusters */
@@ -108,6 +119,8 @@ static quad_t maxmbufmem; /* overall rea
SYSCTL_QUAD(_kern_ipc, OID_AUTO, maxmbufmem, CTLFLAG_RDTUN, &maxmbufmem, 0,
"Maximum real memory allocatable to various mbuf types");
+static uma_zone_t m_getzone(int);
+
/*
* tunable_mbinit() has to be run before any mbuf allocations are done.
*/
@@ -261,17 +274,6 @@ SYSCTL_PROC(_kern_ipc, OID_AUTO, nmbufs,
"Maximum number of mbufs allowed");
/*
- * Zones from which we allocate.
- */
-uma_zone_t zone_mbuf;
-uma_zone_t zone_clust;
-uma_zone_t zone_pack;
-uma_zone_t zone_jumbop;
-uma_zone_t zone_jumbo9;
-uma_zone_t zone_jumbo16;
-uma_zone_t zone_ext_refcnt;
-
-/*
* Local prototypes.
*/
static int mb_ctor_mbuf(void *, int, void *, int);
@@ -640,7 +642,7 @@ mb_ctor_pack(void *mem, int size, void *
return (error);
}
-uma_zone_t
+static uma_zone_t
m_getzone(int size)
{
uma_zone_t zone;
@@ -979,6 +981,20 @@ m_getm2(struct mbuf *m, int len, int how
return (m);
}
+struct mbuf *
+m_free(struct mbuf *m)
+{
+ struct mbuf *n = m->m_next;
+
+ if ((m->m_flags & (M_PKTHDR|M_NOFREE)) == (M_PKTHDR|M_NOFREE))
+ m_tag_delete_chain(m, NULL);
+ if (m->m_flags & M_EXT)
+ mb_free_ext(m);
+ else if ((m->m_flags & M_NOFREE) == 0)
+ uma_zfree(zone_mbuf, m);
+ return (n);
+}
+
/*
* Free an entire chain of mbufs and associated external buffers, if
* applicable.
Modified: user/andre/mbuf_staging/sys/mbuf.h
==============================================================================
--- user/andre/mbuf_staging/sys/mbuf.h Thu Oct 10 20:03:54 2013 (r256295)
+++ user/andre/mbuf_staging/sys/mbuf.h Thu Oct 10 20:06:34 2013 (r256296)
@@ -502,25 +502,13 @@ struct mbuf {
#endif
/*
- * Network buffer allocation API
- *
- * The rest of it is defined in kern/kern_mbuf.c
+ * Network buffer allocation API is defined in kern/kern_mbuf.c
*/
-extern uma_zone_t zone_mbuf;
-extern uma_zone_t zone_clust;
-extern uma_zone_t zone_pack;
-extern uma_zone_t zone_jumbop;
-extern uma_zone_t zone_jumbo9;
-extern uma_zone_t zone_jumbo16;
-extern uma_zone_t zone_ext_refcnt;
-
void mb_free_ext(struct mbuf *);
int m_pkthdr_init(struct mbuf *, int);
-uma_zone_t m_getzone(int size);
int m_gettype(int);
void m_extaddref(struct mbuf *, caddr_t, u_int, u_int *,
int (*)(struct mbuf *, void *, void *), void *, void *);
-uma_zone_t m_getzone(int);
int m_init(struct mbuf *, uma_zone_t, int, int, short, int);
struct mbuf *m_get(int, short);
struct mbuf *m_getclr(int, short);
@@ -719,6 +707,7 @@ struct mbuf *m_dup(struct mbuf *, int);
int m_dup_pkthdr(struct mbuf *, struct mbuf *, int);
u_int m_fixhdr(struct mbuf *);
struct mbuf *m_fragment(struct mbuf *, int, int);
+struct mbuf *m_free(struct mbuf *);
void m_freem(struct mbuf *);
struct mbuf *m_get2(int, int, short, int);
struct mbuf *m_getjcl(int, short, int, int);
@@ -917,20 +906,6 @@ m_tag_find(struct mbuf *m, int type, str
m_tag_locate(m, MTAG_ABI_COMPAT, type, start));
}
-static __inline struct mbuf *
-m_free(struct mbuf *m)
-{
- struct mbuf *n = m->m_next;
-
- if ((m->m_flags & (M_PKTHDR|M_NOFREE)) == (M_PKTHDR|M_NOFREE))
- m_tag_delete_chain(m, NULL);
- if (m->m_flags & M_EXT)
- mb_free_ext(m);
- else if ((m->m_flags & M_NOFREE) == 0)
- uma_zfree(zone_mbuf, m);
- return (n);
-}
-
static int inline
rt_m_getfib(struct mbuf *m)
{
More information about the svn-src-user
mailing list