summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mbuf.c
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2007-12-04 07:06:08 +0000
committeralc <alc@FreeBSD.org>2007-12-04 07:06:08 +0000
commit200640eacfbecd3f053374044fbc0e1a7f39b99f (patch)
treeb347e67bd91752a0c5ff7e6d6c1916df2aa4cce1 /sys/kern/kern_mbuf.c
parent8327024837c0e102c20438c0aae9c8ea8d8d04de (diff)
downloadFreeBSD-src-200640eacfbecd3f053374044fbc0e1a7f39b99f.zip
FreeBSD-src-200640eacfbecd3f053374044fbc0e1a7f39b99f.tar.gz
Introduce an UMA backend page allocator for the jumbo frame zones that
allocates physically contiguous memory. MFC after: 3 months Requested and reviewed by: Kip Macy Tested by: Andrew Gallatin and Pyun YongHyeon
Diffstat (limited to 'sys/kern/kern_mbuf.c')
-rw-r--r--sys/kern/kern_mbuf.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c
index 1577305..492a1e3 100644
--- a/sys/kern/kern_mbuf.c
+++ b/sys/kern/kern_mbuf.c
@@ -166,6 +166,10 @@ static void mb_zfini_pack(void *, int);
static void mb_reclaim(void *);
static void mbuf_init(void *);
+static void *mbuf_jumbo_alloc(uma_zone_t, int, u_int8_t *, int);
+static void mbuf_jumbo_free(void *, int, u_int8_t);
+
+static MALLOC_DEFINE(M_JUMBOFRAME, "jumboframes", "mbuf jumbo frame buffers");
/* Ensure that MSIZE doesn't break dtom() - it must be a power of 2 */
CTASSERT((((MSIZE - 1) ^ MSIZE) + 1) >> 1 == MSIZE);
@@ -226,6 +230,8 @@ mbuf_init(void *dummy)
UMA_ALIGN_PTR, UMA_ZONE_REFCNT);
if (nmbjumbo9 > 0)
uma_zone_set_max(zone_jumbo9, nmbjumbo9);
+ uma_zone_set_allocf(zone_jumbo9, mbuf_jumbo_alloc);
+ uma_zone_set_freef(zone_jumbo9, mbuf_jumbo_free);
zone_jumbo16 = uma_zcreate(MBUF_JUMBO16_MEM_NAME, MJUM16BYTES,
mb_ctor_clust, mb_dtor_clust,
@@ -237,6 +243,8 @@ mbuf_init(void *dummy)
UMA_ALIGN_PTR, UMA_ZONE_REFCNT);
if (nmbjumbo16 > 0)
uma_zone_set_max(zone_jumbo16, nmbjumbo16);
+ uma_zone_set_allocf(zone_jumbo16, mbuf_jumbo_alloc);
+ uma_zone_set_freef(zone_jumbo16, mbuf_jumbo_free);
zone_ext_refcnt = uma_zcreate(MBUF_EXTREFCNT_MEM_NAME, sizeof(u_int),
NULL, NULL,
@@ -274,6 +282,31 @@ mbuf_init(void *dummy)
}
/*
+ * UMA backend page allocator for the jumbo frame zones.
+ *
+ * Allocates kernel virtual memory that is backed by contiguous physical
+ * pages.
+ */
+static void *
+mbuf_jumbo_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait)
+{
+
+ *flags = UMA_SLAB_PRIV;
+ return (contigmalloc(bytes, M_JUMBOFRAME, wait, (vm_paddr_t)0,
+ ~(vm_paddr_t)0, 1, 0));
+}
+
+/*
+ * UMA backend page deallocator for the jumbo frame zones.
+ */
+static void
+mbuf_jumbo_free(void *mem, int size, u_int8_t flags)
+{
+
+ contigfree(mem, size, M_JUMBOFRAME);
+}
+
+/*
* Constructor for Mbuf master zone.
*
* The 'arg' pointer points to a mb_args structure which
OpenPOWER on IntegriCloud