version 1.50.2.12, 2002/11/11 22:13:58 |
version 1.73, 2002/03/09 05:14:33 |
Line 94 struct pool_item_header { |
|
Line 94 struct pool_item_header { |
|
TAILQ_HEAD(,pool_item) ph_itemlist; /* chunk list for this page */ |
TAILQ_HEAD(,pool_item) ph_itemlist; /* chunk list for this page */ |
LIST_ENTRY(pool_item_header) |
LIST_ENTRY(pool_item_header) |
ph_hashlist; /* Off-page page headers */ |
ph_hashlist; /* Off-page page headers */ |
unsigned int ph_nmissing; /* # of chunks in use */ |
int ph_nmissing; /* # of chunks in use */ |
caddr_t ph_page; /* this page's address */ |
caddr_t ph_page; /* this page's address */ |
struct timeval ph_time; /* last referenced */ |
struct timeval ph_time; /* last referenced */ |
}; |
}; |
Line 102 TAILQ_HEAD(pool_pagelist,pool_item_heade |
|
Line 102 TAILQ_HEAD(pool_pagelist,pool_item_heade |
|
|
|
struct pool_item { |
struct pool_item { |
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
u_int pi_magic; |
int pi_magic; |
#endif |
#endif |
#define PI_MAGIC 0xdeadbeefU |
#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 145 struct pool_item { |
|
Line 145 struct pool_item { |
|
/* The cache group pool. */ |
/* The cache group pool. */ |
static struct pool pcgpool; |
static struct pool pcgpool; |
|
|
|
/* The pool cache group. */ |
|
#define PCG_NOBJECTS 16 |
|
struct pool_cache_group { |
|
TAILQ_ENTRY(pool_cache_group) |
|
pcg_list; /* link in the pool cache's group list */ |
|
u_int pcg_avail; /* # available objects */ |
|
/* pointers to the objects */ |
|
void *pcg_objects[PCG_NOBJECTS]; |
|
}; |
|
|
static void pool_cache_reclaim(struct pool_cache *); |
static void pool_cache_reclaim(struct pool_cache *); |
|
|
static int pool_catchup(struct pool *); |
static int pool_catchup(struct pool *); |
Line 415 pool_init(struct pool *pp, size_t size, |
|
Line 425 pool_init(struct pool *pp, size_t size, |
|
if (size < sizeof(struct pool_item)) |
if (size < sizeof(struct pool_item)) |
size = sizeof(struct pool_item); |
size = sizeof(struct pool_item); |
|
|
size = roundup(size, align); |
size = ALIGN(size); |
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
if (size > palloc->pa_pagesz) |
if (size > palloc->pa_pagesz) |
panic("pool_init: pool item size (%lu) too large", |
panic("pool_init: pool item size (%lu) too large", |
Line 564 pool_destroy(struct pool *pp) |
|
Line 574 pool_destroy(struct pool *pp) |
|
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
if (pp->pr_nout != 0) { |
if (pp->pr_nout != 0) { |
pr_printlog(pp, NULL, printf); |
pr_printlog(pp, NULL, printf); |
panic("pool_destroy: pool busy: still out: %u", |
panic("pool_destroy: pool busy: still out: %u\n", |
pp->pr_nout); |
pp->pr_nout); |
} |
} |
#endif |
#endif |
Line 634 pool_get(struct pool *pp, int flags) |
|
Line 644 pool_get(struct pool *pp, int flags) |
|
void *v; |
void *v; |
|
|
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
if (__predict_false(curlwp == NULL && doing_shutdown == 0 && |
if (__predict_false(curproc == NULL && doing_shutdown == 0 && |
(flags & PR_WAITOK) != 0)) |
(flags & PR_WAITOK) != 0)) |
panic("pool_get: %s: must have NOWAIT", pp->pr_wchan); |
panic("pool_get: must have NOWAIT"); |
|
|
#ifdef LOCKDEBUG |
#ifdef LOCKDEBUG |
if (flags & PR_WAITOK) |
if (flags & PR_WAITOK) |
Line 715 pool_get(struct pool *pp, int flags) |
|
Line 725 pool_get(struct pool *pp, int flags) |
|
simple_unlock(&pp->pr_slock); |
simple_unlock(&pp->pr_slock); |
printf("pool_get: %s: curpage NULL, nitems %u\n", |
printf("pool_get: %s: curpage NULL, nitems %u\n", |
pp->pr_wchan, pp->pr_nitems); |
pp->pr_wchan, pp->pr_nitems); |
panic("pool_get: nitems inconsistent"); |
panic("pool_get: nitems inconsistent\n"); |
} |
} |
#endif |
#endif |
|
|
Line 785 pool_get(struct pool *pp, int flags) |
|
Line 795 pool_get(struct pool *pp, int flags) |
|
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", |
pp->pr_wchan, pp->pr_nitems); |
pp->pr_wchan, pp->pr_nitems); |
panic("pool_get: nitems inconsistent"); |
panic("pool_get: nitems inconsistent\n"); |
} |
} |
#endif |
#endif |
|
|
Line 916 pool_do_put(struct pool *pp, void *v) |
|
Line 926 pool_do_put(struct pool *pp, void *v) |
|
#endif |
#endif |
|
|
TAILQ_INSERT_HEAD(&ph->ph_itemlist, pi, pi_list); |
TAILQ_INSERT_HEAD(&ph->ph_itemlist, pi, pi_list); |
KDASSERT(ph->ph_nmissing != 0); |
|
ph->ph_nmissing--; |
ph->ph_nmissing--; |
pp->pr_nput++; |
pp->pr_nput++; |
pp->pr_nitems++; |
pp->pr_nitems++; |
Line 1032 pool_put(struct pool *pp, void *v) |
|
Line 1041 pool_put(struct pool *pp, void *v) |
|
#endif |
#endif |
|
|
/* |
/* |
* Add N items to the pool. |
|
*/ |
|
int |
|
pool_prime(struct pool *pp, int n) |
|
{ |
|
struct pool_item_header *ph; |
|
caddr_t cp; |
|
int newpages; |
|
|
|
simple_lock(&pp->pr_slock); |
|
|
|
newpages = roundup(n, pp->pr_itemsperpage) / pp->pr_itemsperpage; |
|
|
|
while (newpages-- > 0) { |
|
simple_unlock(&pp->pr_slock); |
|
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) |
|
pool_allocator_free(pp, cp); |
|
break; |
|
} |
|
|
|
pool_prime_page(pp, cp, ph); |
|
pp->pr_npagealloc++; |
|
pp->pr_minpages++; |
|
} |
|
|
|
if (pp->pr_minpages >= pp->pr_maxpages) |
|
pp->pr_maxpages = pp->pr_minpages + 1; /* XXX */ |
|
|
|
simple_unlock(&pp->pr_slock); |
|
return (0); |
|
} |
|
|
|
/* |
|
* Add a page worth of items to the pool. |
* Add a page worth of items to the pool. |
* |
* |
* Note, we must be called with the pool descriptor LOCKED. |
* Note, we must be called with the pool descriptor LOCKED. |
Line 1126 pool_prime_page(struct pool *pp, caddr_t |
|
Line 1096 pool_prime_page(struct pool *pp, caddr_t |
|
while (n--) { |
while (n--) { |
pi = (struct pool_item *)cp; |
pi = (struct pool_item *)cp; |
|
|
KASSERT(((((vaddr_t)pi) + ioff) & (align - 1)) == 0); |
|
|
|
/* Insert on page list */ |
/* Insert on page list */ |
TAILQ_INSERT_TAIL(&ph->ph_itemlist, pi, pi_list); |
TAILQ_INSERT_TAIL(&ph->ph_itemlist, pi, pi_list); |
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
Line 1190 pool_catchup(struct pool *pp) |
|
Line 1158 pool_catchup(struct pool *pp) |
|
void |
void |
pool_setlowat(struct pool *pp, int n) |
pool_setlowat(struct pool *pp, int n) |
{ |
{ |
|
int error; |
|
|
simple_lock(&pp->pr_slock); |
simple_lock(&pp->pr_slock); |
|
|
Line 1199 pool_setlowat(struct pool *pp, int n) |
|
Line 1168 pool_setlowat(struct pool *pp, int n) |
|
: roundup(n, pp->pr_itemsperpage) / pp->pr_itemsperpage; |
: roundup(n, pp->pr_itemsperpage) / pp->pr_itemsperpage; |
|
|
/* Make sure we're caught up with the newly-set low water mark. */ |
/* Make sure we're caught up with the newly-set low water mark. */ |
if (POOL_NEEDS_CATCHUP(pp) && pool_catchup(pp) != 0) { |
if (POOL_NEEDS_CATCHUP(pp) && (error = pool_catchup(pp) != 0)) { |
/* |
/* |
* XXX: Should we log a warning? Should we set up a timeout |
* XXX: Should we log a warning? Should we set up a timeout |
* to try again in a second or so? The latter could break |
* to try again in a second or so? The latter could break |
Line 1425 pool_print1(struct pool *pp, const char |
|
Line 1394 pool_print1(struct pool *pp, const char |
|
print_pagelist = 1; |
print_pagelist = 1; |
if (c == 'c') |
if (c == 'c') |
print_cache = 1; |
print_cache = 1; |
|
modif++; |
} |
} |
|
|
(*pr)("POOL %s: size %u, align %u, ioff %u, roflags 0x%08x\n", |
(*pr)("POOL %s: size %u, align %u, ioff %u, roflags 0x%08x\n", |