version 1.21, 1999/03/31 23:23:48 |
version 1.21.2.3, 1999/06/24 16:14:35 |
Line 73 static struct pool phpool; |
|
Line 73 static struct pool phpool; |
|
int pool_inactive_time = 10; |
int pool_inactive_time = 10; |
|
|
/* Next candidate for drainage (see pool_drain()) */ |
/* Next candidate for drainage (see pool_drain()) */ |
static struct pool *drainpp = NULL; |
static struct pool *drainpp; |
|
|
|
/* This spin lock protects both pool_head and drainpp. */ |
|
struct simplelock pool_head_slock = SIMPLELOCK_INITIALIZER; |
|
|
struct pool_item_header { |
struct pool_item_header { |
/* Page headers */ |
/* Page headers */ |
Line 254 pr_rmpage(pp, ph) |
|
Line 257 pr_rmpage(pp, ph) |
|
pp->pr_npages--; |
pp->pr_npages--; |
pp->pr_npagefree++; |
pp->pr_npagefree++; |
|
|
|
if ((pp->pr_roflags & PR_PHINPAGE) == 0) { |
|
LIST_REMOVE(ph, ph_hashlist); |
|
pool_put(&phpool, ph); |
|
} |
|
|
if (pp->pr_curpage == ph) { |
if (pp->pr_curpage == ph) { |
/* |
/* |
* Find a new non-empty page header, if any. |
* Find a new non-empty page header, if any. |
Line 267 pr_rmpage(pp, ph) |
|
Line 275 pr_rmpage(pp, ph) |
|
|
|
pp->pr_curpage = ph; |
pp->pr_curpage = ph; |
} |
} |
|
|
if ((pp->pr_roflags & PR_PHINPAGE) == 0) { |
|
LIST_REMOVE(ph, ph_hashlist); |
|
pool_put(&phpool, ph); |
|
} |
|
} |
} |
|
|
/* |
/* |
Line 310 pool_create(size, align, ioff, nitems, w |
|
Line 313 pool_create(size, align, ioff, nitems, w |
|
pool_destroy(pp); |
pool_destroy(pp); |
return (NULL); |
return (NULL); |
} |
} |
|
int s; |
} |
} |
|
s = splhigh(); |
|
|
|
splx(s); |
return (pp); |
return (pp); |
} |
} |
|
|
Line 363 pool_init(pp, size, align, ioff, flags, |
|
Line 369 pool_init(pp, size, align, ioff, flags, |
|
/* |
/* |
* Initialize the pool structure. |
* Initialize the pool structure. |
*/ |
*/ |
TAILQ_INSERT_TAIL(&pool_head, pp, pr_poollist); |
|
TAILQ_INIT(&pp->pr_pagelist); |
TAILQ_INIT(&pp->pr_pagelist); |
pp->pr_curpage = NULL; |
pp->pr_curpage = NULL; |
pp->pr_npages = 0; |
pp->pr_npages = 0; |
Line 451 pool_init(pp, size, align, ioff, flags, |
|
Line 456 pool_init(pp, size, align, ioff, flags, |
|
|
|
/* |
/* |
* Initialize private page header pool if we haven't done so yet. |
* Initialize private page header pool if we haven't done so yet. |
|
* XXX LOCKING. |
*/ |
*/ |
if (phpool.pr_size == 0) { |
if (phpool.pr_size == 0) { |
pool_init(&phpool, sizeof(struct pool_item_header), 0, 0, |
pool_init(&phpool, sizeof(struct pool_item_header), 0, 0, |
0, "phpool", 0, 0, 0, 0); |
0, "phpool", 0, 0, 0, 0); |
} |
} |
|
|
return; |
/* 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); |
} |
} |
|
|
/* |
/* |
Line 483 pool_destroy(pp) |
|
Line 492 pool_destroy(pp) |
|
pr_rmpage(pp, ph); |
pr_rmpage(pp, ph); |
|
|
/* Remove from global pool list */ |
/* Remove from global pool list */ |
|
simple_lock(&pool_head_slock); |
TAILQ_REMOVE(&pool_head, pp, pr_poollist); |
TAILQ_REMOVE(&pool_head, pp, pr_poollist); |
|
/* XXX Only clear this if we were drainpp? */ |
drainpp = NULL; |
drainpp = NULL; |
|
simple_unlock(&pool_head_slock); |
|
|
#ifdef POOL_DIAGNOSTIC |
#ifdef POOL_DIAGNOSTIC |
if ((pp->pr_roflags & PR_LOGGING) != 0) |
if ((pp->pr_roflags & PR_LOGGING) != 0) |
Line 1039 pool_catchup(pp) |
|
Line 1051 pool_catchup(pp) |
|
void |
void |
pool_setlowat(pp, n) |
pool_setlowat(pp, n) |
pool_handle_t pp; |
pool_handle_t pp; |
int n; |
int s, n; |
{ |
{ |
int error; |
int error; |
|
|
simple_lock(&pp->pr_slock); |
simple_lock(&pp->pr_slock); |
|
s = splhigh(); |
|
|
|
splx(s); |
pp->pr_minitems = n; |
pp->pr_minitems = n; |
pp->pr_minpages = (n == 0) |
pp->pr_minpages = (n == 0) |
? 0 |
? 0 |
Line 1215 pool_drain(arg) |
|
Line 1229 pool_drain(arg) |
|
void *arg; |
void *arg; |
{ |
{ |
struct pool *pp; |
struct pool *pp; |
int s = splimp(); |
int s; |
|
|
/* XXX:lock pool head */ |
s = splimp(); |
if (drainpp == NULL && (drainpp = TAILQ_FIRST(&pool_head)) == NULL) { |
simple_lock(&pool_head_slock); |
splx(s); |
|
return; |
if (drainpp == NULL && (drainpp = TAILQ_FIRST(&pool_head)) == NULL) |
} |
goto out; |
|
|
pp = drainpp; |
pp = drainpp; |
drainpp = TAILQ_NEXT(pp, pr_poollist); |
drainpp = TAILQ_NEXT(pp, pr_poollist); |
/* XXX:unlock pool head */ |
|
|
|
pool_reclaim(pp); |
pool_reclaim(pp); |
|
|
|
out: |
|
simple_unlock(&pool_head_slock); |
splx(s); |
splx(s); |
} |
} |
|
|