version 1.74.2.2, 2002/03/12 15:54:04 |
version 1.75, 2002/03/13 08:12:58 |
|
|
/* $NetBSD$ */ |
/* $NetBSD$ */ |
|
|
/*- |
/*- |
* Copyright (c) 1997, 1999, 2000, 2002 The NetBSD Foundation, Inc. |
* Copyright (c) 1997, 1999, 2000 The NetBSD Foundation, Inc. |
* All rights reserved. |
* All rights reserved. |
* |
* |
* This code is derived from software contributed to The NetBSD Foundation |
* This code is derived from software contributed to The NetBSD Foundation |
Line 425 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 871 pool_get(struct pool *pp, int flags) |
|
Line 871 pool_get(struct pool *pp, int flags) |
|
|
|
pr_leave(pp); |
pr_leave(pp); |
simple_unlock(&pp->pr_slock); |
simple_unlock(&pp->pr_slock); |
KASSERT((((vaddr_t)v + pp->pr_itemoffset) & (pp->pr_align - 1)) == 0); |
|
return (v); |
return (v); |
} |
} |
|
|
Line 1049 pool_prime(struct pool *pp, int n) |
|
Line 1048 pool_prime(struct pool *pp, int n) |
|
{ |
{ |
struct pool_item_header *ph; |
struct pool_item_header *ph; |
caddr_t cp; |
caddr_t cp; |
int newpages, error = 0; |
int newpages; |
|
|
simple_lock(&pp->pr_slock); |
simple_lock(&pp->pr_slock); |
|
|
Line 1063 pool_prime(struct pool *pp, int n) |
|
Line 1062 pool_prime(struct pool *pp, int n) |
|
simple_lock(&pp->pr_slock); |
simple_lock(&pp->pr_slock); |
|
|
if (__predict_false(cp == NULL || ph == NULL)) { |
if (__predict_false(cp == NULL || ph == NULL)) { |
error = ENOMEM; |
|
if (cp != NULL) |
if (cp != NULL) |
pool_allocator_free(pp, cp); |
pool_allocator_free(pp, cp); |
break; |
break; |
Line 1091 pool_prime_page(struct pool *pp, caddr_t |
|
Line 1089 pool_prime_page(struct pool *pp, caddr_t |
|
{ |
{ |
struct pool_item *pi; |
struct pool_item *pi; |
caddr_t cp = storage; |
caddr_t cp = storage; |
const unsigned int align = pp->pr_align; |
unsigned int align = pp->pr_align; |
const unsigned int ioff = pp->pr_itemoffset; |
unsigned int ioff = pp->pr_itemoffset; |
int n; |
int n; |
|
|
#ifdef DIAGNOSTIC |
#ifdef DIAGNOSTIC |
Line 1128 pool_prime_page(struct pool *pp, caddr_t |
|
Line 1126 pool_prime_page(struct pool *pp, caddr_t |
|
if (ioff != 0) |
if (ioff != 0) |
cp = (caddr_t)(cp + (align - ioff)); |
cp = (caddr_t)(cp + (align - ioff)); |
|
|
KASSERT((((vaddr_t)cp + ioff) & (align - 1)) == 0); |
|
|
|
/* |
/* |
* Insert remaining chunks on the bucket list. |
* Insert remaining chunks on the bucket list. |
*/ |
*/ |
Line 1145 pool_prime_page(struct pool *pp, caddr_t |
|
Line 1141 pool_prime_page(struct pool *pp, caddr_t |
|
pi->pi_magic = PI_MAGIC; |
pi->pi_magic = PI_MAGIC; |
#endif |
#endif |
cp = (caddr_t)(cp + pp->pr_size); |
cp = (caddr_t)(cp + pp->pr_size); |
|
|
KASSERT((((vaddr_t)cp + ioff) & (align - 1)) == 0); |
|
} |
} |
|
|
/* |
/* |
Line 1203 pool_catchup(struct pool *pp) |
|
Line 1197 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 1213 pool_setlowat(struct pool *pp, int n) |
|
Line 1206 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) && (error = pool_catchup(pp) != 0)) { |
if (POOL_NEEDS_CATCHUP(pp) && 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 1702 pool_cache_get(struct pool_cache *pc, in |
|
Line 1695 pool_cache_get(struct pool_cache *pc, in |
|
return (NULL); |
return (NULL); |
} |
} |
} |
} |
KASSERT((((vaddr_t)object + pc->pc_pool->pr_itemoffset) & |
|
(pc->pc_pool->pr_align - 1)) == 0); |
|
return (object); |
return (object); |
} |
} |
|
|
Line 1717 pool_cache_get(struct pool_cache *pc, in |
|
Line 1708 pool_cache_get(struct pool_cache *pc, in |
|
|
|
simple_unlock(&pc->pc_slock); |
simple_unlock(&pc->pc_slock); |
|
|
KASSERT((((vaddr_t)object + pc->pc_pool->pr_itemoffset) & |
|
(pc->pc_pool->pr_align - 1)) == 0); |
|
return (object); |
return (object); |
} |
} |
|
|