summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>2002-03-08 20:48:27 +0000
committerthorpej <thorpej@NetBSD.org>2002-03-08 20:48:27 +0000
commita180cee23b473847ef3a3bebc8e5c778b4bf97cd (patch)
treebaa8c819b3912e1cee37a1c058dd5c3070f76622 /sys
parent16510c2b023cc77a06b739e0808d3be74c428e29 (diff)
Pool deals fairly well with physical memory shortage, but it doesn't
deal with shortages of the VM maps where the backing pages are mapped (usually kmem_map). Try to deal with this: * Group all information about the backend allocator for a pool in a separate structure. The pool references this structure, rather than the individual fields. * Change the pool_init() API accordingly, and adjust all callers. * Link all pools using the same backend allocator on a list. * The backend allocator is responsible for waiting for physical memory to become available, but will still fail if it cannot callocate KVA space for the pages. If this happens, carefully drain all pools using the same backend allocator, so that some KVA space can be freed. * Change pool_reclaim() to indicate if it actually succeeded in freeing some pages, and use that information to make draining easier and more efficient. * Get rid of PR_URGENT. There was only one use of it, and it could be dealt with by the caller. From art@openbsd.org.
Diffstat (limited to 'sys')
-rw-r--r--sys/adosfs/advfsops.c7
-rw-r--r--sys/arch/alpha/alpha/pmap.c38
-rw-r--r--sys/arch/arm/arm32/pmap.c6
-rw-r--r--sys/arch/arm26/arm26/pmap.c6
-rw-r--r--sys/arch/cesfic/cesfic/pmap.c4
-rw-r--r--sys/arch/hp300/hp300/pmap.c4
-rw-r--r--sys/arch/i386/i386/pmap.c8
-rw-r--r--sys/arch/luna68k/luna68k/pmap.c4
-rw-r--r--sys/arch/mac68k/mac68k/iop.c6
-rw-r--r--sys/arch/mac68k/mac68k/pmap.c4
-rw-r--r--sys/arch/mips/mips/pmap.c20
-rw-r--r--sys/arch/mvme68k/mvme68k/pmap.c4
-rw-r--r--sys/arch/news68k/news68k/pmap.c4
-rw-r--r--sys/arch/pc532/pc532/pmap.c6
-rw-r--r--sys/arch/powerpc/ibm4xx/pmap.c5
-rw-r--r--sys/arch/powerpc/mpc6xx/pmap.c50
-rw-r--r--sys/arch/sgimips/hpc/sbic.c4
-rw-r--r--sys/arch/sh3/sh3/pmap.c4
-rw-r--r--sys/arch/sparc/sparc/pmap.c37
-rw-r--r--sys/arch/sparc64/sparc64/pmap.c5
-rw-r--r--sys/arch/sun2/sun2/pmap.c4
-rw-r--r--sys/arch/sun3/sun3/pmap.c4
-rw-r--r--sys/arch/sun3/sun3x/pmap.c4
-rw-r--r--sys/arch/x68k/x68k/pmap.c4
-rw-r--r--sys/arch/x86_64/x86_64/pmap.c6
-rw-r--r--sys/dev/ccd.c6
-rw-r--r--sys/dev/ic/ncr53c9x.c6
-rw-r--r--sys/dev/ic/wdc.c6
-rw-r--r--sys/dev/raidframe/rf_netbsdkintf.c6
-rw-r--r--sys/dev/rnd.c6
-rw-r--r--sys/dev/scsipi/scsipi_base.c6
-rw-r--r--sys/dev/vnd.c8
-rw-r--r--sys/filecorefs/filecore_node.c7
-rw-r--r--sys/isofs/cd9660/cd9660_node.c7
-rw-r--r--sys/kern/kern_descrip.c10
-rw-r--r--sys/kern/kern_malloc_debug.c6
-rw-r--r--sys/kern/kern_proc.c14
-rw-r--r--sys/kern/kern_sig.c6
-rw-r--r--sys/kern/subr_extent.c6
-rw-r--r--sys/kern/subr_pool.c446
-rw-r--r--sys/kern/sys_pipe.c7
-rw-r--r--sys/kern/tty.c6
-rw-r--r--sys/kern/uipc_mbuf.c28
-rw-r--r--sys/kern/uipc_socket.c6
-rw-r--r--sys/kern/vfs_bio.c7
-rw-r--r--sys/kern/vfs_cache.c7
-rw-r--r--sys/kern/vfs_init.c6
-rw-r--r--sys/kern/vfs_subr.c6
-rw-r--r--sys/msdosfs/msdosfs_denode.c7
-rw-r--r--sys/net/if_bridge.c6
-rw-r--r--sys/net/route.c8
-rw-r--r--sys/netinet/in_pcb.c6
-rw-r--r--sys/netinet/ip_flow.c6
-rw-r--r--sys/netinet/ip_input.c6
-rw-r--r--sys/netinet/tcp_input.c6
-rw-r--r--sys/netinet/tcp_subr.c6
-rw-r--r--sys/nfs/nfs_node.c8
-rw-r--r--sys/sys/pool.h69
-rw-r--r--sys/ufs/ext2fs/ext2fs_vfsops.c7
-rw-r--r--sys/ufs/ffs/ffs_softdep.c48
-rw-r--r--sys/ufs/ffs/ffs_vfsops.c6
-rw-r--r--sys/ufs/lfs/lfs_vfsops.c7
-rw-r--r--sys/uvm/uvm_amap.c7
-rw-r--r--sys/uvm/uvm_aobj.c9
-rw-r--r--sys/uvm/uvm_map.c12
-rw-r--r--sys/uvm/uvm_swap.c8
66 files changed, 607 insertions, 492 deletions
diff --git a/sys/adosfs/advfsops.c b/sys/adosfs/advfsops.c
index baa45373217..bf275e86ddb 100644
--- a/sys/adosfs/advfsops.c
+++ b/sys/adosfs/advfsops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: advfsops.c,v 1.50 2001/11/12 22:59:18 lukem Exp $ */
+/* $NetBSD: advfsops.c,v 1.51 2002/03/08 20:48:27 thorpej Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.50 2001/11/12 22:59:18 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.51 2002/03/08 20:48:27 thorpej Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -811,8 +811,7 @@ adosfs_init()
simple_lock_init(&adosfs_hashlock);
pool_init(&adosfs_node_pool, sizeof(struct anode), 0, 0, 0,
- "adosndpl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_ANODE);
+ "adosndpl", &pool_allocator_nointr);
}
void
diff --git a/sys/arch/alpha/alpha/pmap.c b/sys/arch/alpha/alpha/pmap.c
index 678478e5999..f2dccc50be2 100644
--- a/sys/arch/alpha/alpha/pmap.c
+++ b/sys/arch/alpha/alpha/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.190 2002/01/03 22:43:05 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.191 2002/03/08 20:48:28 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -154,7 +154,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.190 2002/01/03 22:43:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.191 2002/03/08 20:48:28 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -489,8 +489,12 @@ void pmap_l3pt_delref(pmap_t, vaddr_t, pt_entry_t *, long);
void pmap_l2pt_delref(pmap_t, pt_entry_t *, pt_entry_t *, long);
void pmap_l1pt_delref(pmap_t, pt_entry_t *, long);
-void *pmap_l1pt_alloc(unsigned long, int, int);
-void pmap_l1pt_free(void *, unsigned long, int);
+void *pmap_l1pt_alloc(struct pool *, int);
+void pmap_l1pt_free(struct pool *, void *);
+
+struct pool_allocator pmap_l1pt_allocator = {
+ pmap_l1pt_alloc, pmap_l1pt_free, 0,
+};
int pmap_l1pt_ctor(void *, void *, int);
@@ -500,8 +504,13 @@ int pmap_l1pt_ctor(void *, void *, int);
int pmap_pv_enter(pmap_t, struct vm_page *, vaddr_t, pt_entry_t *,
boolean_t);
void pmap_pv_remove(pmap_t, struct vm_page *, vaddr_t, boolean_t);
-void *pmap_pv_page_alloc(u_long, int, int);
-void pmap_pv_page_free(void *, u_long, int);
+void *pmap_pv_page_alloc(struct pool *, int);
+void pmap_pv_page_free(struct pool *, void *);
+
+struct pool_allocator pmap_pv_page_allocator = {
+ pmap_pv_page_alloc, pmap_pv_page_free, 0,
+};
+
#ifdef DEBUG
void pmap_pv_dump(paddr_t);
#endif
@@ -925,13 +934,13 @@ pmap_bootstrap(paddr_t ptaddr, u_int maxasn, u_long ncpuids)
pmap_ncpuids = ncpuids;
pool_init(&pmap_pmap_pool,
PMAP_SIZEOF(pmap_ncpuids), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
pool_init(&pmap_l1pt_pool, PAGE_SIZE, 0, 0, 0, "l1ptpl",
- 0, pmap_l1pt_alloc, pmap_l1pt_free, M_VMPMAP);
+ &pmap_l1pt_allocator);
pool_cache_init(&pmap_l1pt_cache, &pmap_l1pt_pool, pmap_l1pt_ctor,
NULL, NULL);
pool_init(&pmap_pv_pool, sizeof(struct pv_entry), 0, 0, 0, "pvpl",
- 0, pmap_pv_page_alloc, pmap_pv_page_free, M_VMPMAP);
+ &pmap_pv_page_allocator);
TAILQ_INIT(&pmap_all_pmaps);
@@ -973,8 +982,7 @@ pmap_bootstrap(paddr_t ptaddr, u_int maxasn, u_long ncpuids)
* Initialize the TLB shootdown queues.
*/
pool_init(&pmap_tlb_shootdown_job_pool,
- sizeof(struct pmap_tlb_shootdown_job), 0, 0, 0, "pmaptlbpl",
- 0, NULL, NULL, M_VMPMAP);
+ sizeof(struct pmap_tlb_shootdown_job), 0, 0, 0, "pmaptlbpl", NULL);
for (i = 0; i < ALPHA_MAXPROCS; i++) {
TAILQ_INIT(&pmap_tlb_shootdown_q[i].pq_head);
simple_lock_init(&pmap_tlb_shootdown_q[i].pq_slock);
@@ -2988,7 +2996,7 @@ pmap_pv_remove(pmap_t pmap, struct vm_page *pg, vaddr_t va, boolean_t dolock)
* Allocate a page for the pv_entry pool.
*/
void *
-pmap_pv_page_alloc(u_long size, int flags, int mtype)
+pmap_pv_page_alloc(struct pool *pp, int flags)
{
paddr_t pg;
@@ -3003,7 +3011,7 @@ pmap_pv_page_alloc(u_long size, int flags, int mtype)
* Free a pv_entry pool page.
*/
void
-pmap_pv_page_free(void *v, u_long size, int mtype)
+pmap_pv_page_free(struct pool *pp, void *v)
{
pmap_physpage_free(ALPHA_K0SEG_TO_PHYS((vaddr_t)v));
@@ -3367,7 +3375,7 @@ pmap_l1pt_ctor(void *arg, void *object, int flags)
* Page alloctor for L1 PT pages.
*/
void *
-pmap_l1pt_alloc(unsigned long sz, int flags, int mtype)
+pmap_l1pt_alloc(struct pool *pp, int flags)
{
paddr_t ptpa;
@@ -3386,7 +3394,7 @@ pmap_l1pt_alloc(unsigned long sz, int flags, int mtype)
* Page freer for L1 PT pages.
*/
void
-pmap_l1pt_free(void *v, unsigned long sz, int mtype)
+pmap_l1pt_free(struct pool *pp, void *v)
{
pmap_physpage_free(ALPHA_K0SEG_TO_PHYS((vaddr_t) v));
diff --git a/sys/arch/arm/arm32/pmap.c b/sys/arch/arm/arm32/pmap.c
index bcf7a8d1d1e..77c4bfd1244 100644
--- a/sys/arch/arm/arm32/pmap.c
+++ b/sys/arch/arm/arm32/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.51 2002/03/06 10:55:21 chris Exp $ */
+/* $NetBSD: pmap.c,v 1.52 2002/03/08 20:48:29 thorpej Exp $ */
/*
* Copyright (c) 2002 Wasabi Systems, Inc.
@@ -143,7 +143,7 @@
#include <machine/param.h>
#include <arm/arm32/katelib.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.51 2002/03/06 10:55:21 chris Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.52 2002/03/08 20:48:29 thorpej Exp $");
#ifdef PMAP_DEBUG
#define PDEBUG(_lev_,_stat_) \
if (pmap_debug_level >= (_lev_)) \
@@ -1150,7 +1150,7 @@ pmap_bootstrap(kernel_l1pt, kernel_ptpt)
*/
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
cpu_dcache_wbinv_all();
}
diff --git a/sys/arch/arm26/arm26/pmap.c b/sys/arch/arm26/arm26/pmap.c
index f99128566fa..87433cd62bb 100644
--- a/sys/arch/arm26/arm26/pmap.c
+++ b/sys/arch/arm26/arm26/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.36 2001/11/18 15:57:23 bjh21 Exp $ */
+/* $NetBSD: pmap.c,v 1.37 2002/03/08 20:48:30 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000 Ben Harris
* All rights reserved.
@@ -105,7 +105,7 @@
#include <sys/param.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.36 2001/11/18 15:57:23 bjh21 Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.37 2002/03/08 20:48:30 thorpej Exp $");
#include <sys/kernel.h> /* for cold */
#include <sys/malloc.h>
@@ -362,7 +362,7 @@ pmap_init2()
/* Create pmap pool */
pool_init(&pmap_pool, sizeof(struct pmap), 0, 0, 0,
- "pmappool", 0, NULL, NULL, M_VMPMAP);
+ "pmappool", NULL);
pmap_initialised = 1;
}
diff --git a/sys/arch/cesfic/cesfic/pmap.c b/sys/arch/cesfic/cesfic/pmap.c
index c862274f41f..fbf3edbfa0e 100644
--- a/sys/arch/cesfic/cesfic/pmap.c
+++ b/sys/arch/cesfic/cesfic/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.11 2002/01/02 00:51:34 chs Exp $ */
+/* $NetBSD: pmap.c,v 1.12 2002/03/08 20:48:30 thorpej Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -511,7 +511,7 @@ pmap_init()
* Initialize the pmap pools.
*/
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
/*
* Now it is safe to enable pv_table recording.
diff --git a/sys/arch/hp300/hp300/pmap.c b/sys/arch/hp300/hp300/pmap.c
index fac10c36438..b8e2332e118 100644
--- a/sys/arch/hp300/hp300/pmap.c
+++ b/sys/arch/hp300/hp300/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.103 2002/01/02 00:51:34 chs Exp $ */
+/* $NetBSD: pmap.c,v 1.104 2002/03/08 20:48:30 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -545,7 +545,7 @@ pmap_init()
* Initialize the pmap pools.
*/
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
/*
* Now it is safe to enable pv_table recording.
diff --git a/sys/arch/i386/i386/pmap.c b/sys/arch/i386/i386/pmap.c
index fabadd6a4a3..faa19575bde 100644
--- a/sys/arch/i386/i386/pmap.c
+++ b/sys/arch/i386/i386/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.133 2002/01/02 00:51:35 chs Exp $ */
+/* $NetBSD: pmap.c,v 1.134 2002/03/08 20:48:30 thorpej Exp $ */
/*
*
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.133 2002/01/02 00:51:35 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.134 2002/03/08 20:48:30 thorpej Exp $");
#include "opt_cputype.h"
#include "opt_user_ldt.h"
@@ -855,14 +855,14 @@ pmap_bootstrap(kva_start)
*/
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
/*
* initialize the PDE pool and cache.
*/
pool_init(&pmap_pdp_pool, PAGE_SIZE, 0, 0, 0, "pdppl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
pool_cache_init(&pmap_pdp_cache, &pmap_pdp_pool,
pmap_pdp_ctor, NULL, NULL);
diff --git a/sys/arch/luna68k/luna68k/pmap.c b/sys/arch/luna68k/luna68k/pmap.c
index ef23f331972..7d483270343 100644
--- a/sys/arch/luna68k/luna68k/pmap.c
+++ b/sys/arch/luna68k/luna68k/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.22 2002/01/02 00:51:35 chs Exp $ */
+/* $NetBSD: pmap.c,v 1.23 2002/03/08 20:48:31 thorpej Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -519,7 +519,7 @@ pmap_init()
* Initialize the pmap pools.
*/
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
/*
* Now it is safe to enable pv_table recording.
diff --git a/sys/arch/mac68k/mac68k/iop.c b/sys/arch/mac68k/mac68k/iop.c
index 7729ed455ff..1d6f4ec5585 100644
--- a/sys/arch/mac68k/mac68k/iop.c
+++ b/sys/arch/mac68k/mac68k/iop.c
@@ -1,4 +1,4 @@
-/* $NetBSD: iop.c,v 1.3 2000/07/30 21:48:55 briggs Exp $ */
+/* $NetBSD: iop.c,v 1.4 2002/03/08 20:48:31 thorpej Exp $ */
/*
* Copyright (c) 2000 Allen Briggs.
@@ -173,7 +173,7 @@ iop_init(fullinit)
ioph = iop->iop;
printf("SCC IOP base: 0x%x\n", (unsigned) ioph);
pool_init(&iop->pool, sizeof(struct iop_msg), 0, 0, 0, "mac68k_iop1",
- 0, NULL, NULL, M_DEVBUF);
+ NULL);
ioph->control_status = IOP_BYPASS;
iop = &mac68k_iops[ISM_IOP];
@@ -181,7 +181,7 @@ iop_init(fullinit)
printf("ISM IOP base: 0x%x, alive %x\n", (unsigned) ioph,
(unsigned) iop_alive(ioph));
pool_init(&iop->pool, sizeof(struct iop_msg), 0, 0, 0, "mac68k_iop2",
- 0, NULL, NULL, M_DEVBUF);
+ NULL);
iop_write1(ioph, IOP_ADDR_ALIVE, 0);
/*
diff --git a/sys/arch/mac68k/mac68k/pmap.c b/sys/arch/mac68k/mac68k/pmap.c
index 2e6bd21ce1f..710a0aaa270 100644
--- a/sys/arch/mac68k/mac68k/pmap.c
+++ b/sys/arch/mac68k/mac68k/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.85 2002/01/02 00:51:35 chs Exp $ */
+/* $NetBSD: pmap.c,v 1.86 2002/03/08 20:48:31 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -539,7 +539,7 @@ pmap_init()
* Initialize the pmap pools.
*/
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
/*
* Now it is safe to enable pv_table recording.
diff --git a/sys/arch/mips/mips/pmap.c b/sys/arch/mips/mips/pmap.c
index 07f4b53cce7..be6505bf408 100644
--- a/sys/arch/mips/mips/pmap.c
+++ b/sys/arch/mips/mips/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.140 2002/03/05 16:01:25 simonb Exp $ */
+/* $NetBSD: pmap.c,v 1.141 2002/03/08 20:48:32 thorpej Exp $ */
/*-
* Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.140 2002/03/05 16:01:25 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.141 2002/03/08 20:48:32 thorpej Exp $");
/*
* Manages physical address maps.
@@ -248,8 +248,12 @@ pt_entry_t *pmap_pte(pmap_t, vaddr_t);
/*
* PV table management functions.
*/
-void *pmap_pv_page_alloc(u_long, int, int);
-void pmap_pv_page_free(void *, u_long, int);
+void *pmap_pv_page_alloc(struct pool *, int);
+void pmap_pv_page_free(struct pool *, void *);
+
+struct pool_allocator pmap_pv_page_allocator = {
+ pmap_pv_page_alloc, pmap_pv_page_free, 0,
+};
#define pmap_pv_alloc() pool_get(&pmap_pv_pool, PR_NOWAIT)
#define pmap_pv_free(pv) pool_put(&pmap_pv_pool, (pv))
@@ -352,9 +356,9 @@ pmap_bootstrap()
* Initialize the pools.
*/
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
pool_init(&pmap_pv_pool, sizeof(struct pv_entry), 0, 0, 0, "pvpl",
- 0, pmap_pv_page_alloc, pmap_pv_page_free, M_VMPMAP);
+ &pmap_pv_page_allocator);
/*
* Initialize the kernel pmap.
@@ -2081,7 +2085,7 @@ pmap_remove_pv(pmap, va, pa)
* Allocate a page for the pv_entry pool.
*/
void *
-pmap_pv_page_alloc(u_long size, int flags, int mtype)
+pmap_pv_page_alloc(struct pool *pp, int flags)
{
struct vm_page *pg;
@@ -2098,7 +2102,7 @@ pmap_pv_page_alloc(u_long size, int flags, int mtype)
* Free a pv_entry pool page.
*/
void
-pmap_pv_page_free(void *v, u_long size, int mtype)
+pmap_pv_page_free(struct pool *pp, void *v)
{
uvm_pagefree(PHYS_TO_VM_PAGE(MIPS_KSEG0_TO_PHYS((vaddr_t)v)));
}
diff --git a/sys/arch/mvme68k/mvme68k/pmap.c b/sys/arch/mvme68k/mvme68k/pmap.c
index ac34a59760f..cd026e239e0 100644
--- a/sys/arch/mvme68k/mvme68k/pmap.c
+++ b/sys/arch/mvme68k/mvme68k/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.76 2002/01/02 00:51:36 chs Exp $ */
+/* $NetBSD: pmap.c,v 1.77 2002/03/08 20:48:32 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -532,7 +532,7 @@ pmap_init()
* Initialize the pmap pools.
*/
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
/*
* Now that this is done, mark the pages shared with the
diff --git a/sys/arch/news68k/news68k/pmap.c b/sys/arch/news68k/news68k/pmap.c
index 7f3d7cfe596..ff5c8f6b48b 100644
--- a/sys/arch/news68k/news68k/pmap.c
+++ b/sys/arch/news68k/news68k/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.28 2002/01/02 00:51:36 chs Exp $ */
+/* $NetBSD: pmap.c,v 1.29 2002/03/08 20:48:32 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -537,7 +537,7 @@ pmap_init()
* Initialize the pmap pools.
*/
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
/*
* Now it is safe to enable pv_table recording.
diff --git a/sys/arch/pc532/pc532/pmap.c b/sys/arch/pc532/pc532/pmap.c
index e15c430151d..46b937e0e76 100644
--- a/sys/arch/pc532/pc532/pmap.c
+++ b/sys/arch/pc532/pc532/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.67 2002/01/02 00:51:36 chs Exp $ */
+/* $NetBSD: pmap.c,v 1.68 2002/03/08 20:48:33 thorpej Exp $ */
/*
*
@@ -751,14 +751,14 @@ pmap_bootstrap(kva_start)
*/
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
/*
* initialize the PDE pool and cache.
*/
pool_init(&pmap_pdp_pool, PAGE_SIZE, 0, 0, 0, "pdppl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
pool_cache_init(&pmap_pdp_cache, &pmap_pdp_pool,
pmap_pdp_ctor, NULL, NULL);
diff --git a/sys/arch/powerpc/ibm4xx/pmap.c b/sys/arch/powerpc/ibm4xx/pmap.c
index c206739257e..7f7cd69113d 100644
--- a/sys/arch/powerpc/ibm4xx/pmap.c
+++ b/sys/arch/powerpc/ibm4xx/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.8 2001/11/26 23:26:33 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.9 2002/03/08 20:48:33 thorpej Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -521,8 +521,7 @@ pmap_init(void)
splx(s);
/* Setup a pool for additional pvlist structures */
- pool_init(&pv_pool, sizeof(struct pv_entry), 0, 0, 0, "pv_entry", 0,
- NULL, NULL, 0);
+ pool_init(&pv_pool, sizeof(struct pv_entry), 0, 0, 0, "pv_entry", NULL);
}
/*
diff --git a/sys/arch/powerpc/mpc6xx/pmap.c b/sys/arch/powerpc/mpc6xx/pmap.c
index 348165d21ee..f5683a1834c 100644
--- a/sys/arch/powerpc/mpc6xx/pmap.c
+++ b/sys/arch/powerpc/mpc6xx/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.37 2002/01/02 00:51:37 chs Exp $ */
+/* $NetBSD: pmap.c,v 1.38 2002/03/08 20:48:33 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -193,10 +193,19 @@ u_long pmap_upvop_maxfree;
u_long pmap_mpvop_free;
u_long pmap_mpvop_maxfree;
-STATIC void *pmap_pool_ualloc(unsigned long, int, int);
-STATIC void *pmap_pool_malloc(unsigned long, int, int);
-STATIC void pmap_pool_ufree(void *, unsigned long, int);
-STATIC void pmap_pool_mfree(void *, unsigned long, int);
+STATIC void *pmap_pool_ualloc(struct pool *, int);
+STATIC void *pmap_pool_malloc(struct pool *, int);
+
+STATIC void pmap_pool_ufree(struct pool *, void *);
+STATIC void pmap_pool_mfree(struct pool *, void *);
+
+static struct pool_allocator pmap_pool_mallocator = {
+ pmap_pool_malloc, pmap_pool_mfree, 0,
+};
+
+static struct pool_allocator pmap_pool_uallocator = {
+ pmap_pool_ualloc, pmap_pool_ufree, 0,
+};
#if defined(DEBUG) || defined(PMAPCHECK) || defined(DDB)
void pmap_pte_print(volatile pte_t *pt);
@@ -792,8 +801,8 @@ pmap_init(void)
s = splvm();
pool_init(&pmap_mpvo_pool, sizeof(struct pvo_entry),
- sizeof(struct pvo_entry), 0, 0, "pmap_mpvopl", NBPG,
- pmap_pool_malloc, pmap_pool_mfree, M_VMPMAP);
+ sizeof(struct pvo_entry), 0, 0, "pmap_mpvopl",
+ &pmap_pool_mallocator);
pool_setlowat(&pmap_mpvo_pool, 1008);
@@ -1454,8 +1463,6 @@ pmap_pvo_enter(pmap_t pm, struct pool *pl, struct pvo_head *pvo_head,
/*
* If we aren't overwriting an mapping, try to allocate
*/
- if ((flags & PMAP_CANFAIL) == 0)
- poolflags |= PR_URGENT;
pmap_interrupts_restore(msr);
pvo = pool_get(pl, poolflags);
msr = pmap_interrupts_off();
@@ -2321,13 +2328,10 @@ pmap_pvo_verify(void)
void *
-pmap_pool_ualloc(unsigned long size, int flags, int tag)
+pmap_pool_ualloc(struct pool *pp, int flags)
{
struct pvo_page *pvop;
- if (size != PAGE_SIZE)
- panic("pmap_pool_alloc: size(%lu) != PAGE_SIZE", size);
-
pvop = SIMPLEQ_FIRST(&pmap_upvop_head);
if (pvop != NULL) {
pmap_upvop_free--;
@@ -2337,18 +2341,15 @@ pmap_pool_ualloc(unsigned long size, int flags, int tag)
if (uvm.page_init_done != TRUE) {
return (void *) uvm_pageboot_alloc(PAGE_SIZE);
}
- return pmap_pool_malloc(size, flags, tag);
+ return pmap_pool_malloc(pp, flags);
}
void *
-pmap_pool_malloc(unsigned long size, int flags, int tag)
+pmap_pool_malloc(struct pool *pp, int flags)
{
struct pvo_page *pvop;
struct vm_page *pg;
- if (size != PAGE_SIZE)
- panic("pmap_pool_alloc: size(%lu) != PAGE_SIZE", size);
-
pvop = SIMPLEQ_FIRST(&pmap_mpvop_head);
if (pvop != NULL) {
pmap_mpvop_free--;
@@ -2370,7 +2371,7 @@ pmap_pool_malloc(unsigned long size, int flags, int tag)
}
void
-pmap_pool_ufree(void *va, unsigned long size, int tag)
+pmap_pool_ufree(struct pool *pp, void *va)
{
struct pvo_page *pvop;
#if 0
@@ -2387,11 +2388,9 @@ pmap_pool_ufree(void *va, unsigned long size, int tag)
}
void
-pmap_pool_mfree(void *va, unsigned long size, int tag)
+pmap_pool_mfree(struct pool *pp, void *va)
{
struct pvo_page *pvop;
- if (size != PAGE_SIZE)
- panic("pmap_pool_alloc: size(%lu) != PAGE_SIZE", size);
pvop = va;
SIMPLEQ_INSERT_HEAD(&pmap_mpvop_head, pvop, pvop_link);
@@ -2874,12 +2873,11 @@ pmap_bootstrap(paddr_t kernelstart, paddr_t kernelend)
#endif
pool_init(&pmap_upvo_pool, sizeof(struct pvo_entry),
- sizeof(struct pvo_entry), 0, 0, "pmap_upvopl", NBPG,
- pmap_pool_ualloc, pmap_pool_ufree, M_VMPMAP);
+ sizeof(struct pvo_entry), 0, 0, "pmap_upvopl",
+ &pmap_pool_uallocator);
pool_setlowat(&pmap_upvo_pool, 252);
pool_init(&pmap_pool, sizeof(struct pmap),
- sizeof(void *), 0, 0, "pmap_pl", NBPG,
- pmap_pool_ualloc, pmap_pool_ufree, M_VMPMAP);
+ sizeof(void *), 0, 0, "pmap_pl", &pmap_pool_uallocator);
}
diff --git a/sys/arch/sgimips/hpc/sbic.c b/sys/arch/sgimips/hpc/sbic.c
index f616f85c932..07ae4bcb939 100644
--- a/sys/arch/sgimips/hpc/sbic.c
+++ b/sys/arch/sgimips/hpc/sbic.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sbic.c,v 1.6 2002/02/11 10:44:39 wiz Exp $ */
+/* $NetBSD: sbic.c,v 1.7 2002/03/08 20:48:34 thorpej Exp $ */
/*
* Changes Copyright (c) 2001 Wayne Knowles
@@ -209,7 +209,7 @@ wd33c93_init(dev)
if (!wd33c93_pool_initialized) {
/* All instances share the same pool */
pool_init(&wd33c93_pool, sizeof(struct wd33c93_acb), 0, 0, 0,
- "wd33c93_acb", 0, NULL, NULL, 0);
+ "wd33c93_acb", NULL);
++wd33c93_pool_initialized;
}
diff --git a/sys/arch/sh3/sh3/pmap.c b/sys/arch/sh3/sh3/pmap.c
index cd32ce72bfd..87d1660c889 100644
--- a/sys/arch/sh3/sh3/pmap.c
+++ b/sys/arch/sh3/sh3/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.33 2002/02/17 20:55:57 uch Exp $ */
+/* $NetBSD: pmap.c,v 1.34 2002/03/08 20:48:34 thorpej Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -749,7 +749,7 @@ pmap_bootstrap(vaddr_t kva_start)
*/
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
/*
* we must call uvm_page_physload() after we are done playing with
diff --git a/sys/arch/sparc/sparc/pmap.c b/sys/arch/sparc/sparc/pmap.c
index 343f42ef69a..869ceef2b1e 100644
--- a/sys/arch/sparc/sparc/pmap.c
+++ b/sys/arch/sparc/sparc/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.205 2002/02/26 15:13:27 simonb Exp $ */
+/* $NetBSD: pmap.c,v 1.206 2002/03/08 20:48:34 thorpej Exp $ */
/*
* Copyright (c) 1996
@@ -359,8 +359,12 @@ u_int *kernel_pagtable_store; /* 128k of storage to map the kernel */
static struct pool L1_pool;
static struct pool L23_pool;
-static void *pgt_page_alloc __P((unsigned long, int, int));
-static void pgt_page_free __P((void *, unsigned long, int));
+static void *pgt_page_alloc __P((struct pool *, int));
+static void pgt_page_free __P((struct pool *, void *));
+
+static struct pool_allocator pgt_page_allocator = {
+ pgt_page_alloc, pgt_page_free, 0,
+};
#endif
@@ -886,10 +890,7 @@ setpte4m(va, pte)
* Page table pool back-end.
*/
void *
-pgt_page_alloc(sz, flags, mtype)
- unsigned long sz;
- int flags;
- int mtype;
+pgt_page_alloc(struct pool *pp, int flags)
{
int cacheit = (cpuinfo.flags & CPUFLG_CACHEPAGETABLES) != 0;
struct vm_page *pg;
@@ -926,10 +927,7 @@ pgt_page_alloc(sz, flags, mtype)
}
void
-pgt_page_free(v, sz, mtype)
- void *v;
- unsigned long sz;
- int mtype;
+pgt_page_free(struct pool *pp, void *v)
{
vaddr_t va;
paddr_t pa;
@@ -939,8 +937,8 @@ pgt_page_free(v, sz, mtype)
rv = pmap_extract(pmap_kernel(), va, &pa);
KASSERT(rv);
uvm_pagefree(PHYS_TO_VM_PAGE(pa));
- pmap_kremove(va, sz);
- uvm_km_free(kernel_map, va, sz);
+ pmap_kremove(va, PAGE_SIZE);
+ uvm_km_free(kernel_map, va, PAGE_SIZE);
}
#endif /* 4m only */
@@ -3778,8 +3776,7 @@ pmap_init()
vm_num_phys = vm_last_phys - vm_first_phys;
/* Setup a pool for additional pvlist structures */
- pool_init(&pv_pool, sizeof(struct pvlist), 0, 0, 0, "pvtable", 0,
- NULL, NULL, 0);
+ pool_init(&pv_pool, sizeof(struct pvlist), 0, 0, 0, "pvtable", NULL);
/*
* Setup a pool for pmap structures.
@@ -3791,7 +3788,7 @@ pmap_init()
ncpu * sizeof(int *) + /* pm_reg_ptps */
ncpu * sizeof(int); /* pm_reg_ptps_pa */
pool_init(&pmap_pmap_pool, sizeof_pmap, 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
pool_cache_init(&pmap_pmap_pool_cache, &pmap_pmap_pool,
pmap_pmap_pool_ctor, pmap_pmap_pool_dtor, NULL);
@@ -3805,12 +3802,12 @@ pmap_init()
int n;
n = SRMMU_L1SIZE * sizeof(int);
- pool_init(&L1_pool, n, n, 0, 0, "L1 pagetable", 0,
- pgt_page_alloc, pgt_page_free, 0);
+ pool_init(&L1_pool, n, n, 0, 0, "L1 pagetable",
+ &pgt_page_allocator);
n = SRMMU_L2SIZE * sizeof(int);
- pool_init(&L23_pool, n, n, 0, 0, "L2/L3 pagetable", 0,
- pgt_page_alloc, pgt_page_free, 0);
+ pool_init(&L23_pool, n, n, 0, 0, "L2/L3 pagetable",
+ &pgt_page_allocator);
}
#endif
diff --git a/sys/arch/sparc64/sparc64/pmap.c b/sys/arch/sparc64/sparc64/pmap.c
index b5b3cf7b543..cb46bc2ace3 100644
--- a/sys/arch/sparc64/sparc64/pmap.c
+++ b/sys/arch/sparc64/sparc64/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.116 2002/02/27 16:09:51 pk Exp $ */
+/* $NetBSD: pmap.c,v 1.117 2002/03/08 20:48:35 thorpej Exp $ */
#undef NO_VCACHE /* Don't forget the locked TLB in dostart */
#define HWREF
/*
@@ -1523,8 +1523,7 @@ pmap_init()
}
/* Setup a pool for additional pvlist structures */
- pool_init(&pv_pool, sizeof(struct pv_entry), 0, 0, 0, "pv_entry", 0,
- NULL, NULL, 0);
+ pool_init(&pv_pool, sizeof(struct pv_entry), 0, 0, 0, "pv_entry", NULL);
vm_first_phys = avail_start;
vm_num_phys = avail_end - avail_start;
diff --git a/sys/arch/sun2/sun2/pmap.c b/sys/arch/sun2/sun2/pmap.c
index 15548fb94e4..a842eeb00cb 100644
--- a/sys/arch/sun2/sun2/pmap.c
+++ b/sys/arch/sun2/sun2/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.16 2001/11/30 18:22:51 fredette Exp $ */
+/* $NetBSD: pmap.c,v 1.17 2002/03/08 20:48:35 thorpej Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -1836,7 +1836,7 @@ pmap_init()
/* Initialize the pmap pool. */
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
}
/*
diff --git a/sys/arch/sun3/sun3/pmap.c b/sys/arch/sun3/sun3/pmap.c
index 8f8d57b9543..1b905536fd6 100644
--- a/sys/arch/sun3/sun3/pmap.c
+++ b/sys/arch/sun3/sun3/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.135 2001/09/10 21:19:28 chris Exp $ */
+/* $NetBSD: pmap.c,v 1.136 2002/03/08 20:48:35 thorpej Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -1864,7 +1864,7 @@ pmap_init()
/* Initialize the pmap pool. */
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
}
/*
diff --git a/sys/arch/sun3/sun3x/pmap.c b/sys/arch/sun3/sun3x/pmap.c
index 399e2adf8b2..6078bafb73f 100644
--- a/sys/arch/sun3/sun3x/pmap.c
+++ b/sys/arch/sun3/sun3x/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.73 2001/09/10 21:19:28 chris Exp $ */
+/* $NetBSD: pmap.c,v 1.74 2002/03/08 20:48:36 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -1062,7 +1062,7 @@ pmap_init()
/** Initialize the pmap pools **/
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
}
/* pmap_init_a_tables() INTERNAL
diff --git a/sys/arch/x68k/x68k/pmap.c b/sys/arch/x68k/x68k/pmap.c
index bca29cf3cc7..ce08aa6b663 100644
--- a/sys/arch/x68k/x68k/pmap.c
+++ b/sys/arch/x68k/x68k/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.75 2002/01/02 00:51:38 chs Exp $ */
+/* $NetBSD: pmap.c,v 1.76 2002/03/08 20:48:36 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -548,7 +548,7 @@ pmap_init()
* Initialize the pmap pools.
*/
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
/*
* Now that this is done, mark the pages shared with the
diff --git a/sys/arch/x86_64/x86_64/pmap.c b/sys/arch/x86_64/x86_64/pmap.c
index 13db060cf1e..c2448be3595 100644
--- a/sys/arch/x86_64/x86_64/pmap.c
+++ b/sys/arch/x86_64/x86_64/pmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.4 2002/01/02 00:51:38 chs Exp $ */
+/* $NetBSD: pmap.c,v 1.5 2002/03/08 20:48:37 thorpej Exp $ */
/*
*
@@ -994,14 +994,14 @@ pmap_bootstrap(kva_start)
*/
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
/*
* initialize the PDE pool and cache.
*/
pool_init(&pmap_pdp_pool, PAGE_SIZE, 0, 0, 0, "pdppl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VMPMAP);
+ &pool_allocator_nointr);
pool_cache_init(&pmap_pdp_cache, &pmap_pdp_pool,
pmap_pdp_ctor, NULL, NULL);
diff --git a/sys/dev/ccd.c b/sys/dev/ccd.c
index d2952f3f432..f00a5e0d8de 100644
--- a/sys/dev/ccd.c
+++ b/sys/dev/ccd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ccd.c,v 1.75 2002/01/13 19:28:06 tsutsui Exp $ */
+/* $NetBSD: ccd.c,v 1.76 2002/03/08 20:48:37 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.75 2002/01/13 19:28:06 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.76 2002/03/08 20:48:37 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -201,7 +201,7 @@ ccdattach(num)
/* Initialize the component buffer pool. */
pool_init(&ccd_cbufpool, sizeof(struct ccdbuf), 0,
- 0, 0, "ccdpl", 0, NULL, NULL, M_DEVBUF);
+ 0, 0, "ccdpl", NULL);
/* Initialize per-softc structures. */
for (i = 0; i < num; i++) {
diff --git a/sys/dev/ic/ncr53c9x.c b/sys/dev/ic/ncr53c9x.c
index 545ddb7ad5f..b93e3d34c25 100644
--- a/sys/dev/ic/ncr53c9x.c
+++ b/sys/dev/ic/ncr53c9x.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ncr53c9x.c,v 1.89 2002/01/12 16:03:12 tsutsui Exp $ */
+/* $NetBSD: ncr53c9x.c,v 1.90 2002/03/08 20:48:38 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ncr53c9x.c,v 1.89 2002/01/12 16:03:12 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ncr53c9x.c,v 1.90 2002/03/08 20:48:38 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -429,7 +429,7 @@ ncr53c9x_init(sc, doreset)
if (!ecb_pool_initialized) {
/* All instances share this pool */
pool_init(&ecb_pool, sizeof(struct ncr53c9x_ecb), 0, 0, 0,
- "ncr53c9x_ecb", 0, NULL, NULL, 0);
+ "ncr53c9x_ecb", NULL);
ecb_pool_initialized = 1;
}
diff --git a/sys/dev/ic/wdc.c b/sys/dev/ic/wdc.c
index 678f1a406b9..a63914baeb8 100644
--- a/sys/dev/ic/wdc.c
+++ b/sys/dev/ic/wdc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: wdc.c,v 1.111 2002/03/04 02:19:10 simonb Exp $ */
+/* $NetBSD: wdc.c,v 1.112 2002/03/08 20:48:38 thorpej Exp $ */
/*
@@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.111 2002/03/04 02:19:10 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.112 2002/03/08 20:48:38 thorpej Exp $");
#ifndef WDCDEBUG
#define WDCDEBUG
@@ -331,7 +331,7 @@ wdcattach(chp)
if (inited == 0) {
/* Initialize the wdc_xfer pool. */
pool_init(&wdc_xfer_pool, sizeof(struct wdc_xfer), 0,
- 0, 0, "wdcspl", 0, NULL, NULL, M_DEVBUF);
+ 0, 0, "wdcspl", NULL);
inited++;
}
TAILQ_INIT(&chp->ch_queue->sc_xfer);
diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c
index 8c4d2cfac1d..ec9deda7af8 100644
--- a/sys/dev/raidframe/rf_netbsdkintf.c
+++ b/sys/dev/raidframe/rf_netbsdkintf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_netbsdkintf.c,v 1.116 2002/01/09 04:21:43 thorpej Exp $ */
+/* $NetBSD: rf_netbsdkintf.c,v 1.117 2002/03/08 20:48:39 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -114,7 +114,7 @@
***********************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.116 2002/01/09 04:21:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.117 2002/03/08 20:48:39 thorpej Exp $");
#include <sys/param.h>
#include <sys/errno.h>
@@ -329,7 +329,7 @@ raidattach(num)
/* Initialize the component buffer pool. */
pool_init(&raidframe_cbufpool, sizeof(struct raidbuf), 0,
- 0, 0, "raidpl", 0, NULL, NULL, M_RAIDFRAME);
+ 0, 0, "raidpl", NULL);
rc = rf_mutex_init(&rf_sparet_wait_mutex);
if (rc) {
diff --git a/sys/dev/rnd.c b/sys/dev/rnd.c
index 3fadb239ae5..ebe6cd674cd 100644
--- a/sys/dev/rnd.c
+++ b/sys/dev/rnd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rnd.c,v 1.25 2001/11/13 05:32:50 lukem Exp $ */
+/* $NetBSD: rnd.c,v 1.26 2002/03/08 20:48:37 thorpej Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.25 2001/11/13 05:32:50 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rnd.c,v 1.26 2002/03/08 20:48:37 thorpej Exp $");
#include <sys/param.h>
#include <sys/ioctl.h>
@@ -288,7 +288,7 @@ rnd_init(void)
SIMPLEQ_INIT(&rnd_samples);
pool_init(&rnd_mempool, sizeof(rnd_sample_t), 0, 0, 0, "rndsample",
- 0, NULL, NULL, 0);
+ NULL);
rndpool_init(&rnd_pool);
diff --git a/sys/dev/scsipi/scsipi_base.c b/sys/dev/scsipi/scsipi_base.c
index b9761a9ba3d..ea68c2dc07a 100644
--- a/sys/dev/scsipi/scsipi_base.c
+++ b/sys/dev/scsipi/scsipi_base.c
@@ -1,4 +1,4 @@
-/* $NetBSD: scsipi_base.c,v 1.67 2002/02/21 05:30:30 enami Exp $ */
+/* $NetBSD: scsipi_base.c,v 1.68 2002/03/08 20:48:39 thorpej Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.67 2002/02/21 05:30:30 enami Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.68 2002/03/08 20:48:39 thorpej Exp $");
#include "opt_scsi.h"
@@ -101,7 +101,7 @@ scsipi_init()
/* Initialize the scsipi_xfer pool. */
pool_init(&scsipi_xfer_pool, sizeof(struct scsipi_xfer), 0,
- 0, 0, "scxspl", 0, NULL, NULL, M_DEVBUF);
+ 0, 0, "scxspl", NULL);
}
/*
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c
index 06e29cec9cb..91048a09fb1 100644
--- a/sys/dev/vnd.c
+++ b/sys/dev/vnd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vnd.c,v 1.77 2002/01/13 19:28:08 tsutsui Exp $ */
+/* $NetBSD: vnd.c,v 1.78 2002/03/08 20:48:37 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -98,7 +98,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.77 2002/01/13 19:28:08 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.78 2002/03/08 20:48:37 thorpej Exp $");
#if defined(_KERNEL_OPT)
#include "fs_nfs.h"
@@ -868,9 +868,9 @@ vndioctl(dev, cmd, data, flag, p)
/* Initialize the xfer and buffer pools. */
pool_init(&vnd->sc_vxpool, sizeof(struct vndxfer), 0,
- 0, 0, "vndxpl", 0, NULL, NULL, M_DEVBUF);
+ 0, 0, "vndxpl", NULL);
pool_init(&vnd->sc_vbpool, sizeof(struct vndbuf), 0,
- 0, 0, "vndbpl", 0, NULL, NULL, M_DEVBUF);
+ 0, 0, "vndbpl", NULL);
/* Try and read the disklabel. */
vndgetdisklabel(dev);
diff --git a/sys/filecorefs/filecore_node.c b/sys/filecorefs/filecore_node.c
index e80768bb3d3..595435f124f 100644
--- a/sys/filecorefs/filecore_node.c
+++ b/sys/filecorefs/filecore_node.c
@@ -1,4 +1,4 @@
-/* $NetBSD: filecore_node.c,v 1.9 2001/11/12 23:04:10 lukem Exp $ */
+/* $NetBSD: filecore_node.c,v 1.10 2002/03/08 20:48:40 thorpej Exp $ */
/*-
* Copyright (c) 1998 Andrew McMurry
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: filecore_node.c,v 1.9 2001/11/12 23:04:10 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: filecore_node.c,v 1.10 2002/03/08 20:48:40 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -80,8 +80,7 @@ filecore_init()
M_WAITOK, &filecorehash);
simple_lock_init(&filecore_ihash_slock);
pool_init(&filecore_node_pool, sizeof(struct filecore_node),
- 0, 0, 0, "filecrnopl", 0, pool_page_alloc_nointr,
- pool_page_free_nointr, M_FILECORENODE);
+ 0, 0, 0, "filecrnopl", &pool_allocator_nointr);
}
/*
diff --git a/sys/isofs/cd9660/cd9660_node.c b/sys/isofs/cd9660/cd9660_node.c
index 10b188aaae1..b5d3ca7255d 100644
--- a/sys/isofs/cd9660/cd9660_node.c
+++ b/sys/isofs/cd9660/cd9660_node.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cd9660_node.c,v 1.27 2001/11/12 15:29:49 lukem Exp $ */
+/* $NetBSD: cd9660_node.c,v 1.28 2002/03/08 20:48:40 thorpej Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1994
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_node.c,v 1.27 2001/11/12 15:29:49 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_node.c,v 1.28 2002/03/08 20:48:40 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -96,8 +96,7 @@ cd9660_init()
M_WAITOK, &idvhash);
#endif
pool_init(&cd9660_node_pool, sizeof(struct iso_node), 0, 0, 0,
- "cd9660nopl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_ISOFSNODE);
+ "cd9660nopl", &pool_allocator_nointr);
}
/*
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 4424f838f82..b6c242f963c 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_descrip.c,v 1.84 2002/01/31 22:17:33 kleink Exp $ */
+/* $NetBSD: kern_descrip.c,v 1.85 2002/03/08 20:48:40 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.84 2002/01/31 22:17:33 kleink Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.85 2002/03/08 20:48:40 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -700,11 +700,11 @@ finit(void)
{
pool_init(&file_pool, sizeof(struct file), 0, 0, 0, "filepl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_FILE);
+ &pool_allocator_nointr);
pool_init(&cwdi_pool, sizeof(struct cwdinfo), 0, 0, 0, "cwdipl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_FILEDESC);
+ &pool_allocator_nointr);
pool_init(&filedesc0_pool, sizeof(struct filedesc0), 0, 0, 0, "fdescpl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_FILEDESC);
+ &pool_allocator_nointr);
}
/*
diff --git a/sys/kern/kern_malloc_debug.c b/sys/kern/kern_malloc_debug.c
index 2fc7af7b89a..7921d5a7662 100644
--- a/sys/kern/kern_malloc_debug.c
+++ b/sys/kern/kern_malloc_debug.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_malloc_debug.c,v 1.5 2001/11/17 03:50:28 lukem Exp $ */
+/* $NetBSD: kern_malloc_debug.c,v 1.6 2002/03/08 20:48:40 thorpej Exp $ */
/*
* Copyright (c) 1999, 2000 Artur Grabowski <art@openbsd.org>
@@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_malloc_debug.c,v 1.5 2001/11/17 03:50:28 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_malloc_debug.c,v 1.6 2002/03/08 20:48:40 thorpej Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -221,7 +221,7 @@ debug_malloc_init(void)
debug_malloc_chunks_on_freelist = 0;
pool_init(&debug_malloc_pool, sizeof(struct debug_malloc_entry),
- 0, 0, 0, "mdbepl", 0, NULL, NULL, 0);
+ 0, 0, 0, "mdbepl", NULL);
}
/*
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 7080e07008b..3c5c5198fa6 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_proc.c,v 1.45 2001/11/12 15:25:13 lukem Exp $ */
+/* $NetBSD: kern_proc.c,v 1.46 2002/03/08 20:48:40 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.45 2001/11/12 15:25:13 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.46 2002/03/08 20:48:40 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -190,15 +190,15 @@ procinit()
hashinit(maxproc / 16, HASH_LIST, M_PROC, M_WAITOK, &uihash);
pool_init(&proc_pool, sizeof(struct proc), 0, 0, 0, "procpl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_PROC);
+ &pool_allocator_nointr);
pool_init(&pgrp_pool, sizeof(struct pgrp), 0, 0, 0, "pgrppl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_PGRP);
+ &pool_allocator_nointr);
pool_init(&pcred_pool, sizeof(struct pcred), 0, 0, 0, "pcredpl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_SUBPROC);
+ &pool_allocator_nointr);
pool_init(&plimit_pool, sizeof(struct plimit), 0, 0, 0, "plimitpl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_SUBPROC);
+ &pool_allocator_nointr);
pool_init(&rusage_pool, sizeof(struct rusage), 0, 0, 0, "rusgepl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_ZOMBIE);
+ &pool_allocator_nointr);
}
/*
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 9d3d13a91a6..8b7fc7900bb 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sig.c,v 1.119 2001/12/18 15:51:52 christos Exp $ */
+/* $NetBSD: kern_sig.c,v 1.120 2002/03/08 20:48:40 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.119 2001/12/18 15:51:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.120 2002/03/08 20:48:40 thorpej Exp $");
#include "opt_ktrace.h"
#include "opt_compat_sunos.h"
@@ -106,7 +106,7 @@ signal_init(void)
{
pool_init(&sigacts_pool, sizeof(struct sigacts), 0, 0, 0, "sigapl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_SUBPROC);
+ &pool_allocator_nointr);
}
/*
diff --git a/sys/kern/subr_extent.c b/sys/kern/subr_extent.c
index 7ac991b0d95..dcd2aac34f8 100644
--- a/sys/kern/subr_extent.c
+++ b/sys/kern/subr_extent.c
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_extent.c,v 1.45 2002/02/09 01:00:09 bouyer Exp $ */
+/* $NetBSD: subr_extent.c,v 1.46 2002/03/08 20:48:41 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1998 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_extent.c,v 1.45 2002/02/09 01:00:09 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_extent.c,v 1.46 2002/03/08 20:48:41 thorpej Exp $");
#ifdef _KERNEL
#include <sys/param.h>
@@ -137,7 +137,7 @@ expool_init(void)
#if defined(_KERNEL)
pool_init(&expool, sizeof(struct extent_region), 0, 0, 0,
- "extent", 0, 0, 0, 0);
+ "extent", NULL);
#else
expool.pr_size = sizeof(struct extent_region);
#endif
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c
index 14e1151cf03..c4840bdd4eb 100644
--- a/sys/kern/subr_pool.c
+++ b/sys/kern/subr_pool.c
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_pool.c,v 1.65 2001/11/20 06:57:04 enami Exp $ */
+/* $NetBSD: subr_pool.c,v 1.66 2002/03/08 20:48:41 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1999, 2000 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.65 2001/11/20 06:57:04 enami Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.66 2002/03/08 20:48:41 thorpej Exp $");
#include "opt_pool.h"
#include "opt_poollog.h"
@@ -110,7 +110,8 @@ struct pool_item {
};
#define PR_HASH_INDEX(pp,addr) \
- (((u_long)(addr) >> (pp)->pr_pageshift) & (PR_HASHTABSIZE - 1))
+ (((u_long)(addr) >> (pp)->pr_alloc->pa_pageshift) & \
+ (PR_HASHTABSIZE - 1))
#define POOL_NEEDS_CATCHUP(pp) \
((pp)->pr_nitems < (pp)->pr_minitems)
@@ -159,12 +160,9 @@ static void pool_cache_reclaim(struct pool_cache *);
static int pool_catchup(struct pool *);
static void pool_prime_page(struct pool *, caddr_t,
struct pool_item_header *);
-static void *pool_page_alloc(unsigned long, int, int);
-static void pool_page_free(void *, unsigned long, int);
-#ifdef POOL_SUBPAGE
-static void *pool_subpage_alloc(unsigned long, int, int);
-static void pool_subpage_free(void *, unsigned long, int);
-#endif
+
+void *pool_allocator_alloc(struct pool *, int);
+void pool_allocator_free(struct pool *, void *);
static void pool_print1(struct pool *, const char *,
void (*)(const char *, ...));
@@ -338,7 +336,7 @@ pr_rmpage(struct pool *pp, struct pool_item_header *ph,
if (pq) {
TAILQ_INSERT_HEAD(pq, ph, ph_pagelist);
} else {
- (*pp->pr_free)(ph->ph_page, pp->pr_pagesz, pp->pr_mtype);
+ pool_allocator_free(pp, ph->ph_page);
if ((pp->pr_roflags & PR_PHINPAGE) == 0) {
LIST_REMOVE(ph, ph_hashlist);
s = splhigh();
@@ -371,10 +369,7 @@ pr_rmpage(struct pool *pp, struct pool_item_header *ph,
*/
void
pool_init(struct pool *pp, size_t size, u_int align, u_int ioff, int flags,
- const char *wchan, size_t pagesz,
- void *(*alloc)(unsigned long, int, int),
- void (*release)(void *, unsigned long, int),
- int mtype)
+ const char *wchan, struct pool_allocator *palloc)
{
int off, slack, i;
@@ -386,34 +381,43 @@ pool_init(struct pool *pp, size_t size, u_int align, u_int ioff, int flags,
flags |= PR_LOGGING;
#endif
+#ifdef POOL_SUBPAGE
/*
- * Check arguments and construct default values.
+ * XXX We don't provide a real `nointr' back-end
+ * yet; all sub-pages come from a kmem back-end.
+ * maybe some day...
*/
- if (!powerof2(pagesz))
- panic("pool_init: page size invalid (%lx)\n", (u_long)pagesz);
-
- if (alloc == NULL && release == NULL) {
+ if (palloc == NULL) {
+ extern struct pool_allocator pool_allocator_kmem_subpage;
+ palloc = &pool_allocator_kmem_subpage;
+ }
+ /*
+ * We'll assume any user-specified back-end allocator
+ * will deal with sub-pages, or simply don't care.
+ */
+#else
+ if (palloc == NULL)
+ palloc = &pool_allocator_kmem;
+#endif /* POOL_SUBPAGE */
+ if ((palloc->pa_flags & PA_INITIALIZED) == 0) {
+ if (palloc->pa_pagesz == 0) {
#ifdef POOL_SUBPAGE
- alloc = pool_subpage_alloc;
- release = pool_subpage_free;
- pagesz = POOL_SUBPAGE;
+ if (palloc == &pool_allocator_kmem)
+ palloc->pa_pagesz = PAGE_SIZE;
+ else
+ palloc->pa_pagesz = POOL_SUBPAGE;
#else
- alloc = pool_page_alloc;
- release = pool_page_free;
- pagesz = PAGE_SIZE; /* Rounds to PAGE_SIZE anyhow. */
-#endif
- } else if ((alloc != NULL && release != NULL) == 0) {
- /* If you specifiy one, must specify both. */
- panic("pool_init: must specify alloc and release together");
+ palloc->pa_pagesz = PAGE_SIZE;
+#endif /* POOL_SUBPAGE */
+ }
+
+ TAILQ_INIT(&palloc->pa_list);
+
+ simple_lock_init(&palloc->pa_slock);
+ palloc->pa_pagemask = ~(palloc->pa_pagesz - 1);
+ palloc->pa_pageshift = ffs(palloc->pa_pagesz) - 1;
+ palloc->pa_flags |= PA_INITIALIZED;
}
-#ifdef POOL_SUBPAGE
- else if (alloc == pool_page_alloc_nointr &&
- release == pool_page_free_nointr)
- pagesz = POOL_SUBPAGE;
-#endif
-
- if (pagesz == 0)
- pagesz = PAGE_SIZE;
if (align == 0)
align = ALIGN(1);
@@ -422,9 +426,11 @@ pool_init(struct pool *pp, size_t size, u_int align, u_int ioff, int flags,
size = sizeof(struct pool_item);
size = ALIGN(size);
- if (size > pagesz)
+#ifdef DIAGNOSTIC
+ if (size > palloc->pa_pagesz)
panic("pool_init: pool item size (%lu) too large",
(u_long)size);
+#endif
/*
* Initialize the pool structure.
@@ -441,12 +447,7 @@ pool_init(struct pool *pp, size_t size, u_int align, u_int ioff, int flags,
pp->pr_size = size;
pp->pr_align = align;
pp->pr_wchan = wchan;
- pp->pr_mtype = mtype;
- pp->pr_alloc = alloc;
- pp->pr_free = release;
- pp->pr_pagesz = pagesz;
- pp->pr_pagemask = ~(pagesz - 1);
- pp->pr_pageshift = ffs(pagesz) - 1;
+ pp->pr_alloc = palloc;
pp->pr_nitems = 0;
pp->pr_nout = 0;
pp->pr_hardlimit = UINT_MAX;
@@ -463,15 +464,15 @@ pool_init(struct pool *pp, size_t size, u_int align, u_int ioff, int flags,
* with its header based on the page address.
* We use 1/16 of the page size as the threshold (XXX: tune)
*/
- if (pp->pr_size < pagesz/16) {
+ if (pp->pr_size < palloc->pa_pagesz/16) {
/* Use the end of the page for the page header */
pp->pr_roflags |= PR_PHINPAGE;
- pp->pr_phoffset = off =
- pagesz - ALIGN(sizeof(struct pool_item_header));
+ pp->pr_phoffset = off = palloc->pa_pagesz -
+ ALIGN(sizeof(struct pool_item_header));
} else {
/* The page header will be taken from our page header pool */
pp->pr_phoffset = 0;
- off = pagesz;
+ off = palloc->pa_pagesz;
for (i = 0; i < PR_HASHTABSIZE; i++) {
LIST_INIT(&pp->pr_hashtab[i]);
}
@@ -528,22 +529,26 @@ pool_init(struct pool *pp, size_t size, u_int align, u_int ioff, int flags,
if (phpool.pr_size == 0) {
#ifdef POOL_SUBPAGE
pool_init(&phpool, sizeof(struct pool_item_header), 0, 0, 0,
- "phpool", PAGE_SIZE, pool_page_alloc, pool_page_free, 0);
+ "phpool", &pool_allocator_kmem);
pool_init(&psppool, POOL_SUBPAGE, POOL_SUBPAGE, 0,
- PR_RECURSIVE, "psppool", PAGE_SIZE,
- pool_page_alloc, pool_page_free, 0);
+ PR_RECURSIVE, "psppool", &pool_allocator_kmem);
#else
pool_init(&phpool, sizeof(struct pool_item_header), 0, 0,
- 0, "phpool", 0, 0, 0, 0);
+ 0, "phpool", NULL);
#endif
pool_init(&pcgpool, sizeof(struct pool_cache_group), 0, 0,
- 0, "pcgpool", 0, 0, 0, 0);
+ 0, "pcgpool", NULL);
}
/* Insert into the list of all pools. */
simple_lock(&pool_head_slock);
TAILQ_INSERT_TAIL(&pool_head, pp, pr_poollist);
simple_unlock(&pool_head_slock);
+
+ /* Insert this into the list of pools using this allocator. */
+ simple_lock(&palloc->pa_slock);
+ TAILQ_INSERT_TAIL(&palloc->pa_list, pp, pr_alloc_list);
+ simple_unlock(&palloc->pa_slock);
}
/*
@@ -555,6 +560,11 @@ pool_destroy(struct pool *pp)
struct pool_item_header *ph;
struct pool_cache *pc;
+ /* Locking order: pool_allocator -> pool */
+ simple_lock(&pp->pr_alloc->pa_slock);
+ TAILQ_REMOVE(&pp->pr_alloc->pa_list, pp, pr_alloc_list);
+ simple_unlock(&pp->pr_alloc->pa_slock);
+
/* Destroy all caches for this pool. */
while ((pc = TAILQ_FIRST(&pp->pr_cachelist)) != NULL)
pool_cache_destroy(pc);
@@ -676,9 +686,6 @@ pool_get(struct pool *pp, int flags)
&pp->pr_hardlimit_ratecap))
log(LOG_ERR, "%s\n", pp->pr_hardlimit_warning);
- if (flags & PR_URGENT)
- panic("pool_get: urgent");
-
pp->pr_nfail++;
pr_leave(pp);
@@ -709,7 +716,7 @@ pool_get(struct pool *pp, int flags)
*/
pr_leave(pp);
simple_unlock(&pp->pr_slock);
- v = (*pp->pr_alloc)(pp->pr_pagesz, flags, pp->pr_mtype);
+ v = pool_allocator_alloc(pp, flags);
if (__predict_true(v != NULL))
ph = pool_alloc_item_header(pp, v, flags);
simple_lock(&pp->pr_slock);
@@ -717,7 +724,7 @@ pool_get(struct pool *pp, int flags)
if (__predict_false(v == NULL || ph == NULL)) {
if (v != NULL)
- (*pp->pr_free)(v, pp->pr_pagesz, pp->pr_mtype);
+ pool_allocator_free(pp, v);
/*
* We were unable to allocate a page or item
@@ -728,9 +735,6 @@ pool_get(struct pool *pp, int flags)
if (pp->pr_curpage != NULL)
goto startover;
- if (flags & PR_URGENT)
- panic("pool_get: urgent");
-
if ((flags & PR_WAITOK) == 0) {
pp->pr_nfail++;
pr_leave(pp);
@@ -741,15 +745,11 @@ pool_get(struct pool *pp, int flags)
/*
* Wait for items to be returned to this pool.
*
- * XXX: we actually want to wait just until
- * the page allocator has memory again. Depending
- * on this pool's usage, we might get stuck here
- * for a long time.
- *
* XXX: maybe we should wake up once a second and
* try again?
*/
pp->pr_flags |= PR_WANTED;
+ /* PA_WANTED is already set on the allocator. */
pr_leave(pp);
ltsleep(pp, PSWP, pp->pr_wchan, 0, &pp->pr_slock);
pr_enter(pp, file, line);
@@ -867,7 +867,7 @@ pool_do_put(struct pool *pp, void *v)
LOCK_ASSERT(simple_lock_held(&pp->pr_slock));
- page = (caddr_t)((u_long)v & pp->pr_pagemask);
+ page = (caddr_t)((u_long)v & pp->pr_alloc->pa_pagemask);
#ifdef DIAGNOSTIC
if (__predict_false(pp->pr_nout == 0)) {
@@ -1035,7 +1035,7 @@ pool_prime(struct pool *pp, int n)
while (newpages-- > 0) {
simple_unlock(&pp->pr_slock);
- cp = (*pp->pr_alloc)(pp->pr_pagesz, PR_NOWAIT, pp->pr_mtype);
+ cp = pool_allocator_alloc(pp, PR_NOWAIT);
if (__predict_true(cp != NULL))
ph = pool_alloc_item_header(pp, cp, PR_NOWAIT);
simple_lock(&pp->pr_slock);
@@ -1043,7 +1043,7 @@ pool_prime(struct pool *pp, int n)
if (__predict_false(cp == NULL || ph == NULL)) {
error = ENOMEM;
if (cp != NULL)
- (*pp->pr_free)(cp, pp->pr_pagesz, pp->pr_mtype);
+ pool_allocator_free(pp, cp);
break;
}
@@ -1073,8 +1073,10 @@ pool_prime_page(struct pool *pp, caddr_t storage, struct pool_item_header *ph)
unsigned int ioff = pp->pr_itemoffset;
int n;
- if (((u_long)cp & (pp->pr_pagesz - 1)) != 0)
+#ifdef DIAGNOSTIC
+ if (((u_long)cp & (pp->pr_alloc->pa_pagesz - 1)) != 0)
panic("pool_prime_page: %s: unaligned page", pp->pr_wchan);
+#endif
if ((pp->pr_roflags & PR_PHINPAGE) == 0)
LIST_INSERT_HEAD(&pp->pr_hashtab[PR_HASH_INDEX(pp, cp)],
@@ -1169,13 +1171,13 @@ pool_catchup(struct pool *pp)
* the pool descriptor?
*/
simple_unlock(&pp->pr_slock);
- cp = (*pp->pr_alloc)(pp->pr_pagesz, PR_NOWAIT, pp->pr_mtype);
+ cp = pool_allocator_alloc(pp, PR_NOWAIT);
if (__predict_true(cp != NULL))
ph = pool_alloc_item_header(pp, cp, PR_NOWAIT);
simple_lock(&pp->pr_slock);
if (__predict_false(cp == NULL || ph == NULL)) {
if (cp != NULL)
- (*pp->pr_free)(cp, pp->pr_pagesz, pp->pr_mtype);
+ pool_allocator_free(pp, cp);
error = ENOMEM;
break;
}
@@ -1247,84 +1249,9 @@ pool_sethardlimit(struct pool *pp, int n, const char *warnmess, int ratecap)
}
/*
- * Default page allocator.
- */
-static void *
-pool_page_alloc(unsigned long sz, int flags, int mtype)
-{
- boolean_t waitok = (flags & PR_WAITOK) ? TRUE : FALSE;
-
- return ((void *)uvm_km_alloc_poolpage(waitok));
-}
-
-static void
-pool_page_free(void *v, unsigned long sz, int mtype)
-{
-
- uvm_km_free_poolpage((vaddr_t)v);
-}
-
-#ifdef POOL_SUBPAGE
-/*
- * Sub-page allocator, for machines with large hardware pages.
- */
-static void *
-pool_subpage_alloc(unsigned long sz, int flags, int mtype)
-{
-
- return pool_get(&psppool, flags);
-}
-
-static void
-pool_subpage_free(void *v, unsigned long sz, int mtype)
-{
-
- pool_put(&psppool, v);
-}
-#endif
-
-#ifdef POOL_SUBPAGE
-/* We don't provide a real nointr allocator. Maybe later. */
-void *
-pool_page_alloc_nointr(unsigned long sz, int flags, int mtype)
-{
-
- return pool_subpage_alloc(sz, flags, mtype);
-}
-
-void
-pool_page_free_nointr(void *v, unsigned long sz, int mtype)
-{
-
- pool_subpage_free(v, sz, mtype);
-}
-#else
-/*
- * Alternate pool page allocator for pools that know they will
- * never be accessed in interrupt context.
- */
-void *
-pool_page_alloc_nointr(unsigned long sz, int flags, int mtype)
-{
- boolean_t waitok = (flags & PR_WAITOK) ? TRUE : FALSE;
-
- return ((void *)uvm_km_alloc_poolpage1(kernel_map, uvm.kernel_object,
- waitok));
-}
-
-void
-pool_page_free_nointr(void *v, unsigned long sz, int mtype)
-{
-
- uvm_km_free_poolpage1(kernel_map, (vaddr_t)v);
-}
-#endif
-
-
-/*
* Release all complete pages that have not been used recently.
*/
-void
+int
#ifdef POOL_DIAGNOSTIC
_pool_reclaim(struct pool *pp, const char *file, long line)
#else
@@ -1338,10 +1265,10 @@ pool_reclaim(struct pool *pp)
int s;
if (pp->pr_roflags & PR_STATIC)
- return;
+ return (0);
if (simple_lock_try(&pp->pr_slock) == 0)
- return;
+ return (0);
pr_enter(pp, file, line);
TAILQ_INIT(&pq);
@@ -1382,12 +1309,12 @@ pool_reclaim(struct pool *pp)
pr_leave(pp);
simple_unlock(&pp->pr_slock);
- if (TAILQ_EMPTY(&pq)) {
- return;
- }
+ if (TAILQ_EMPTY(&pq))
+ return (0);
+
while ((ph = TAILQ_FIRST(&pq)) != NULL) {
TAILQ_REMOVE(&pq, ph, ph_pagelist);
- (*pp->pr_free)(ph->ph_page, pp->pr_pagesz, pp->pr_mtype);
+ pool_allocator_free(pp, ph->ph_page);
if (pp->pr_roflags & PR_PHINPAGE) {
continue;
}
@@ -1396,8 +1323,9 @@ pool_reclaim(struct pool *pp)
pool_put(&phpool, ph);
splx(s);
}
-}
+ return (1);
+}
/*
* Drain pools, one at a time.
@@ -1425,7 +1353,6 @@ pool_drain(void *arg)
splx(s);
}
-
/*
* Diagnostic helpers.
*/
@@ -1501,8 +1428,7 @@ pool_print1(struct pool *pp, const char *modif, void (*pr)(const char *, ...))
(*pr)("POOL %s: size %u, align %u, ioff %u, roflags 0x%08x\n",
pp->pr_wchan, pp->pr_size, pp->pr_align, pp->pr_itemoffset,
pp->pr_roflags);
- (*pr)("\tpagesz %u, mtype %d\n", pp->pr_pagesz, pp->pr_mtype);
- (*pr)("\talloc %p, release %p\n", pp->pr_alloc, pp->pr_free);
+ (*pr)("\talloc %p\n", pp->pr_alloc);
(*pr)("\tminitems %u, minpages %u, maxpages %u, npages %u\n",
pp->pr_minitems, pp->pr_minpages, pp->pr_maxpages, pp->pr_npages);
(*pr)("\titemsperpage %u, nitems %u, nout %u, hardlimit %u\n",
@@ -1583,7 +1509,7 @@ pool_chk(struct pool *pp, const char *label)
int n;
caddr_t page;
- page = (caddr_t)((u_long)ph & pp->pr_pagemask);
+ page = (caddr_t)((u_long)ph & pp->pr_alloc->pa_pagemask);
if (page != ph->ph_page &&
(pp->pr_roflags & PR_PHINPAGE) != 0) {
if (label != NULL)
@@ -1612,7 +1538,8 @@ pool_chk(struct pool *pp, const char *label)
panic("pool");
}
#endif
- page = (caddr_t)((u_long)pi & pp->pr_pagemask);
+ page =
+ (caddr_t)((u_long)pi & pp->pr_alloc->pa_pagemask);
if (page == ph->ph_page)
continue;
@@ -1912,3 +1839,202 @@ pool_cache_reclaim(struct pool_cache *pc)
pool_cache_do_invalidate(pc, 1, pool_do_put);
simple_unlock(&pc->pc_slock);
}
+
+/*
+ * Pool backend allocators.
+ *
+ * Each pool has a backend allocator that handles allocation, deallocation,
+ * and any additional draining that might be needed.
+ *
+ * We provide two standard allocators:
+ *
+ * pool_allocator_kmem - the default when no allocator is specified
+ *
+ * pool_allocator_nointr - used for pools that will not be accessed
+ * in interrupt context.
+ */
+void *pool_page_alloc(struct pool *, int);
+void pool_page_free(struct pool *, void *);
+
+struct pool_allocator pool_allocator_kmem = {
+ pool_page_alloc, pool_page_free, 0,
+};
+
+void *pool_page_alloc_nointr(struct pool *, int);
+void pool_page_free_nointr(struct pool *, void *);
+
+struct pool_allocator pool_allocator_nointr = {
+ pool_page_alloc_nointr, pool_page_free_nointr, 0,
+};
+
+#ifdef POOL_SUBPAGE
+void *pool_subpage_alloc(struct pool *, int);
+void pool_subpage_free(struct pool *, void *);
+
+struct pool_allocator pool_allocator_kmem_subpage = {
+ pool_subpage_alloc, pool_subpage_free, 0,
+};
+#endif /* POOL_SUBPAGE */
+
+/*
+ * We have at least three different resources for the same allocation and
+ * each resource can be depleted. First, we have the ready elements in the
+ * pool. Then we have the resource (typically a vm_map) for this allocator.
+ * Finally, we have physical memory. Waiting for any of these can be
+ * unnecessary when any other is freed, but the kernel doesn't support
+ * sleeping on multiple wait channels, so we have to employ another strategy.
+ *
+ * The caller sleeps on the pool (so that it can be awakened when an item
+ * is returned to the pool), but we set PA_WANT on the allocator. When a
+ * page is returned to the allocator and PA_WANT is set, pool_allocator_free
+ * will wake up all sleeping pools belonging to this allocator.
+ *
+ * XXX Thundering herd.
+ */
+void *
+pool_allocator_alloc(struct pool *org, int flags)
+{
+ struct pool_allocator *pa = org->pr_alloc;
+ struct pool *pp, *start;
+ int s, freed;
+ void *res;
+
+ do {
+ if ((res = (*pa->pa_alloc)(org, flags)) != NULL)
+ return (res);
+ if ((flags & PR_WAITOK) == 0)
+ break;
+
+ /*
+ * Drain all pools, except "org", that use this
+ * allocator. We do this to reclaim VA space.
+ * pa_alloc is responsible for waiting for
+ * physical memory.
+ *
+ * XXX We risk looping forever if start if someone
+ * calls pool_destroy on "start". But there is no
+ * other way to have potentially sleeping pool_reclaim,
+ * non-sleeping locks on pool_allocator, and some
+ * stirring of drained pools in the allocator.
+ */
+ freed = 0;
+
+ s = splvm();
+ simple_lock(&pa->pa_slock);
+ pp = start = TAILQ_FIRST(&pa->pa_list);
+ do {
+ TAILQ_REMOVE(&pa->pa_list, pp, pr_alloc_list);
+ TAILQ_INSERT_TAIL(&pa->pa_list, pp, pr_alloc_list);
+ if (pp == org)
+ continue;
+ simple_unlock(&pa->pa_list);
+ freed = pool_reclaim(pp);
+ simple_lock(&pa->pa_list);
+ } while ((pp = TAILQ_FIRST(&pa->pa_list)) != start &&
+ freed == 0);
+
+ if (freed == 0) {
+ /*
+ * We set PA_WANT here, the caller will most likely
+ * sleep waiting for pages (if not, this won't hurt
+ * that much), and there is no way to set this in
+ * the caller without violating locking order.
+ */
+ pa->pa_flags |= PA_WANT;
+ }
+ simple_unlock(&pa->pa_slock);
+ splx(s);
+ } while (freed);
+ return (NULL);
+}
+
+void
+pool_allocator_free(struct pool *pp, void *v)
+{
+ struct pool_allocator *pa = pp->pr_alloc;
+ int s;
+
+ (*pa->pa_free)(pp, v);
+
+ s = splvm();
+ simple_lock(&pa->pa_slock);
+ if ((pa->pa_flags & PA_WANT) == 0) {
+ simple_unlock(&pa->pa_slock);
+ splx(s);
+ return;
+ }
+
+ TAILQ_FOREACH(pp, &pa->pa_list, pr_alloc_list) {
+ simple_lock(&pp->pr_slock);
+ if ((pp->pr_flags & PR_WANTED) != 0) {
+ pp->pr_flags &= ~PR_WANTED;
+ wakeup(pp);
+ }
+ }
+ pa->pa_flags &= ~PA_WANT;
+ simple_unlock(&pa->pa_slock);
+ splx(s);
+}
+
+void *
+pool_page_alloc(struct pool *pp, int flags)
+{
+ boolean_t waitok = (flags & PR_WAITOK) ? TRUE : FALSE;
+
+ return ((void *) uvm_km_alloc_poolpage(waitok));
+}
+
+void
+pool_page_free(struct pool *pp, void *v)
+{
+
+ uvm_km_free_poolpage((vaddr_t) v);
+}
+
+#ifdef POOL_SUBPAGE
+/* Sub-page allocator, for machines with large hardware pages. */
+void *
+pool_subpage_alloc(struct pool *pp, int flags)
+{
+
+ return (pool_get(&psppool, flags));
+}
+
+void
+pool_subpage_free(struct pool *pp, void *v)
+{
+
+ pool_put(&psppool, v);
+}
+
+/* We don't provide a real nointr allocator. Maybe later. */
+void *
+pool_page_alloc_nointr(struct pool *pp, int flags)
+{
+
+ return (pool_subpage_alloc(pp, flags));
+}
+
+void
+pool_page_free_nointr(struct pool *pp, void *v)
+{
+
+ pool_subpage_free(pp, v);
+}
+#else
+void *
+pool_page_alloc_nointr(struct pool *pp, int flags)
+{
+ boolean_t waitok = (flags & PR_WAITOK) ? TRUE : FALSE;
+
+ return ((void *) uvm_km_alloc_poolpage1(kernel_map,
+ uvm.kernel_object, waitok));
+}
+
+void
+pool_page_free_nointr(struct pool *pp, void *v)
+{
+
+ uvm_km_free_poolpage1(kernel_map, (vaddr_t) v);
+}
+#endif /* POOL_SUBPAGE */
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 271d1866f6d..2de84b7348c 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_pipe.c,v 1.22 2002/02/28 04:43:16 thorpej Exp $ */
+/* $NetBSD: sys_pipe.c,v 1.23 2002/03/08 20:48:41 thorpej Exp $ */
/*
* Copyright (c) 1996 John S. Dyson
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.22 2002/02/28 04:43:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.23 2002/03/08 20:48:41 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1815,8 +1815,7 @@ sysctl_dopipe(name, namelen, oldp, oldlenp, newp, newlen)
void
pipe_init(void)
{
- pool_init(&pipe_pool, sizeof(struct pipe), 0, 0, 0, "pipepl",
- 0, NULL, NULL, M_PIPE);
+ pool_init(&pipe_pool, sizeof(struct pipe), 0, 0, 0, "pipepl", NULL);
}
#endif /* __NetBSD __ */
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index f7221f30b50..1152a9a8e8a 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tty.c,v 1.132 2002/03/04 02:32:58 simonb Exp $ */
+/* $NetBSD: tty.c,v 1.133 2002/03/08 20:48:41 thorpej Exp $ */
/*-
* Copyright (c) 1982, 1986, 1990, 1991, 1993
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.132 2002/03/04 02:32:58 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.133 2002/03/08 20:48:41 thorpej Exp $");
#include "opt_uconsole.h"
@@ -2102,7 +2102,7 @@ tty_init(void)
tty_count = 0;
pool_init(&tty_pool, sizeof(struct tty), 0, 0, 0, "ttypl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_TTYS);
+ &pool_allocator_nointr);
}
/*
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index b9ddab203c4..8d4565c4b44 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_mbuf.c,v 1.57 2002/02/12 00:52:33 thorpej Exp $ */
+/* $NetBSD: uipc_mbuf.c,v 1.58 2002/03/08 20:48:41 thorpej Exp $ */
/*-
* Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.57 2002/02/12 00:52:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.58 2002/03/08 20:48:41 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -107,8 +107,13 @@ int max_protohdr;
int max_hdr;
int max_datalen;
-void *mclpool_alloc __P((unsigned long, int, int));
-void mclpool_release __P((void *, unsigned long, int));
+void *mclpool_alloc __P((struct pool *, int));
+void mclpool_release __P((struct pool *, void *));
+
+struct pool_allocator mclpool_allocator = {
+ mclpool_alloc, mclpool_release, 0,
+};
+
static struct mbuf *m_copym0 __P((struct mbuf *, int, int, int, int));
const char mclpool_warnmsg[] =
@@ -121,9 +126,8 @@ void
mbinit()
{
- pool_init(&mbpool, msize, 0, 0, 0, "mbpl", 0, NULL, NULL, 0);
- pool_init(&mclpool, mclbytes, 0, 0, 0, "mclpl", 0, mclpool_alloc,
- mclpool_release, 0);
+ pool_init(&mbpool, msize, 0, 0, 0, "mbpl", NULL);
+ pool_init(&mclpool, mclbytes, 0, 0, 0, "mclpl", &mclpool_allocator);
pool_cache_init(&mbpool_cache, &mbpool, NULL, NULL, NULL);
pool_cache_init(&mclpool_cache, &mclpool, NULL, NULL, NULL);
@@ -218,10 +222,9 @@ sysctl_dombuf(name, namelen, oldp, oldlenp, newp, newlen)
}
void *
-mclpool_alloc(sz, flags, mtype)
- unsigned long sz;
+mclpool_alloc(pp, flags)
+ struct pool *pp;
int flags;
- int mtype;
{
boolean_t waitok = (flags & PR_WAITOK) ? TRUE : FALSE;
@@ -229,10 +232,9 @@ mclpool_alloc(sz, flags, mtype)
}
void
-mclpool_release(v, sz, mtype)
+mclpool_release(pp, v)
+ struct pool *pp;
void *v;
- unsigned long sz;
- int mtype;
{
uvm_km_free_poolpage1(mb_map, (vaddr_t)v);
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index b49355cab85..8f65f64ca6c 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_socket.c,v 1.61 2002/01/03 01:16:02 mrg Exp $ */
+/* $NetBSD: uipc_socket.c,v 1.62 2002/03/08 20:48:41 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1990, 1993
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.61 2002/01/03 01:16:02 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.62 2002/03/08 20:48:41 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -63,7 +63,7 @@ soinit(void)
{
pool_init(&socket_pool, sizeof(struct socket), 0, 0, 0,
- "sockpl", 0, NULL, NULL, M_SOCKET);
+ "sockpl", NULL);
}
/*
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 3c5cc0c9653..8022ac89c69 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_bio.c,v 1.78 2002/02/10 23:14:18 chs Exp $ */
+/* $NetBSD: vfs_bio.c,v 1.79 2002/03/08 20:48:42 thorpej Exp $ */
/*-
* Copyright (c) 1994 Christopher G. Demetriou
@@ -49,7 +49,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.78 2002/02/10 23:14:18 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.79 2002/03/08 20:48:42 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -155,8 +155,7 @@ bufinit()
* which are strictly I/O control blocks, not buffer cache
* buffers.
*/
- pool_init(&bufpool, sizeof(struct buf), 0, 0, 0, "bufpl", 0,
- NULL, NULL, M_DEVBUF);
+ pool_init(&bufpool, sizeof(struct buf), 0, 0, 0, "bufpl", NULL);
for (dp = bufqueues; dp < &bufqueues[BQUEUES]; dp++)
TAILQ_INIT(dp);
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index 5f17e5d70ed..92dfb8c7765 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_cache.c,v 1.34 2001/12/10 01:49:26 enami Exp $ */
+/* $NetBSD: vfs_cache.c,v 1.35 2002/03/08 20:48:42 thorpej Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.34 2001/12/10 01:49:26 enami Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.35 2002/03/08 20:48:42 thorpej Exp $");
#include "opt_ddb.h"
#include "opt_revcache.h"
@@ -411,8 +411,7 @@ nchinit(void)
hashinit(desiredvnodes/8, HASH_LIST, M_CACHE, M_WAITOK, &ncvhash);
#endif
pool_init(&namecache_pool, sizeof(struct namecache), 0, 0, 0,
- "ncachepl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_CACHE);
+ "ncachepl", &pool_allocator_nointr);
}
/*
diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c
index 7040ea0e269..aa6c8291cd9 100644
--- a/sys/kern/vfs_init.c
+++ b/sys/kern/vfs_init.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_init.c,v 1.20 2001/11/12 15:25:38 lukem Exp $ */
+/* $NetBSD: vfs_init.c,v 1.21 2002/03/08 20:48:42 thorpej Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_init.c,v 1.20 2001/11/12 15:25:38 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_init.c,v 1.21 2002/03/08 20:48:42 thorpej Exp $");
#include <sys/param.h>
#include <sys/mount.h>
@@ -330,7 +330,7 @@ vfsinit()
* Initialize the namei pathname buffer pool and cache.
*/
pool_init(&pnbuf_pool, MAXPATHLEN, 0, 0, 0, "pnbufpl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_NAMEI);
+ &pool_allocator_nointr);
pool_cache_init(&pnbuf_cache, &pnbuf_pool, NULL, NULL, NULL);
/*
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index a87a11469da..9accbac6fdd 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_subr.c,v 1.170 2002/03/04 02:25:23 simonb Exp $ */
+/* $NetBSD: vfs_subr.c,v 1.171 2002/03/08 20:48:42 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -82,7 +82,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.170 2002/03/04 02:25:23 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.171 2002/03/08 20:48:42 thorpej Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@@ -189,7 +189,7 @@ vntblinit()
{
pool_init(&vnode_pool, sizeof(struct vnode), 0, 0, 0, "vnodepl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_VNODE);
+ &pool_allocator_nointr);
/*
* Initialize the filesystem syncer.
diff --git a/sys/msdosfs/msdosfs_denode.c b/sys/msdosfs/msdosfs_denode.c
index db2aedacf1c..f1591605d03 100644
--- a/sys/msdosfs/msdosfs_denode.c
+++ b/sys/msdosfs/msdosfs_denode.c
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_denode.c,v 1.54 2002/01/08 20:11:00 jdolecek Exp $ */
+/* $NetBSD: msdosfs_denode.c,v 1.55 2002/03/08 20:48:42 thorpej Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.54 2002/01/08 20:11:00 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.55 2002/03/08 20:48:42 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -98,8 +98,7 @@ msdosfs_init()
M_WAITOK, &dehash);
simple_lock_init(&msdosfs_ihash_slock);
pool_init(&msdosfs_denode_pool, sizeof(struct denode), 0, 0, 0,
- "msdosnopl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_MSDOSFSNODE);
+ "msdosnopl", &pool_allocator_nointr);
}
/*
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index 9d89309d5b7..6212aa41401 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -1,4 +1,4 @@
-/* $NetBSD: if_bridge.c,v 1.3 2001/11/12 23:49:37 lukem Exp $ */
+/* $NetBSD: if_bridge.c,v 1.4 2002/03/08 20:48:43 thorpej Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.3 2001/11/12 23:49:37 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.4 2002/03/08 20:48:43 thorpej Exp $");
#include "bpfilter.h"
#include "rnd.h"
@@ -303,7 +303,7 @@ bridgeattach(int n)
{
pool_init(&bridge_rtnode_pool, sizeof(struct bridge_rtnode),
- 0, 0, 0, "brtpl", 0, NULL, NULL, 0);
+ 0, 0, 0, "brtpl", NULL);
LIST_INIT(&bridge_list);
if_clone_attach(&bridge_cloner);
diff --git a/sys/net/route.c b/sys/net/route.c
index 987c908185a..037244743f4 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $NetBSD: route.c,v 1.50 2001/11/12 23:49:48 lukem Exp $ */
+/* $NetBSD: route.c,v 1.51 2002/03/08 20:48:43 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -102,7 +102,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.50 2001/11/12 23:49:48 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.51 2002/03/08 20:48:43 thorpej Exp $");
#include "opt_ns.h"
@@ -160,7 +160,7 @@ route_init()
{
pool_init(&rtentry_pool, sizeof(struct rtentry), 0, 0, 0, "rtentpl",
- 0, NULL, NULL, M_RTABLE);
+ NULL);
rn_init(); /* initialize all zeroes, all ones, mask table */
rtable_init((void **)rt_tables);
@@ -874,7 +874,7 @@ rt_timer_init()
assert(rt_init_done == 0);
pool_init(&rttimer_pool, sizeof(struct rttimer), 0, 0, 0, "rttmrpl",
- 0, NULL, NULL, M_RTABLE);
+ NULL);
LIST_INIT(&rttimer_queue_head);
callout_init(&rt_timer_ch);
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 8945c942721..18f906d6d19 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1,4 +1,4 @@
-/* $NetBSD: in_pcb.c,v 1.74 2002/01/22 03:53:55 itojun Exp $ */
+/* $NetBSD: in_pcb.c,v 1.75 2002/03/08 20:48:43 thorpej Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -102,7 +102,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.74 2002/01/22 03:53:55 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.75 2002/03/08 20:48:43 thorpej Exp $");
#include "opt_ipsec.h"
@@ -164,7 +164,7 @@ in_pcbinit(table, bindhashsize, connecthashsize)
if (inpcb_pool_initialized == 0) {
pool_init(&inpcb_pool, sizeof(struct inpcb), 0, 0, 0,
- "inpcbpl", 0, NULL, NULL, M_PCB);
+ "inpcbpl", NULL);
inpcb_pool_initialized = 1;
}
diff --git a/sys/netinet/ip_flow.c b/sys/netinet/ip_flow.c
index 2fb84f68c8c..e24175debdb 100644
--- a/sys/netinet/ip_flow.c
+++ b/sys/netinet/ip_flow.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_flow.c,v 1.22 2001/11/13 00:32:37 lukem Exp $ */
+/* $NetBSD: ip_flow.c,v 1.23 2002/03/08 20:48:43 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 1.22 2001/11/13 00:32:37 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 1.23 2002/03/08 20:48:43 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -132,7 +132,7 @@ ipflow_init()
int i;
pool_init(&ipflow_pool, sizeof(struct ipflow), 0, 0, 0, "ipflowpl",
- 0, NULL, NULL, M_IPFLOW);
+ NULL);
LIST_INIT(&ipflowlist);
for (i = 0; i < IPFLOW_HASHSIZE; i++)
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 66acf6fb031..a5b385e9a3a 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_input.c,v 1.145 2002/02/25 02:17:55 itojun Exp $ */
+/* $NetBSD: ip_input.c,v 1.146 2002/03/08 20:48:43 thorpej Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -102,7 +102,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.145 2002/02/25 02:17:55 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_input.c,v 1.146 2002/03/08 20:48:43 thorpej Exp $");
#include "opt_gateway.h"
#include "opt_pfil_hooks.h"
@@ -318,7 +318,7 @@ ip_init()
int i;
pool_init(&ipqent_pool, sizeof(struct ipqent), 0, 0, 0, "ipqepl",
- 0, NULL, NULL, M_IPQ);
+ NULL);
pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW);
if (pr == 0)
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index 9a45e8fc645..22c086454e7 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_input.c,v 1.134 2002/01/24 02:12:29 itojun Exp $ */
+/* $NetBSD: tcp_input.c,v 1.135 2002/03/08 20:48:44 thorpej Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -152,7 +152,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.134 2002/01/24 02:12:29 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.135 2002/03/08 20:48:44 thorpej Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -2659,7 +2659,7 @@ syn_cache_init()
/* Initialize the syn cache pool. */
pool_init(&syn_cache_pool, sizeof(struct syn_cache), 0, 0, 0,
- "synpl", 0, NULL, NULL, M_PCB);
+ "synpl", NULL);
}
void
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index c65527c6382..20d5f767469 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_subr.c,v 1.122 2001/11/13 00:32:41 lukem Exp $ */
+/* $NetBSD: tcp_subr.c,v 1.123 2002/03/08 20:48:44 thorpej Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -102,7 +102,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.122 2001/11/13 00:32:41 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.123 2002/03/08 20:48:44 thorpej Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -236,7 +236,7 @@ tcp_init()
int hlen;
pool_init(&tcpcb_pool, sizeof(struct tcpcb), 0, 0, 0, "tcpcbpl",
- 0, NULL, NULL, M_PCB);
+ NULL);
in_pcbinit(&tcbtable, tcbhashsize, tcbhashsize);
#ifdef INET6
tcb6.in6p_next = tcb6.in6p_prev = &tcb6;
diff --git a/sys/nfs/nfs_node.c b/sys/nfs/nfs_node.c
index 756a74dcd7e..4836ab290df 100644
--- a/sys/nfs/nfs_node.c
+++ b/sys/nfs/nfs_node.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_node.c,v 1.51 2002/01/26 02:52:20 chs Exp $ */
+/* $NetBSD: nfs_node.c,v 1.52 2002/03/08 20:48:45 thorpej Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.51 2002/01/26 02:52:20 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.52 2002/03/08 20:48:45 thorpej Exp $");
#include "opt_nfs.h"
@@ -99,9 +99,9 @@ nfs_nhinit()
lockinit(&nfs_hashlock, PINOD, "nfs_hashlock", 0, 0);
pool_init(&nfs_node_pool, sizeof(struct nfsnode), 0, 0, 0, "nfsnodepl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_NFSNODE);
+ &pool_allocator_nointr);
pool_init(&nfs_vattr_pool, sizeof(struct vattr), 0, 0, 0, "nfsvapl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_NFSNODE);
+ &pool_allocator_nointr);
}
/*
diff --git a/sys/sys/pool.h b/sys/sys/pool.h
index 7bf59c9bf3f..714f4be3747 100644
--- a/sys/sys/pool.h
+++ b/sys/sys/pool.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pool.h,v 1.28 2001/10/07 12:44:06 bjh21 Exp $ */
+/* $NetBSD: pool.h,v 1.29 2002/03/08 20:48:45 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -82,6 +82,21 @@ struct pool_cache {
unsigned long pc_nitems; /* # objects currently in cache */
};
+struct pool_allocator {
+ void *(*pa_alloc)(struct pool *, int);
+ void (*pa_free)(struct pool *, void *);
+ int pa_pagesz;
+
+ /* The following fields are for internal use only. */
+ struct simplelock pa_slock;
+ TAILQ_HEAD(, pool) pa_list; /* list of pools using this allocator */
+ int pa_flags;
+#define PA_INITIALIZED 0x01
+#define PA_WANT 0x02 /* wakeup any sleeping pools on free */
+ int pa_pagemask;
+ int pa_pageshift;
+};
+
struct pool {
TAILQ_ENTRY(pool)
pr_poollist;
@@ -97,32 +112,27 @@ struct pool {
unsigned int pr_minpages; /* same in page units */
unsigned int pr_maxpages; /* maximum # of pages to keep */
unsigned int pr_npages; /* # of pages allocated */
- unsigned int pr_pagesz; /* page size, must be 2^n */
- unsigned long pr_pagemask; /* abbrev. of above */
- unsigned int pr_pageshift; /* shift corr. to above */
unsigned int pr_itemsperpage;/* # items that fit in a page */
unsigned int pr_slack; /* unused space in a page */
unsigned int pr_nitems; /* number of available items in pool */
unsigned int pr_nout; /* # items currently allocated */
unsigned int pr_hardlimit; /* hard limit to number of allocated
items */
- void *(*pr_alloc)(unsigned long, int, int);
- void (*pr_free)(void *, unsigned long, int);
- int pr_mtype; /* memory allocator tag */
+ struct pool_allocator *pr_alloc;/* back-end allocator */
+ TAILQ_ENTRY(pool) pr_alloc_list;/* link on allocator's pool list */
const char *pr_wchan; /* tsleep(9) identifier */
unsigned int pr_flags; /* r/w flags */
unsigned int pr_roflags; /* r/o flags */
-#define PR_MALLOCOK 1
-#define PR_NOWAIT 0 /* for symmetry */
-#define PR_WAITOK 2
-#define PR_WANTED 4
-#define PR_STATIC 8
-#define PR_FREEHEADER 16
-#define PR_URGENT 32
-#define PR_PHINPAGE 64
-#define PR_LOGGING 128
-#define PR_LIMITFAIL 256 /* even if waiting, fail if we hit limit */
-#define PR_RECURSIVE 512 /* pool contains pools, for vmstat(8) */
+#define PR_MALLOCOK 0x01
+#define PR_NOWAIT 0x00 /* for symmetry */
+#define PR_WAITOK 0x02
+#define PR_WANTED 0x04
+#define PR_STATIC 0x08
+#define PR_FREEHEADER 0x10
+#define PR_PHINPAGE 0x40
+#define PR_LOGGING 0x80
+#define PR_LIMITFAIL 0x100 /* even if waiting, fail if we hit limit */
+#define PR_RECURSIVE 0x200 /* pool contains pools, for vmstat(8) */
/*
* `pr_slock' protects the pool's data structures when removing
@@ -174,16 +184,22 @@ struct pool {
#endif /* __POOL_EXPOSE */
#ifdef _KERNEL
+/*
+ * pool_allocator_kmem is the default that all pools get unless
+ * otherwise specified. pool_allocator_nointr is provided for
+ * pools that know they will never be accessed in interrupt
+ * context.
+ */
+extern struct pool_allocator pool_allocator_kmem;
+extern struct pool_allocator pool_allocator_nointr;
+
void pool_init(struct pool *, size_t, u_int, u_int,
- int, const char *, size_t,
- void *(*)__P((unsigned long, int, int)),
- void (*)__P((void *, unsigned long, int)),
- int);
+ int, const char *, struct pool_allocator *);
void pool_destroy(struct pool *);
void *pool_get(struct pool *, int);
void pool_put(struct pool *, void *);
-void pool_reclaim(struct pool *);
+int pool_reclaim(struct pool *);
#ifdef POOL_DIAGNOSTIC
/*
@@ -212,13 +228,6 @@ void pool_printit(struct pool *, const char *,
int pool_chk(struct pool *, const char *);
/*
- * Alternate pool page allocator, provided for pools that know they
- * will never be accessed in interrupt context.
- */
-void *pool_page_alloc_nointr(unsigned long, int, int);
-void pool_page_free_nointr(void *, unsigned long, int);
-
-/*
* Pool cache routines.
*/
void pool_cache_init(struct pool_cache *, struct pool *,
diff --git a/sys/ufs/ext2fs/ext2fs_vfsops.c b/sys/ufs/ext2fs/ext2fs_vfsops.c
index b9fa50f8a6e..c9595b8c009 100644
--- a/sys/ufs/ext2fs/ext2fs_vfsops.c
+++ b/sys/ufs/ext2fs/ext2fs_vfsops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ext2fs_vfsops.c,v 1.48 2001/11/08 02:39:08 lukem Exp $ */
+/* $NetBSD: ext2fs_vfsops.c,v 1.49 2002/03/08 20:48:45 thorpej Exp $ */
/*
* Copyright (c) 1997 Manuel Bouyer.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.48 2001/11/08 02:39:08 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.49 2002/03/08 20:48:45 thorpej Exp $");
#if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h"
@@ -130,8 +130,7 @@ ext2fs_init()
* XXX Same structure as FFS inodes? Should we share a common pool?
*/
pool_init(&ext2fs_inode_pool, sizeof(struct inode), 0, 0, 0,
- "ext2fsinopl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_EXT2FSNODE);
+ "ext2fsinopl", &pool_allocator_nointr);
}
void
diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c
index 20f059a6f6b..f136b5f6a75 100644
--- a/sys/ufs/ffs/ffs_softdep.c
+++ b/sys/ufs/ffs/ffs_softdep.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_softdep.c,v 1.29 2002/02/22 08:23:16 enami Exp $ */
+/* $NetBSD: ffs_softdep.c,v 1.30 2002/03/08 20:48:45 thorpej Exp $ */
/*
* Copyright 1998 Marshall Kirk McKusick. All Rights Reserved.
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_softdep.c,v 1.29 2002/02/22 08:23:16 enami Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_softdep.c,v 1.30 2002/03/08 20:48:45 thorpej Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -1067,53 +1067,39 @@ softdep_initialize()
&newblk_hash);
sema_init(&newblk_in_progress, "newblk", PRIBIO, 0);
pool_init(&sdpcpool, sizeof(struct buf), 0, 0, 0, "sdpcpool",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_TEMP);
+ &pool_allocator_nointr);
for (i = 0; i < PCBPHASHSIZE; i++) {
LIST_INIT(&pcbphashhead[i]);
}
pool_init(&pagedep_pool, sizeof(struct pagedep), 0, 0, 0,
- "pagedeppl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_PAGEDEP);
+ "pagedeppl", &pool_allocator_nointr);
pool_init(&inodedep_pool, sizeof(struct inodedep), 0, 0, 0,
- "inodedeppl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_INODEDEP);
+ "inodedeppl", &pool_allocator_nointr);
pool_init(&newblk_pool, sizeof(struct newblk), 0, 0, 0,
- "newblkpl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_NEWBLK);
+ "newblkpl", &pool_allocator_nointr);
pool_init(&bmsafemap_pool, sizeof(struct bmsafemap), 0, 0, 0,
- "bmsafemappl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_BMSAFEMAP);
+ "bmsafemappl", &pool_allocator_nointr);
pool_init(&allocdirect_pool, sizeof(struct allocdirect), 0, 0, 0,
- "allocdirectpl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_ALLOCDIRECT);
+ "allocdirectpl", &pool_allocator_nointr);
pool_init(&indirdep_pool, sizeof(struct indirdep), 0, 0, 0,
- "indirdeppl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_INDIRDEP);
+ "indirdeppl", &pool_allocator_nointr);
pool_init(&allocindir_pool, sizeof(struct allocindir), 0, 0, 0,
- "allocindirpl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_ALLOCINDIR);
+ "allocindirpl", &pool_allocator_nointr);
pool_init(&freefrag_pool, sizeof(struct freefrag), 0, 0, 0,
- "freefragpl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_FREEFRAG);
+ "freefragpl", &pool_allocator_nointr);
pool_init(&freeblks_pool, sizeof(struct freeblks), 0, 0, 0,
- "freeblkspl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_FREEBLKS);
+ "freeblkspl", &pool_allocator_nointr);
pool_init(&freefile_pool, sizeof(struct freefile), 0, 0, 0,
- "freefilepl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_FREEFILE);
+ "freefilepl", &pool_allocator_nointr);
pool_init(&diradd_pool, sizeof(struct diradd), 0, 0, 0,
- "diraddpl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_DIRADD);
+ "diraddpl", &pool_allocator_nointr);
pool_init(&mkdir_pool, sizeof(struct mkdir), 0, 0, 0,
- "mkdirpl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_MKDIR);
+ "mkdirpl", &pool_allocator_nointr);
pool_init(&dirrem_pool, sizeof(struct dirrem), 0, 0, 0,
- "dirrempl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_DIRREM);
+ "dirrempl", &pool_allocator_nointr);
pool_init(&newdirblk_pool, sizeof (struct newdirblk), 0, 0, 0,
- "newdirblkpl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_NEWDIRBLK);
+ "newdirblkpl", &pool_allocator_nointr);
}
/*
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index 39a88893dc3..cd7023d7b92 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_vfsops.c,v 1.92 2002/02/28 21:59:23 pooka Exp $ */
+/* $NetBSD: ffs_vfsops.c,v 1.93 2002/03/08 20:48:46 thorpej Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1994
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.92 2002/02/28 21:59:23 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.93 2002/03/08 20:48:46 thorpej Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -1249,7 +1249,7 @@ ffs_init()
ufs_init();
pool_init(&ffs_inode_pool, sizeof(struct inode), 0, 0, 0, "ffsinopl",
- 0, pool_page_alloc_nointr, pool_page_free_nointr, M_FFSNODE);
+ &pool_allocator_nointr);
}
void
diff --git a/sys/ufs/lfs/lfs_vfsops.c b/sys/ufs/lfs/lfs_vfsops.c
index 9babc5be78e..4c6e2f2061b 100644
--- a/sys/ufs/lfs/lfs_vfsops.c
+++ b/sys/ufs/lfs/lfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_vfsops.c,v 1.71 2001/12/18 07:51:18 chs Exp $ */
+/* $NetBSD: lfs_vfsops.c,v 1.72 2002/03/08 20:48:46 thorpej Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.71 2001/12/18 07:51:18 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.72 2002/03/08 20:48:46 thorpej Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@@ -164,8 +164,7 @@ lfs_init()
* XXX Same structure as FFS inodes? Should we share a common pool?
*/
pool_init(&lfs_inode_pool, sizeof(struct inode), 0, 0, 0,
- "lfsinopl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_LFSNODE);
+ "lfsinopl", &pool_allocator_nointr);
}
void
diff --git a/sys/uvm/uvm_amap.c b/sys/uvm/uvm_amap.c
index a33c94307dd..c19c7f473b4 100644
--- a/sys/uvm/uvm_amap.c
+++ b/sys/uvm/uvm_amap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_amap.c,v 1.41 2002/02/25 00:39:16 chs Exp $ */
+/* $NetBSD: uvm_amap.c,v 1.42 2002/03/08 20:48:46 thorpej Exp $ */
/*
*
@@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.41 2002/02/25 00:39:16 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.42 2002/03/08 20:48:46 thorpej Exp $");
#undef UVM_AMAP_INLINE /* enable/disable amap inlines */
@@ -162,8 +162,7 @@ amap_init(void)
*/
pool_init(&uvm_amap_pool, sizeof(struct vm_amap), 0, 0, 0,
- "amappl", 0, pool_page_alloc_nointr, pool_page_free_nointr,
- M_UVMAMAP);
+ "amappl", &pool_allocator_nointr);
}
/*
diff --git a/sys/uvm/uvm_aobj.c b/sys/uvm/uvm_aobj.c
index f7b0092ba13..82057b6e539 100644
--- a/sys/uvm/uvm_aobj.c
+++ b/sys/uvm/uvm_aobj.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_aobj.c,v 1.49 2001/11/10 07:36:59 lukem Exp $ */
+/* $NetBSD: uvm_aobj.c,v 1.50 2002/03/08 20:48:47 thorpej Exp $ */
/*
* Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.49 2001/11/10 07:36:59 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.50 2002/03/08 20:48:47 thorpej Exp $");
#include "opt_uvmhist.h"
@@ -584,10 +584,9 @@ uao_init(void)
*/
pool_init(&uao_swhash_elt_pool, sizeof(struct uao_swhash_elt),
- 0, 0, 0, "uaoeltpl", 0, NULL, NULL, M_UVMAOBJ);
+ 0, 0, 0, "uaoeltpl", NULL);
pool_init(&uvm_aobj_pool, sizeof(struct uvm_aobj), 0, 0, 0,
- "aobjpl", 0,
- pool_page_alloc_nointr, pool_page_free_nointr, M_UVMAOBJ);
+ "aobjpl", &pool_allocator_nointr);
}
/*
diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c
index 2af10c62b70..5f19f6e540c 100644
--- a/sys/uvm/uvm_map.c
+++ b/sys/uvm/uvm_map.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_map.c,v 1.117 2001/12/31 22:34:40 chs Exp $ */
+/* $NetBSD: uvm_map.c,v 1.118 2002/03/08 20:48:47 thorpej Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.117 2001/12/31 22:34:40 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.118 2002/03/08 20:48:47 thorpej Exp $");
#include "opt_ddb.h"
#include "opt_uvmhist.h"
@@ -365,13 +365,11 @@ uvm_map_init()
* initialize the map-related pools.
*/
pool_init(&uvm_vmspace_pool, sizeof(struct vmspace),
- 0, 0, 0, "vmsppl", 0,
- pool_page_alloc_nointr, pool_page_free_nointr, M_VMMAP);
+ 0, 0, 0, "vmsppl", &pool_allocator_nointr);
pool_init(&uvm_map_entry_pool, sizeof(struct vm_map_entry),
- 0, 0, 0, "vmmpepl", 0,
- pool_page_alloc_nointr, pool_page_free_nointr, M_VMMAP);
+ 0, 0, 0, "vmmpepl", &pool_allocator_nointr);
pool_init(&uvm_map_entry_kmem_pool, sizeof(struct vm_map_entry),
- 0, 0, 0, "vmmpekpl", 0, NULL, NULL, M_VMMAP);
+ 0, 0, 0, "vmmpekpl", NULL);
}
/*
diff --git a/sys/uvm/uvm_swap.c b/sys/uvm/uvm_swap.c
index c15c6ba35eb..941d6cfd47b 100644
--- a/sys/uvm/uvm_swap.c
+++ b/sys/uvm/uvm_swap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_swap.c,v 1.58 2001/12/16 04:51:34 enami Exp $ */
+/* $NetBSD: uvm_swap.c,v 1.59 2002/03/08 20:48:47 thorpej Exp $ */
/*
* Copyright (c) 1995, 1996, 1997 Matthew R. Green
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.58 2001/12/16 04:51:34 enami Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.59 2002/03/08 20:48:47 thorpej Exp $");
#include "fs_nfs.h"
#include "opt_uvmhist.h"
@@ -278,10 +278,10 @@ uvm_swap_init()
*/
pool_init(&vndxfer_pool, sizeof(struct vndxfer), 0, 0, 0,
- "swp vnx", 0, NULL, NULL, 0);
+ "swp vnx", NULL);
pool_init(&vndbuf_pool, sizeof(struct vndbuf), 0, 0, 0,
- "swp vnd", 0, NULL, NULL, 0);
+ "swp vnd", NULL);
/*
* done!