version 1.3, 1998/07/23 20:34:00 |
version 1.12, 1998/08/28 21:18:37 |
|
|
*/ |
*/ |
|
|
/* List of all pools */ |
/* List of all pools */ |
static TAILQ_HEAD(,pool) pool_head = TAILQ_HEAD_INITIALIZER(pool_head); |
TAILQ_HEAD(,pool) pool_head = TAILQ_HEAD_INITIALIZER(pool_head); |
|
|
/* Private pool for page header structures */ |
/* Private pool for page header structures */ |
static struct pool phpool; |
static struct pool phpool; |
Line 226 pr_rmpage(pp, ph) |
|
Line 226 pr_rmpage(pp, ph) |
|
{ |
{ |
|
|
/* |
/* |
|
* If the page was idle, decrement the idle page count. |
|
*/ |
|
if (ph->ph_nmissing == 0) { |
|
#ifdef DIAGNOSTIC |
|
if (pp->pr_nidle == 0) |
|
panic("pr_rmpage: nidle inconsistent"); |
|
#endif |
|
pp->pr_nidle--; |
|
} |
|
|
|
/* |
* Unlink a page from the pool and release it. |
* Unlink a page from the pool and release it. |
*/ |
*/ |
TAILQ_REMOVE(&pp->pr_pagelist, ph, ph_pagelist); |
TAILQ_REMOVE(&pp->pr_pagelist, ph, ph_pagelist); |
Line 321 pool_init(pp, size, align, ioff, flags, |
|
Line 332 pool_init(pp, size, align, ioff, flags, |
|
if (!powerof2(pagesz) || pagesz > PAGE_SIZE) |
if (!powerof2(pagesz) || pagesz > PAGE_SIZE) |
panic("pool_init: page size invalid (%lx)\n", (u_long)pagesz); |
panic("pool_init: page size invalid (%lx)\n", (u_long)pagesz); |
|
|
if (alloc == NULL) |
if (alloc == NULL && release == NULL) { |
alloc = pool_page_alloc; |
alloc = pool_page_alloc; |
|
|
if (release == NULL) |
|
release = pool_page_free; |
release = pool_page_free; |
|
pagesz = PAGE_SIZE; /* Rounds to PAGE_SIZE anyhow. */ |
|
} else if ((alloc != NULL && release != NULL) == 0) { |
|
/* If you specifiy one, must specify both. */ |
|
panic("pool_init: must specify alloc and release together"); |
|
} |
|
|
if (pagesz == 0) |
if (pagesz == 0) |
pagesz = PAGE_SIZE; |
pagesz = PAGE_SIZE; |
|
|
Line 370 pool_init(pp, size, align, ioff, flags, |
|
Line 384 pool_init(pp, size, align, ioff, flags, |
|
/* The page header will be taken from our page header pool */ |
/* The page header will be taken from our page header pool */ |
pp->pr_phoffset = 0; |
pp->pr_phoffset = 0; |
off = pagesz; |
off = pagesz; |
bzero(pp->pr_hashtab, sizeof(pp->pr_hashtab)); |
memset(pp->pr_hashtab, 0, sizeof(pp->pr_hashtab)); |
} |
} |
|
|
/* |
/* |
Line 397 pool_init(pp, size, align, ioff, flags, |
|
Line 411 pool_init(pp, size, align, ioff, flags, |
|
pp->pr_npagealloc = 0; |
pp->pr_npagealloc = 0; |
pp->pr_npagefree = 0; |
pp->pr_npagefree = 0; |
pp->pr_hiwat = 0; |
pp->pr_hiwat = 0; |
|
pp->pr_nidle = 0; |
|
|
#ifdef POOL_DIAGNOSTIC |
#ifdef POOL_DIAGNOSTIC |
if ((flags & PR_LOGGING) != 0) { |
if ((flags & PR_LOGGING) != 0) { |
|
|
* Remove from item list. |
* Remove from item list. |
*/ |
*/ |
TAILQ_REMOVE(&ph->ph_itemlist, pi, pi_list); |
TAILQ_REMOVE(&ph->ph_itemlist, pi, pi_list); |
|
if (ph->ph_nmissing == 0) { |
|
#ifdef DIAGNOSTIC |
|
if (pp->pr_nidle == 0) |
|
panic("pool_get: nidle inconsistent"); |
|
#endif |
|
pp->pr_nidle--; |
|
} |
ph->ph_nmissing++; |
ph->ph_nmissing++; |
if (TAILQ_FIRST(&ph->ph_itemlist) == NULL) { |
if (TAILQ_FIRST(&ph->ph_itemlist) == NULL) { |
/* |
/* |
|
|
* If this page has just become un-empty, move it the head. |
* If this page has just become un-empty, move it the head. |
*/ |
*/ |
if (ph->ph_nmissing == 0) { |
if (ph->ph_nmissing == 0) { |
|
pp->pr_nidle++; |
if (pp->pr_npages > pp->pr_maxpages) { |
if (pp->pr_npages > pp->pr_maxpages) { |
#if 0 |
#if 0 |
timeout(pool_drain, 0, pool_inactive_time*hz); |
timeout(pool_drain, 0, pool_inactive_time*hz); |
Line 727 pool_prime_page(pp, storage) |
|
Line 750 pool_prime_page(pp, storage) |
|
ph->ph_nmissing = 0; |
ph->ph_nmissing = 0; |
ph->ph_time.tv_sec = ph->ph_time.tv_usec = 0; |
ph->ph_time.tv_sec = ph->ph_time.tv_usec = 0; |
|
|
|
pp->pr_nidle++; |
|
|
/* |
/* |
* Color this page. |
* Color this page. |
*/ |
*/ |
Line 805 pool_page_alloc(sz, flags, mtype) |
|
Line 830 pool_page_alloc(sz, flags, mtype) |
|
int flags; |
int flags; |
int mtype; |
int mtype; |
{ |
{ |
vm_offset_t va; |
boolean_t waitok = (flags & PR_WAITOK) ? TRUE : FALSE; |
|
|
#if defined(UVM) |
#if defined(UVM) |
va = uvm_km_kmemalloc(kernel_map, uvm.kernel_object, |
return ((void *)uvm_km_alloc_poolpage(waitok)); |
(vm_size_t)sz, UVM_KMF_NOWAIT); |
#else |
#else |
return ((void *)kmem_alloc_poolpage(waitok)); |
va = kmem_malloc(kmem_map, (vm_size_t)sz, 0); |
#endif |
#endif |
|
return ((void *)va); |
|
} |
} |
|
|
static void |
static void |
Line 824 pool_page_free(v, sz, mtype) |
|
Line 847 pool_page_free(v, sz, mtype) |
|
{ |
{ |
|
|
#if defined(UVM) |
#if defined(UVM) |
uvm_km_free(kernel_map, (vm_offset_t)v, sz); |
uvm_km_free_poolpage((vaddr_t)v); |
|
#else |
|
kmem_free_poolpage((vaddr_t)v); |
|
#endif |
|
} |
|
|
|
/* |
|
* Alternate pool page allocator for pools that know they will |
|
* never be accessed in interrupt context. |
|
*/ |
|
void * |
|
pool_page_alloc_nointr(sz, flags, mtype) |
|
unsigned long sz; |
|
int flags; |
|
int mtype; |
|
{ |
|
#if defined(UVM) |
|
boolean_t waitok = (flags & PR_WAITOK) ? TRUE : FALSE; |
|
|
|
/* |
|
* With UVM, we can use the kernel_map. |
|
*/ |
|
return ((void *)uvm_km_alloc_poolpage1(kernel_map, uvm.kernel_object, |
|
waitok)); |
|
#else |
|
/* |
|
* Can't do anything so cool with Mach VM. |
|
*/ |
|
return (pool_page_alloc(sz, flags, mtype)); |
|
#endif |
|
} |
|
|
|
void |
|
pool_page_free_nointr(v, sz, mtype) |
|
void *v; |
|
unsigned long sz; |
|
int mtype; |
|
{ |
|
|
|
#if defined(UVM) |
|
uvm_km_free_poolpage1(kernel_map, (vaddr_t)v); |
#else |
#else |
kmem_free(kmem_map, (vm_offset_t)v, sz); |
pool_page_free(v, sz, mtype); |
#endif |
#endif |
} |
} |
|
|
|
|
/* |
/* |
* Release all complete pages that have not been used recently. |
* Release all complete pages that have not been used recently. |
*/ |
*/ |
Line 905 pool_print(pp, label) |
|
Line 969 pool_print(pp, label) |
|
printf("%s: ", label); |
printf("%s: ", label); |
|
|
printf("pool %s: nalloc %lu nfree %lu npagealloc %lu npagefree %lu\n" |
printf("pool %s: nalloc %lu nfree %lu npagealloc %lu npagefree %lu\n" |
" npages %u minitems %u itemsperpage %u itemoffset %u\n", |
" npages %u minitems %u itemsperpage %u itemoffset %u\n" |
|
" nidle %lu\n", |
pp->pr_wchan, |
pp->pr_wchan, |
pp->pr_nget, |
pp->pr_nget, |
pp->pr_nput, |
pp->pr_nput, |
Line 914 pool_print(pp, label) |
|
Line 979 pool_print(pp, label) |
|
pp->pr_npages, |
pp->pr_npages, |
pp->pr_minitems, |
pp->pr_minitems, |
pp->pr_itemsperpage, |
pp->pr_itemsperpage, |
pp->pr_itemoffset); |
pp->pr_itemoffset, |
|
pp->pr_nidle); |
} |
} |
|
|
int |
int |