diff options
-rw-r--r-- | sys/kern/subr_extent.c | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/sys/kern/subr_extent.c b/sys/kern/subr_extent.c index ca58df7d879..1b879c6755c 100644 --- a/sys/kern/subr_extent.c +++ b/sys/kern/subr_extent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_extent.c,v 1.17 2001/07/26 14:34:43 art Exp $ */ +/* $OpenBSD: subr_extent.c,v 1.18 2001/08/06 11:19:26 art Exp $ */ /* $NetBSD: subr_extent.c,v 1.7 1996/11/21 18:46:34 cgd Exp $ */ /*- @@ -49,6 +49,7 @@ #include <sys/systm.h> #include <sys/proc.h> #include <sys/queue.h> +#include <sys/pool.h> #include <ddb/db_output.h> #else /* @@ -104,6 +105,20 @@ extent_register(ex) LIST_INSERT_HEAD(ext_listp, ex, ex_link); } +struct pool ex_region_pl; + +static void +extent_pool_init(void) +{ + static int inited; + + if (!inited) { + pool_init(&ex_region_pl, sizeof(struct extent_region), 0, 0, 0, + "extentpl", 0, 0, 0, 0); + inited = 1; + } +} + /* * Find a given extent, and return a pointer to * it so that other extent functions can be used @@ -175,6 +190,8 @@ extent_create(name, start, end, mtype, storage, storagesize, flags) panic("extent_create: storage provided for non-fixed"); #endif + extent_pool_init(); + /* Allocate extent descriptor. */ if (fixed_extent) { struct extent_fixed *fex; @@ -1002,6 +1019,7 @@ extent_alloc_region_descriptor(ex, flags) int flags; { struct extent_region *rp; + int s; if (ex->ex_flags & EXF_FIXED) { struct extent_fixed *fex = (struct extent_fixed *)ex; @@ -1032,10 +1050,9 @@ extent_alloc_region_descriptor(ex, flags) } alloc: - rp = (struct extent_region *) - malloc(sizeof(struct extent_region), ex->ex_mtype, - (flags & EX_WAITOK) ? M_WAITOK : M_NOWAIT); - + s = splimp(); + rp = pool_get(&ex_region_pl, (flags & EX_WAITOK) ? PR_WAITOK : 0); + splx(s); if (rp != NULL) rp->er_flags = ER_ALLOC; @@ -1047,6 +1064,7 @@ extent_free_region_descriptor(ex, rp) struct extent *ex; struct extent_region *rp; { + int s; if (ex->ex_flags & EXF_FIXED) { struct extent_fixed *fex = (struct extent_fixed *)ex; @@ -1064,7 +1082,9 @@ extent_free_region_descriptor(ex, rp) er_link); goto wake_em_up; } else { - free(rp, ex->ex_mtype); + s = splimp(); + pool_put(&ex_region_pl, rp); + splx(s); } } else { /* Clear all flags. */ @@ -1083,7 +1103,9 @@ extent_free_region_descriptor(ex, rp) /* * We know it's dynamically allocated if we get here. */ - free(rp, ex->ex_mtype); + s = splimp(); + pool_put(&ex_region_pl, rp); + splx(s); } #ifndef DDB |