Date: Sun, 5 Feb 2006 21:48:46 GMT From: Alan Cox <alc@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 91189 for review Message-ID: <200602052148.k15Lmkem077449@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=91189 Change 91189 by alc@alc_home on 2006/02/05 21:48:15 A contiguity-aware reimplementation of uma_small_alloc(). This improves performance by reducing the number of 2MB page TLB misses for heap allocated data accessed through the direct map. Affected files ... .. //depot/projects/superpages/src/sys/amd64/amd64/uma_machdep.c#2 edit Differences ... ==== //depot/projects/superpages/src/sys/amd64/amd64/uma_machdep.c#2 (text+ko) ==== @@ -28,10 +28,12 @@ __FBSDID("$FreeBSD: src/sys/amd64/amd64/uma_machdep.c,v 1.1 2003/10/14 05:51:31 alc Exp $"); #include <sys/param.h> +#include <sys/kernel.h> #include <sys/lock.h> #include <sys/mutex.h> #include <sys/systm.h> #include <vm/vm.h> +#include <vm/vm_object.h> #include <vm/vm_page.h> #include <vm/vm_pageout.h> #include <vm/uma.h> @@ -39,11 +41,29 @@ #include <machine/md_var.h> #include <machine/vmparam.h> +static struct vm_object uma_small_object_store; + +static void uma_small_init(void *notused); +SYSINIT(uma_small, SI_SUB_VM, SI_ORDER_SECOND, uma_small_init, NULL) + +static void +uma_small_init(void *notused) +{ + vm_object_t object; + + object = &uma_small_object_store; + VM_OBJECT_LOCK_INIT(object, "uma small object"); + _vm_object_allocate(OBJT_DEFAULT, cnt.v_page_count, object); + object->pg_color = 0; + vm_object_set_flag(object, OBJ_SUPERPAGES); +} + void * uma_small_alloc(uma_zone_t zone, int bytes, u_int8_t *flags, int wait) { - static vm_pindex_t colour; + vm_object_t object; vm_page_t m; + vm_pindex_t pindex; void *va; int pflags; @@ -54,8 +74,12 @@ pflags = VM_ALLOC_SYSTEM; if (wait & M_ZERO) pflags |= VM_ALLOC_ZERO; - for (;;) { - m = vm_page_alloc(NULL, colour++, pflags | VM_ALLOC_NOOBJ); + for (object = &uma_small_object_store;;) { + VM_OBJECT_LOCK(object); + m = TAILQ_LAST(&object->memq, pglist); + pindex = m != NULL ? m->pindex + 1 : 0; + m = vm_page_alloc(object, pindex, pflags); + VM_OBJECT_UNLOCK(object); if (m == NULL) { if (wait & M_NOWAIT) return (NULL); @@ -73,10 +97,14 @@ void uma_small_free(void *mem, int size, u_int8_t flags) { + vm_object_t object; vm_page_t m; + object = &uma_small_object_store; m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)mem)); + VM_OBJECT_LOCK(object); vm_page_lock_queues(); vm_page_free(m); vm_page_unlock_queues(); + VM_OBJECT_UNLOCK(object); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200602052148.k15Lmkem077449>