summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2004-06-02 22:17:23 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2004-06-02 22:17:23 +0000
commit1f21de0d02150532aaca3efc3165ce34e077f149 (patch)
tree7f9cae38d957c2a6db60dad3b838e0e657d63ff2
parent5a39fe414db9196464fc4176ea67c2fd7c2701d6 (diff)
rearrange the allocators we provide for general use.
the new one remains the default and _nointr. _kmem is restored to its former position, and _oldnointr is introduced. this is to allow some pool users who don't like the new allocator to continue working. testing/ok beck@ cedric@
-rw-r--r--sys/kern/subr_pool.c51
-rw-r--r--sys/sys/pool.h11
2 files changed, 41 insertions, 21 deletions
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c
index 67ec10797d4..e9114b34990 100644
--- a/sys/kern/subr_pool.c
+++ b/sys/kern/subr_pool.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_pool.c,v 1.40 2004/05/27 04:55:27 tedu Exp $ */
+/* $OpenBSD: subr_pool.c,v 1.41 2004/06/02 22:17:22 tedu Exp $ */
/* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */
/*-
@@ -397,7 +397,7 @@ pool_init(struct pool *pp, size_t size, u_int align, u_int ioff, int flags,
* Check arguments and construct default values.
*/
if (palloc == NULL)
- palloc = &pool_allocator_kmem;
+ palloc = &pool_allocator_nointr;
if ((palloc->pa_flags & PA_INITIALIZED) == 0) {
if (palloc->pa_pagesz == 0)
palloc->pa_pagesz = PAGE_SIZE;
@@ -1933,22 +1933,26 @@ sysctl_dopool(int *name, u_int namelen, char *where, size_t *sizep)
*
* Each pool has a backend allocator that handles allocation, deallocation
* and any additional draining that might be needed.
- *
- * We provide two standard allocators.
- * pool_alloc_kmem - the default used when no allocator is specified.
- * pool_alloc_nointr - used for pools that will not be accessed in
- * interrupt context.
*/
+void *pool_page_alloc_kmem(struct pool *, int);
+void pool_page_free_kmem(struct pool *, void *);
+void *pool_page_alloc_oldnointr(struct pool *, int);
+void pool_page_free_oldnointr(struct pool *, void *);
void *pool_page_alloc(struct pool *, int);
void pool_page_free(struct pool *, void *);
-void *pool_page_alloc_nointr(struct pool *, int);
-void pool_page_free_nointr(struct pool *, void *);
+/* old default allocator, interrupt safe */
struct pool_allocator pool_allocator_kmem = {
- pool_page_alloc, pool_page_free, 0,
+ pool_page_alloc_kmem, pool_page_free_kmem, 0,
+};
+/* previous nointr. handles large allocations safely */
+struct pool_allocator pool_allocator_oldnointr = {
+ pool_page_alloc_oldnointr, pool_page_free_oldnointr, 0,
};
+/* safe for interrupts, name preserved for compat
+ * this is the default allocator */
struct pool_allocator pool_allocator_nointr = {
- pool_page_alloc_nointr, pool_page_free_nointr, 0,
+ pool_page_alloc, pool_page_free, 0,
};
/*
@@ -2092,19 +2096,36 @@ pool_page_free(struct pool *pp, void *v)
}
void *
-pool_page_alloc_nointr(struct pool *pp, int flags)
+pool_page_alloc_kmem(struct pool *pp, int flags)
+{
+ boolean_t waitok = (flags & PR_WAITOK) ? TRUE : FALSE;
+
+ return ((void *)uvm_km_alloc_poolpage1(kmem_map, uvmexp.kmem_object,
+ waitok));
+}
+
+void
+pool_page_free_kmem(struct pool *pp, void *v)
+{
+
+ uvm_km_free_poolpage1(kmem_map, (vaddr_t)v);
+}
+
+void *
+pool_page_alloc_oldnointr(struct pool *pp, int flags)
{
boolean_t waitok = (flags & PR_WAITOK) ? TRUE : FALSE;
splassert(IPL_NONE);
- return (uvm_km_getpage(waitok));
+ return ((void *)uvm_km_alloc_poolpage1(kernel_map, uvm.kernel_object,
+ waitok));
}
void
-pool_page_free_nointr(struct pool *pp, void *v)
+pool_page_free_oldnointr(struct pool *pp, void *v)
{
splassert(IPL_NONE);
- uvm_km_putpage(v);
+ uvm_km_free_poolpage1(kernel_map, (vaddr_t)v);
}
diff --git a/sys/sys/pool.h b/sys/sys/pool.h
index 37c8473da76..cdf7c226ee1 100644
--- a/sys/sys/pool.h
+++ b/sys/sys/pool.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pool.h,v 1.15 2003/11/18 06:08:18 tedu Exp $ */
+/* $OpenBSD: pool.h,v 1.16 2004/06/02 22:17:22 tedu Exp $ */
/* $NetBSD: pool.h,v 1.27 2001/06/06 22:00:17 rafal Exp $ */
/*-
@@ -188,12 +188,11 @@ struct pool {
};
#ifdef _KERNEL
-/*
- * Alternate pool page allocator, provided for pools that know they
- * will never be accessed in interrupt context.
- */
+/* old nointr allocator, still needed for large allocations */
+extern struct pool_allocator pool_allocator_oldnointr;
+/* interrupt safe (name preserved for compat) new default allocator */
extern struct pool_allocator pool_allocator_nointr;
-/* Standard pool allocator, provided here for reference. */
+/* previous interrupt safe allocator, allocates from kmem */
extern struct pool_allocator pool_allocator_kmem;
int pool_allocator_drain(struct pool_allocator *, struct pool *,