Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Jun 2009 17:59:05 +0000 (UTC)
From:      Alan Cox <alc@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r194454 - head/sys/kern
Message-ID:  <200906181759.n5IHx5EL018751@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: alc
Date: Thu Jun 18 17:59:04 2009
New Revision: 194454
URL: http://svn.freebsd.org/changeset/base/194454

Log:
  Utilize the new function kmem_alloc_contig() to implement the UMA back-end
  allocator for the jumbo frames zones.  This change has two benefits: (1) a
  custom back-end deallocator is no longer required.  UMA's standard
  deallocator suffices. (2) It eliminates a potentially confusing artifact
  of using contigmalloc(): The malloc(9) statistics contain bogus information
  about the usage of jumbo frames.  Specifically, the malloc(9) statistics
  report all jumbo frames in use whereas the UMA zone statistics report the
  "truth" about the number in use vs. the number free.

Modified:
  head/sys/kern/kern_mbuf.c

Modified: head/sys/kern/kern_mbuf.c
==============================================================================
--- head/sys/kern/kern_mbuf.c	Thu Jun 18 17:44:42 2009	(r194453)
+++ head/sys/kern/kern_mbuf.c	Thu Jun 18 17:59:04 2009	(r194454)
@@ -44,6 +44,8 @@ __FBSDID("$FreeBSD$");
 #include <security/mac/mac_framework.h>
 
 #include <vm/vm.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_kern.h>
 #include <vm/vm_page.h>
 #include <vm/uma.h>
 #include <vm/uma_int.h>
@@ -232,9 +234,6 @@ 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);
@@ -296,7 +295,6 @@ mbuf_init(void *dummy)
 	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,
@@ -309,7 +307,6 @@ mbuf_init(void *dummy)
 	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,
@@ -358,18 +355,8 @@ mbuf_jumbo_alloc(uma_zone_t zone, int by
 
 	/* Inform UMA that this allocator uses kernel_map/object. */
 	*flags = UMA_SLAB_KERNEL;
-	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);
+	return ((void *)kmem_alloc_contig(kernel_map, bytes, wait,
+	    (vm_paddr_t)0, ~(vm_paddr_t)0, 1, 0));
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906181759.n5IHx5EL018751>