diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2008-12-23 06:53:13 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2008-12-23 06:53:13 +0000 |
commit | 576b5ef4a0153b9f0135da0d24405e909b267da8 (patch) | |
tree | f8e971b10e5b536f694a90c937a92a2de29e950d | |
parent | 14135fa3ad3d475eb12a04565127f72da7afd4ab (diff) |
add pool_walk as debug code.
this can be used to walk over all the items allocated with a pool and have
them examined by a function the caller provides.
with help from and ok tedu@
-rw-r--r-- | sys/kern/subr_pool.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c index 6abb44bf617..a5491e7022c 100644 --- a/sys/kern/subr_pool.c +++ b/sys/kern/subr_pool.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_pool.c,v 1.73 2008/12/23 06:50:48 dlg Exp $ */ +/* $OpenBSD: subr_pool.c,v 1.74 2008/12/23 06:53:12 dlg Exp $ */ /* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */ /*- @@ -1270,6 +1270,43 @@ pool_chk(struct pool *pp, const char *label) return (r); } + +void +pool_walk(struct pool *pp, void (*func)(void *)) +{ + struct pool_item_header *ph; + struct pool_item *pi; + caddr_t cp; + int n; + + LIST_FOREACH(ph, &pp->pr_emptypages, ph_pagelist) { + cp = ph->ph_colored; + n = ph->ph_nmissing; + + while (n--) { + func(cp); + cp += pp->pr_size; + } + } + + LIST_FOREACH(ph, &pp->pr_partpages, ph_pagelist) { + cp = ph->ph_colored; + n = ph->ph_nmissing; + + do { + TAILQ_FOREACH(pi, &ph->ph_itemlist, pi_list) { + if (cp == (caddr_t)pi) + break; + } + if (cp != (caddr_t)pi) { + func(cp); + n--; + } + + cp += pp->pr_size; + } while (n > 0); + } +} #endif /* |