version 1.55, 2001/05/10 04:51:41 |
version 1.56, 2001/05/13 17:06:59 |
Line 572 pool_alloc_item_header(struct pool *pp, |
|
Line 572 pool_alloc_item_header(struct pool *pp, |
|
* Grab an item from the pool; must be called at appropriate spl level |
* Grab an item from the pool; must be called at appropriate spl level |
*/ |
*/ |
void * |
void * |
|
#ifdef DIAGNOSTIC |
_pool_get(struct pool *pp, int flags, const char *file, long line) |
_pool_get(struct pool *pp, int flags, const char *file, long line) |
|
#else |
|
pool_get(struct pool *pp, int flags) |
|
#endif |
{ |
{ |
struct pool_item *pi; |
struct pool_item *pi; |
struct pool_item_header *ph; |
struct pool_item_header *ph; |
Line 584 _pool_get(struct pool *pp, int flags, co |
|
Line 588 _pool_get(struct pool *pp, int flags, co |
|
pr_printlog(pp, NULL, printf); |
pr_printlog(pp, NULL, printf); |
panic("pool_get: static"); |
panic("pool_get: static"); |
} |
} |
#endif |
|
|
|
if (__predict_false(curproc == NULL && doing_shutdown == 0 && |
if (__predict_false(curproc == NULL && doing_shutdown == 0 && |
(flags & PR_WAITOK) != 0)) |
(flags & PR_WAITOK) != 0)) |
panic("pool_get: must have NOWAIT"); |
panic("pool_get: must have NOWAIT"); |
|
#endif |
|
|
simple_lock(&pp->pr_slock); |
simple_lock(&pp->pr_slock); |
pr_enter(pp, file, line); |
pr_enter(pp, file, line); |
Line 728 _pool_get(struct pool *pp, int flags, co |
|
Line 732 _pool_get(struct pool *pp, int flags, co |
|
pp->pr_wchan, pp->pr_nitems); |
pp->pr_wchan, pp->pr_nitems); |
panic("pool_get: nitems inconsistent\n"); |
panic("pool_get: nitems inconsistent\n"); |
} |
} |
#endif |
|
pr_log(pp, v, PRLOG_GET, file, line); |
pr_log(pp, v, PRLOG_GET, file, line); |
|
|
#ifdef DIAGNOSTIC |
|
if (__predict_false(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;" |
Line 807 _pool_get(struct pool *pp, int flags, co |
|
Line 810 _pool_get(struct pool *pp, int flags, co |
|
* Internal version of pool_put(). Pool is already locked/entered. |
* Internal version of pool_put(). Pool is already locked/entered. |
*/ |
*/ |
static void |
static void |
pool_do_put(struct pool *pp, void *v, const char *file, long line) |
pool_do_put(struct pool *pp, void *v) |
{ |
{ |
struct pool_item *pi = v; |
struct pool_item *pi = v; |
struct pool_item_header *ph; |
struct pool_item_header *ph; |
Line 824 pool_do_put(struct pool *pp, void *v, co |
|
Line 827 pool_do_put(struct pool *pp, void *v, co |
|
} |
} |
#endif |
#endif |
|
|
pr_log(pp, v, PRLOG_PUT, file, line); |
|
|
|
if (__predict_false((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 936 pool_do_put(struct pool *pp, void *v, co |
|
Line 937 pool_do_put(struct pool *pp, void *v, co |
|
/* |
/* |
* Return resource to the pool; must be called at appropriate spl level |
* Return resource to the pool; must be called at appropriate spl level |
*/ |
*/ |
|
#ifdef DIAGNOSTIC |
void |
void |
_pool_put(struct pool *pp, void *v, const char *file, long line) |
_pool_put(struct pool *pp, void *v, const char *file, long line) |
{ |
{ |
Line 943 _pool_put(struct pool *pp, void *v, cons |
|
Line 945 _pool_put(struct pool *pp, void *v, cons |
|
simple_lock(&pp->pr_slock); |
simple_lock(&pp->pr_slock); |
pr_enter(pp, file, line); |
pr_enter(pp, file, line); |
|
|
pool_do_put(pp, v, file, line); |
pr_log(pp, v, PRLOG_PUT, file, line); |
|
|
|
pool_do_put(pp, v); |
|
|
pr_leave(pp); |
pr_leave(pp); |
simple_unlock(&pp->pr_slock); |
simple_unlock(&pp->pr_slock); |
} |
} |
|
|
|
#else |
|
void |
|
pool_put(struct pool *pp, void *v) |
|
{ |
|
|
|
simple_lock(&pp->pr_slock); |
|
|
|
pool_do_put(pp, v); |
|
|
|
simple_unlock(&pp->pr_slock); |
|
} |
|
#endif |
|
|
/* |
/* |
* Add N items to the pool. |
* Add N items to the pool. |
*/ |
*/ |
Line 1219 pool_page_free_nointr(void *v, unsigned |
|
Line 1236 pool_page_free_nointr(void *v, unsigned |
|
* Release all complete pages that have not been used recently. |
* Release all complete pages that have not been used recently. |
*/ |
*/ |
void |
void |
|
#ifdef DIAGNOSTIC |
_pool_reclaim(struct pool *pp, const char *file, long line) |
_pool_reclaim(struct pool *pp, const char *file, long line) |
|
#else |
|
pool_reclaim(struct pool *pp) |
|
#endif |
{ |
{ |
struct pool_item_header *ph, *phnext; |
struct pool_item_header *ph, *phnext; |
struct pool_cache *pc; |
struct pool_cache *pc; |
Line 1729 pool_cache_destruct_object(struct pool_c |
|
Line 1750 pool_cache_destruct_object(struct pool_c |
|
*/ |
*/ |
static void |
static void |
pool_cache_do_invalidate(struct pool_cache *pc, int free_groups, |
pool_cache_do_invalidate(struct pool_cache *pc, int free_groups, |
void (*putit)(struct pool *, void *, const char *, long)) |
void (*putit)(struct pool *, void *)) |
{ |
{ |
struct pool_cache_group *pcg, *npcg; |
struct pool_cache_group *pcg, *npcg; |
void *object; |
void *object; |
Line 1744 pool_cache_do_invalidate(struct pool_cac |
|
Line 1765 pool_cache_do_invalidate(struct pool_cac |
|
pc->pc_allocfrom = NULL; |
pc->pc_allocfrom = NULL; |
if (pc->pc_dtor != NULL) |
if (pc->pc_dtor != NULL) |
(*pc->pc_dtor)(pc->pc_arg, object); |
(*pc->pc_dtor)(pc->pc_arg, object); |
(*putit)(pc->pc_pool, object, __FILE__, __LINE__); |
(*putit)(pc->pc_pool, object); |
} |
} |
if (free_groups) { |
if (free_groups) { |
pc->pc_ngroups--; |
pc->pc_ngroups--; |
Line 1767 pool_cache_invalidate(struct pool_cache |
|
Line 1788 pool_cache_invalidate(struct pool_cache |
|
{ |
{ |
|
|
simple_lock(&pc->pc_slock); |
simple_lock(&pc->pc_slock); |
pool_cache_do_invalidate(pc, 0, _pool_put); |
pool_cache_do_invalidate(pc, 0, pool_put); |
simple_unlock(&pc->pc_slock); |
simple_unlock(&pc->pc_slock); |
} |
} |
|
|