| version 1.137.2.2, 2007/12/12 22:03:31 |
version 1.137.2.3, 2007/12/15 02:22:22 |
| Line 75 __KERNEL_RCSID(0, "$NetBSD$"); |
|
| Line 75 __KERNEL_RCSID(0, "$NetBSD$"); |
|
| */ |
*/ |
| |
|
| /* List of all pools */ |
/* List of all pools */ |
| LIST_HEAD(,pool) pool_head = LIST_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 */ |
| #define PHPOOL_MAX 8 |
#define PHPOOL_MAX 8 |
| Line 182 static struct pool cache_pool; |
|
| Line 182 static struct pool cache_pool; |
|
| static struct pool cache_cpu_pool; |
static struct pool cache_cpu_pool; |
| |
|
| /* List of all caches. */ |
/* List of all caches. */ |
| LIST_HEAD(,pool_cache) pool_cache_head = |
TAILQ_HEAD(,pool_cache) pool_cache_head = |
| LIST_HEAD_INITIALIZER(pool_cache_head); |
TAILQ_HEAD_INITIALIZER(pool_cache_head); |
| |
|
| int pool_cache_disable; |
int pool_cache_disable; |
| |
|
|
|
| pool_init(struct pool *pp, size_t size, u_int align, u_int ioff, int flags, |
pool_init(struct pool *pp, size_t size, u_int align, u_int ioff, int flags, |
| const char *wchan, struct pool_allocator *palloc, int ipl) |
const char *wchan, struct pool_allocator *palloc, int ipl) |
| { |
{ |
| #ifdef DEBUG |
|
| struct pool *pp1; |
struct pool *pp1; |
| #endif |
|
| size_t trysize, phsize; |
size_t trysize, phsize; |
| int off, slack; |
int off, slack; |
| |
|
| Line 629 pool_init(struct pool *pp, size_t size, |
|
| Line 627 pool_init(struct pool *pp, size_t size, |
|
| * Check that the pool hasn't already been initialised and |
* Check that the pool hasn't already been initialised and |
| * added to the list of all pools. |
* added to the list of all pools. |
| */ |
*/ |
| LIST_FOREACH(pp1, &pool_head, pr_poollist) { |
TAILQ_FOREACH(pp1, &pool_head, pr_poollist) { |
| if (pp == pp1) |
if (pp == pp1) |
| panic("pool_init: pool %s already initialised", |
panic("pool_init: pool %s already initialised", |
| wchan); |
wchan); |
| Line 847 pool_init(struct pool *pp, size_t size, |
|
| Line 845 pool_init(struct pool *pp, size_t size, |
|
| "cachegrp", &pool_allocator_meta, IPL_VM); |
"cachegrp", &pool_allocator_meta, IPL_VM); |
| } |
} |
| |
|
| if (__predict_true(!cold)) { |
/* Insert into the list of all pools. */ |
| /* Insert into the list of all pools. */ |
if (__predict_true(!cold)) |
| mutex_enter(&pool_head_lock); |
mutex_enter(&pool_head_lock); |
| LIST_INSERT_HEAD(&pool_head, pp, pr_poollist); |
TAILQ_FOREACH(pp1, &pool_head, pr_poollist) { |
| |
if (strcmp(pp1->pr_wchan, pp->pr_wchan) > 0) |
| |
break; |
| |
} |
| |
if (pp1 == NULL) |
| |
TAILQ_INSERT_TAIL(&pool_head, pp, pr_poollist); |
| |
else |
| |
TAILQ_INSERT_BEFORE(pp1, pp, pr_poollist); |
| |
if (__predict_true(!cold)) |
| mutex_exit(&pool_head_lock); |
mutex_exit(&pool_head_lock); |
| |
|
| /* Insert this into the list of pools using this allocator. */ |
/* Insert this into the list of pools using this allocator. */ |
| |
if (__predict_true(!cold)) |
| mutex_enter(&palloc->pa_lock); |
mutex_enter(&palloc->pa_lock); |
| TAILQ_INSERT_TAIL(&palloc->pa_list, pp, pr_alloc_list); |
TAILQ_INSERT_TAIL(&palloc->pa_list, pp, pr_alloc_list); |
| |
if (__predict_true(!cold)) |
| mutex_exit(&palloc->pa_lock); |
mutex_exit(&palloc->pa_lock); |
| } else { |
|
| LIST_INSERT_HEAD(&pool_head, pp, pr_poollist); |
|
| TAILQ_INSERT_TAIL(&palloc->pa_list, pp, pr_alloc_list); |
|
| } |
|
| |
|
| pool_reclaim_register(pp); |
pool_reclaim_register(pp); |
| } |
} |
| Line 878 pool_destroy(struct pool *pp) |
|
| Line 882 pool_destroy(struct pool *pp) |
|
| mutex_enter(&pool_head_lock); |
mutex_enter(&pool_head_lock); |
| while (pp->pr_refcnt != 0) |
while (pp->pr_refcnt != 0) |
| cv_wait(&pool_busy, &pool_head_lock); |
cv_wait(&pool_busy, &pool_head_lock); |
| LIST_REMOVE(pp, pr_poollist); |
TAILQ_REMOVE(&pool_head, pp, pr_poollist); |
| if (drainpp == pp) |
if (drainpp == pp) |
| drainpp = NULL; |
drainpp = NULL; |
| mutex_exit(&pool_head_lock); |
mutex_exit(&pool_head_lock); |
| Line 1684 pool_drain_start(struct pool **ppp, uint |
|
| Line 1688 pool_drain_start(struct pool **ppp, uint |
|
| { |
{ |
| struct pool *pp; |
struct pool *pp; |
| |
|
| KASSERT(!LIST_EMPTY(&pool_head)); |
KASSERT(!TAILQ_EMPTY(&pool_head)); |
| |
|
| pp = NULL; |
pp = NULL; |
| |
|
| Line 1692 pool_drain_start(struct pool **ppp, uint |
|
| Line 1696 pool_drain_start(struct pool **ppp, uint |
|
| mutex_enter(&pool_head_lock); |
mutex_enter(&pool_head_lock); |
| do { |
do { |
| if (drainpp == NULL) { |
if (drainpp == NULL) { |
| drainpp = LIST_FIRST(&pool_head); |
drainpp = TAILQ_FIRST(&pool_head); |
| } |
} |
| if (drainpp != NULL) { |
if (drainpp != NULL) { |
| pp = drainpp; |
pp = drainpp; |
| drainpp = LIST_NEXT(pp, pr_poollist); |
drainpp = TAILQ_NEXT(pp, pr_poollist); |
| } |
} |
| /* |
/* |
| * Skip completely idle pools. We depend on at least |
* Skip completely idle pools. We depend on at least |
| Line 1752 pool_printall(const char *modif, void (* |
|
| Line 1756 pool_printall(const char *modif, void (* |
|
| { |
{ |
| struct pool *pp; |
struct pool *pp; |
| |
|
| LIST_FOREACH(pp, &pool_head, pr_poollist) { |
TAILQ_FOREACH(pp, &pool_head, pr_poollist) { |
| pool_printit(pp, modif, pr); |
pool_printit(pp, modif, pr); |
| } |
} |
| } |
} |
| Line 2042 pool_cache_bootstrap(pool_cache_t pc, si |
|
| Line 2046 pool_cache_bootstrap(pool_cache_t pc, si |
|
| void *arg) |
void *arg) |
| { |
{ |
| CPU_INFO_ITERATOR cii; |
CPU_INFO_ITERATOR cii; |
| |
pool_cache_t pc1; |
| struct cpu_info *ci; |
struct cpu_info *ci; |
| struct pool *pp; |
struct pool *pp; |
| |
|
| Line 2092 pool_cache_bootstrap(pool_cache_t pc, si |
|
| Line 2097 pool_cache_bootstrap(pool_cache_t pc, si |
|
| pool_cache_cpu_init1(ci, pc); |
pool_cache_cpu_init1(ci, pc); |
| } |
} |
| } |
} |
| |
|
| if (__predict_true(!cold)) { |
/* Add to list of all pools. */ |
| mutex_enter(&pp->pr_lock); |
if (__predict_true(!cold)) |
| pp->pr_cache = pc; |
|
| mutex_exit(&pp->pr_lock); |
|
| mutex_enter(&pool_head_lock); |
mutex_enter(&pool_head_lock); |
| LIST_INSERT_HEAD(&pool_cache_head, pc, pc_cachelist); |
TAILQ_FOREACH(pc1, &pool_cache_head, pc_cachelist) { |
| mutex_exit(&pool_head_lock); |
if (strcmp(pc1->pc_pool.pr_wchan, pc->pc_pool.pr_wchan) > 0) |
| } else { |
break; |
| pp->pr_cache = pc; |
|
| LIST_INSERT_HEAD(&pool_cache_head, pc, pc_cachelist); |
|
| } |
} |
| |
if (pc1 == NULL) |
| |
TAILQ_INSERT_TAIL(&pool_cache_head, pc, pc_cachelist); |
| |
else |
| |
TAILQ_INSERT_BEFORE(pc1, pc, pc_cachelist); |
| |
if (__predict_true(!cold)) |
| |
mutex_exit(&pool_head_lock); |
| |
|
| |
membar_sync(); |
| |
pp->pr_cache = pc; |
| } |
} |
| |
|
| /* |
/* |
| Line 2123 pool_cache_destroy(pool_cache_t pc) |
|
| Line 2133 pool_cache_destroy(pool_cache_t pc) |
|
| mutex_enter(&pool_head_lock); |
mutex_enter(&pool_head_lock); |
| while (pc->pc_refcnt != 0) |
while (pc->pc_refcnt != 0) |
| cv_wait(&pool_busy, &pool_head_lock); |
cv_wait(&pool_busy, &pool_head_lock); |
| LIST_REMOVE(pc, pc_cachelist); |
TAILQ_REMOVE(&pool_cache_head, pc, pc_cachelist); |
| mutex_exit(&pool_head_lock); |
mutex_exit(&pool_head_lock); |
| |
|
| /* First, invalidate the entire cache. */ |
/* First, invalidate the entire cache. */ |
| Line 2214 pool_cache_cpu_init(struct cpu_info *ci) |
|
| Line 2224 pool_cache_cpu_init(struct cpu_info *ci) |
|
| pool_cache_t pc; |
pool_cache_t pc; |
| |
|
| mutex_enter(&pool_head_lock); |
mutex_enter(&pool_head_lock); |
| LIST_FOREACH(pc, &pool_cache_head, pc_cachelist) { |
TAILQ_FOREACH(pc, &pool_cache_head, pc_cachelist) { |
| pc->pc_refcnt++; |
pc->pc_refcnt++; |
| mutex_exit(&pool_head_lock); |
mutex_exit(&pool_head_lock); |
| |
|