version 1.32, 2000/04/10 02:17:42 |
version 1.38, 2000/06/26 14:21:14 |
|
|
#include <sys/syslog.h> |
#include <sys/syslog.h> |
|
|
#include <vm/vm.h> |
#include <vm/vm.h> |
#include <vm/vm_kern.h> |
|
|
|
#include <uvm/uvm.h> |
#include <uvm/uvm.h> |
|
|
Line 97 struct pool_item_header { |
|
Line 96 struct pool_item_header { |
|
struct pool_item { |
struct pool_item { |
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
int pi_magic; |
int pi_magic; |
#define PI_MAGIC 0xdeadbeef |
|
#endif |
#endif |
|
#define PI_MAGIC 0xdeadbeef |
/* Other entries use only this list entry */ |
/* Other entries use only this list entry */ |
TAILQ_ENTRY(pool_item) pi_list; |
TAILQ_ENTRY(pool_item) pi_list; |
}; |
}; |
Line 215 pr_enter(pp, file, line) |
|
Line 214 pr_enter(pp, file, line) |
|
long line; |
long line; |
{ |
{ |
|
|
if (pp->pr_entered_file != NULL) { |
if (__predict_false(pp->pr_entered_file != NULL)) { |
printf("pool %s: reentrancy at file %s line %ld\n", |
printf("pool %s: reentrancy at file %s line %ld\n", |
pp->pr_wchan, file, line); |
pp->pr_wchan, file, line); |
printf(" previous entry at file %s line %ld\n", |
printf(" previous entry at file %s line %ld\n", |
|
|
struct pool *pp; |
struct pool *pp; |
{ |
{ |
|
|
if (pp->pr_entered_file == NULL) { |
if (__predict_false(pp->pr_entered_file == NULL)) { |
printf("pool %s not entered?\n", pp->pr_wchan); |
printf("pool %s not entered?\n", pp->pr_wchan); |
panic("pr_leave"); |
panic("pr_leave"); |
} |
} |
Line 404 pool_init(pp, size, align, ioff, flags, |
|
Line 403 pool_init(pp, size, align, ioff, flags, |
|
/* |
/* |
* Check arguments and construct default values. |
* Check arguments and construct default values. |
*/ |
*/ |
if (!powerof2(pagesz) || pagesz > PAGE_SIZE) |
if (!powerof2(pagesz)) |
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 && release == NULL) { |
if (alloc == NULL && release == NULL) { |
Line 425 pool_init(pp, size, align, ioff, flags, |
|
Line 424 pool_init(pp, size, align, ioff, flags, |
|
if (size < sizeof(struct pool_item)) |
if (size < sizeof(struct pool_item)) |
size = sizeof(struct pool_item); |
size = sizeof(struct pool_item); |
|
|
|
size = ALIGN(size); |
|
if (size >= pagesz) |
|
panic("pool_init: pool item size (%lu) too large", |
|
(u_long)size); |
|
|
/* |
/* |
* Initialize the pool structure. |
* Initialize the pool structure. |
*/ |
*/ |
Line 436 pool_init(pp, size, align, ioff, flags, |
|
Line 440 pool_init(pp, size, align, ioff, flags, |
|
pp->pr_maxpages = UINT_MAX; |
pp->pr_maxpages = UINT_MAX; |
pp->pr_roflags = flags; |
pp->pr_roflags = flags; |
pp->pr_flags = 0; |
pp->pr_flags = 0; |
pp->pr_size = ALIGN(size); |
pp->pr_size = size; |
pp->pr_align = align; |
pp->pr_align = align; |
pp->pr_wchan = wchan; |
pp->pr_wchan = wchan; |
pp->pr_mtype = mtype; |
pp->pr_mtype = mtype; |
Line 582 _pool_get(pp, flags, file, line) |
|
Line 586 _pool_get(pp, flags, file, line) |
|
struct pool_item_header *ph; |
struct pool_item_header *ph; |
|
|
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
if ((pp->pr_roflags & PR_STATIC) && (flags & PR_MALLOCOK)) { |
if (__predict_false((pp->pr_roflags & PR_STATIC) && |
|
(flags & PR_MALLOCOK))) { |
pr_printlog(pp, NULL, printf); |
pr_printlog(pp, NULL, printf); |
panic("pool_get: static"); |
panic("pool_get: static"); |
} |
} |
#endif |
#endif |
|
|
if (curproc == NULL && (flags & PR_WAITOK) != 0) |
if (__predict_false(curproc == NULL && doing_shutdown == 0 && |
|
(flags & PR_WAITOK) != 0)) |
panic("pool_get: must have NOWAIT"); |
panic("pool_get: must have NOWAIT"); |
|
|
simple_lock(&pp->pr_slock); |
simple_lock(&pp->pr_slock); |
Line 601 _pool_get(pp, flags, file, line) |
|
Line 607 _pool_get(pp, flags, file, line) |
|
* the pool. |
* the pool. |
*/ |
*/ |
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
if (pp->pr_nout > pp->pr_hardlimit) { |
if (__predict_false(pp->pr_nout > pp->pr_hardlimit)) { |
pr_leave(pp); |
pr_leave(pp); |
simple_unlock(&pp->pr_slock); |
simple_unlock(&pp->pr_slock); |
panic("pool_get: %s: crossed hard limit", pp->pr_wchan); |
panic("pool_get: %s: crossed hard limit", pp->pr_wchan); |
} |
} |
#endif |
#endif |
if (pp->pr_nout == pp->pr_hardlimit) { |
if (__predict_false(pp->pr_nout == pp->pr_hardlimit)) { |
if ((flags & PR_WAITOK) && !(flags & PR_LIMITFAIL)) { |
if ((flags & PR_WAITOK) && !(flags & PR_LIMITFAIL)) { |
/* |
/* |
* XXX: A warning isn't logged in this case. Should |
* XXX: A warning isn't logged in this case. Should |
Line 717 _pool_get(pp, flags, file, line) |
|
Line 723 _pool_get(pp, flags, file, line) |
|
goto startover; |
goto startover; |
} |
} |
|
|
if ((v = pi = TAILQ_FIRST(&ph->ph_itemlist)) == NULL) { |
if (__predict_false((v = pi = TAILQ_FIRST(&ph->ph_itemlist)) == NULL)) { |
pr_leave(pp); |
pr_leave(pp); |
simple_unlock(&pp->pr_slock); |
simple_unlock(&pp->pr_slock); |
panic("pool_get: %s: page empty", pp->pr_wchan); |
panic("pool_get: %s: page empty", pp->pr_wchan); |
} |
} |
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
if (pp->pr_nitems == 0) { |
if (__predict_false(pp->pr_nitems == 0)) { |
pr_leave(pp); |
pr_leave(pp); |
simple_unlock(&pp->pr_slock); |
simple_unlock(&pp->pr_slock); |
printf("pool_get: %s: items on itemlist, nitems %u\n", |
printf("pool_get: %s: items on itemlist, nitems %u\n", |
Line 734 _pool_get(pp, flags, file, line) |
|
Line 740 _pool_get(pp, flags, file, line) |
|
pr_log(pp, v, PRLOG_GET, file, line); |
pr_log(pp, v, PRLOG_GET, file, line); |
|
|
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
if (pi->pi_magic != PI_MAGIC) { |
if (__predict_false(pi->pi_magic != PI_MAGIC)) { |
pr_printlog(pp, pi, printf); |
pr_printlog(pp, pi, printf); |
panic("pool_get(%s): free list modified: magic=%x; page %p;" |
panic("pool_get(%s): free list modified: magic=%x; page %p;" |
" item addr %p\n", |
" item addr %p\n", |
Line 750 _pool_get(pp, flags, file, line) |
|
Line 756 _pool_get(pp, flags, file, line) |
|
pp->pr_nout++; |
pp->pr_nout++; |
if (ph->ph_nmissing == 0) { |
if (ph->ph_nmissing == 0) { |
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
if (pp->pr_nidle == 0) |
if (__predict_false(pp->pr_nidle == 0)) |
panic("pool_get: nidle inconsistent"); |
panic("pool_get: nidle inconsistent"); |
#endif |
#endif |
pp->pr_nidle--; |
pp->pr_nidle--; |
Line 758 _pool_get(pp, flags, file, line) |
|
Line 764 _pool_get(pp, flags, file, line) |
|
ph->ph_nmissing++; |
ph->ph_nmissing++; |
if (TAILQ_FIRST(&ph->ph_itemlist) == NULL) { |
if (TAILQ_FIRST(&ph->ph_itemlist) == NULL) { |
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
if (ph->ph_nmissing != pp->pr_itemsperpage) { |
if (__predict_false(ph->ph_nmissing != pp->pr_itemsperpage)) { |
pr_leave(pp); |
pr_leave(pp); |
simple_unlock(&pp->pr_slock); |
simple_unlock(&pp->pr_slock); |
panic("pool_get: %s: nmissing inconsistent", |
panic("pool_get: %s: nmissing inconsistent", |
Line 826 _pool_put(pp, v, file, line) |
|
Line 832 _pool_put(pp, v, file, line) |
|
pr_enter(pp, file, line); |
pr_enter(pp, file, line); |
|
|
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
if (pp->pr_nout == 0) { |
if (__predict_false(pp->pr_nout == 0)) { |
printf("pool %s: putting with none out\n", |
printf("pool %s: putting with none out\n", |
pp->pr_wchan); |
pp->pr_wchan); |
panic("pool_put"); |
panic("pool_put"); |
Line 835 _pool_put(pp, v, file, line) |
|
Line 841 _pool_put(pp, v, file, line) |
|
|
|
pr_log(pp, v, PRLOG_PUT, file, line); |
pr_log(pp, v, PRLOG_PUT, file, line); |
|
|
if ((ph = pr_find_pagehead(pp, page)) == NULL) { |
if (__predict_false((ph = pr_find_pagehead(pp, page)) == NULL)) { |
pr_printlog(pp, NULL, printf); |
pr_printlog(pp, NULL, printf); |
panic("pool_put: %s: page header missing", pp->pr_wchan); |
panic("pool_put: %s: page header missing", pp->pr_wchan); |
} |
} |
Line 961 pool_prime(pp, n, storage) |
|
Line 967 pool_prime(pp, n, storage) |
|
int newnitems, newpages; |
int newnitems, newpages; |
|
|
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
if (storage && !(pp->pr_roflags & PR_STATIC)) |
if (__predict_false(storage && !(pp->pr_roflags & PR_STATIC))) |
panic("pool_prime: static"); |
panic("pool_prime: static"); |
/* !storage && static caught below */ |
/* !storage && static caught below */ |
#endif |
#endif |
Line 1019 pool_prime_page(pp, storage) |
|
Line 1025 pool_prime_page(pp, storage) |
|
unsigned int ioff = pp->pr_itemoffset; |
unsigned int ioff = pp->pr_itemoffset; |
int s, n; |
int s, n; |
|
|
|
if (((u_long)cp & (pp->pr_pagesz - 1)) != 0) |
|
panic("pool_prime_page: %s: unaligned page", pp->pr_wchan); |
|
|
if ((pp->pr_roflags & PR_PHINPAGE) != 0) { |
if ((pp->pr_roflags & PR_PHINPAGE) != 0) { |
ph = (struct pool_item_header *)(cp + pp->pr_phoffset); |
ph = (struct pool_item_header *)(cp + pp->pr_phoffset); |
} else { |
} else { |
Line 1121 pool_catchup(pp) |
|
Line 1130 pool_catchup(pp) |
|
simple_unlock(&pp->pr_slock); |
simple_unlock(&pp->pr_slock); |
cp = (*pp->pr_alloc)(pp->pr_pagesz, 0, pp->pr_mtype); |
cp = (*pp->pr_alloc)(pp->pr_pagesz, 0, pp->pr_mtype); |
simple_lock(&pp->pr_slock); |
simple_lock(&pp->pr_slock); |
if (cp == NULL) { |
if (__predict_false(cp == NULL)) { |
error = ENOMEM; |
error = ENOMEM; |
break; |
break; |
} |
} |