summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/vm/uma_core.c22
-rw-r--r--sys/vm/uma_int.h8
2 files changed, 28 insertions, 2 deletions
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index 18e9442..8864150 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -81,6 +81,8 @@
#include <vm/uma_int.h>
#include <vm/uma_dbg.h>
+#include <machine/vmparam.h>
+
/*
* This is the zone from which all zones are spawned. The idea is that even
* the zone heads are allocated from the allocator, so we use the bss section
@@ -633,10 +635,17 @@ finished:
if (zone->uz_flags & UMA_ZFLAG_OFFPAGE)
uma_zfree_internal(slabzone, slab, NULL, 0);
- if (zone->uz_flags & UMA_ZFLAG_MALLOC)
+ if (zone->uz_flags & UMA_ZFLAG_MALLOC) {
+ vm_object_t obj;
+
+ if (flags & UMA_SLAB_KMEM)
+ obj = kmem_object;
+ else
+ obj = NULL;
for (i = 0; i < zone->uz_ppera; i++)
vsetobj((vm_offset_t)mem + (i * PAGE_SIZE),
- kmem_object);
+ obj);
+ }
#ifdef UMA_DEBUG
printf("%s: Returning %d bytes.\n",
zone->uz_name, UMA_SLAB_SIZE * zone->uz_ppera);
@@ -1005,6 +1014,12 @@ zone_ctor(void *mem, int size, void *udata)
zone_large_init(zone);
else
zone_small_init(zone);
+#ifdef UMA_MD_SMALL_ALLOC
+ if (zone->uz_ppera == 1) {
+ zone->uz_allocf = uma_small_alloc;
+ zone->uz_freef = uma_small_free;
+ }
+#endif /* UMA_MD_SMALL_ALLOC */
if (arg->flags & UMA_ZONE_MTXCLASS)
privlc = 1;
@@ -1228,6 +1243,9 @@ uma_startup(void *bootmem)
NULL, NULL, NULL, NULL,
UMA_ALIGN_PTR, UMA_ZONE_INTERNAL);
+#ifdef UMA_MD_SMALL_ALLOC
+ booted = 1;
+#endif
#ifdef UMA_DEBUG
printf("UMA startup complete.\n");
diff --git a/sys/vm/uma_int.h b/sys/vm/uma_int.h
index 77082d3..ce4054f 100644
--- a/sys/vm/uma_int.h
+++ b/sys/vm/uma_int.h
@@ -374,4 +374,12 @@ vsetobj(vm_offset_t va, vm_object_t obj)
p->flags &= ~PG_SLAB;
}
+/*
+ * The following two functions may be defined by architecture specific code
+ * if they can provide more effecient allocation functions. This is useful
+ * for using direct mapped addresses.
+ */
+void *uma_small_alloc(uma_zone_t zone, int bytes, u_int8_t *pflag, int wait);
+void uma_small_free(void *mem, int size, u_int8_t flags);
+
#endif /* VM_UMA_INT_H */
OpenPOWER on IntegriCloud