From a004e1d63cc60549ae5db124adcafb18d60615f1 Mon Sep 17 00:00:00 2001 From: yamt Date: Thu, 1 Dec 2005 13:21:05 +0000 Subject: [PATCH] add "show all pools" command for ddb. --- sys/ddb/db_command.c | 5 +++-- sys/ddb/db_interface.h | 3 ++- sys/ddb/db_xxx.c | 11 +++++++++-- sys/kern/subr_pool.c | 20 ++++++++++++++++++-- sys/sys/pool.h | 3 ++- 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index dd02a44b1552..76ef31af780e 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_command.c,v 1.81 2005/11/27 13:05:28 yamt Exp $ */ +/* $NetBSD: db_command.c,v 1.82 2005/12/01 13:21:05 yamt Exp $ */ /* * Mach Operating System @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.81 2005/11/27 13:05:28 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.82 2005/12/01 13:21:05 yamt Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -128,6 +128,7 @@ static void db_mount_print_cmd(db_expr_t, int, db_expr_t, const char *); static const struct db_command db_show_all_cmds[] = { { "callout", db_show_callout, 0, NULL }, { "procs", db_show_all_procs, 0, NULL }, + { "pools", db_show_all_pools, 0, NULL }, { NULL, NULL, 0, NULL } }; diff --git a/sys/ddb/db_interface.h b/sys/ddb/db_interface.h index e0835585f59b..22178a31db5f 100644 --- a/sys/ddb/db_interface.h +++ b/sys/ddb/db_interface.h @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.h,v 1.15 2005/06/01 12:25:27 drochner Exp $ */ +/* $NetBSD: db_interface.h,v 1.16 2005/12/01 13:21:05 yamt Exp $ */ /*- * Copyright (c) 1995 The NetBSD Foundation, Inc. @@ -53,6 +53,7 @@ void db_kgdb_cmd(db_expr_t, int, db_expr_t, const char *); /* kern/kern_proc.c */ void db_kill_proc(db_expr_t, int, db_expr_t, const char *); void db_show_all_procs(db_expr_t, int, db_expr_t, const char *); +void db_show_all_pools(db_expr_t, int, db_expr_t, const char *); void db_show_sched_qs(db_expr_t, int, db_expr_t, const char *); /* kern/kern_clock.c */ diff --git a/sys/ddb/db_xxx.c b/sys/ddb/db_xxx.c index 1839233ca49a..542987d9bc07 100644 --- a/sys/ddb/db_xxx.c +++ b/sys/ddb/db_xxx.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_xxx.c,v 1.32 2005/10/15 17:29:11 yamt Exp $ */ +/* $NetBSD: db_xxx.c,v 1.33 2005/12/01 13:21:05 yamt Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -39,7 +39,7 @@ #include "opt_kgdb.h" #include -__KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.32 2005/10/15 17:29:11 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.33 2005/12/01 13:21:05 yamt Exp $"); #include #include @@ -227,6 +227,13 @@ db_show_all_procs(db_expr_t addr, int haddr, db_expr_t count, const char *modif) } } +void +db_show_all_pools(db_expr_t addr, int haddr, db_expr_t count, const char *modif) +{ + + pool_printall(modif, db_printf); +} + void db_dmesg(db_expr_t addr, int haddr, db_expr_t count, const char *modif) { diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c index a25684d04387..0f5041d564e5 100644 --- a/sys/kern/subr_pool.c +++ b/sys/kern/subr_pool.c @@ -1,4 +1,4 @@ -/* $NetBSD: subr_pool.c,v 1.107 2005/11/02 14:32:54 yamt Exp $ */ +/* $NetBSD: subr_pool.c,v 1.108 2005/12/01 13:21:05 yamt Exp $ */ /*- * Copyright (c) 1997, 1999, 2000 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.107 2005/11/02 14:32:54 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.108 2005/12/01 13:21:05 yamt Exp $"); #include "opt_pool.h" #include "opt_poollog.h" @@ -1580,6 +1580,22 @@ pool_print(struct pool *pp, const char *modif) splx(s); } +void +pool_printall(const char *modif, void (*pr)(const char *, ...)) +{ + struct pool *pp; + + if (simple_lock_try(&pool_head_slock) == 0) { + (*pr)("WARNING: pool_head_slock is locked\n"); + } else { + simple_unlock(&pool_head_slock); + } + + LIST_FOREACH(pp, &pool_head, pr_poollist) { + pool_printit(pp, modif, pr); + } +} + void pool_printit(struct pool *pp, const char *modif, void (*pr)(const char *, ...)) { diff --git a/sys/sys/pool.h b/sys/sys/pool.h index 7e47cbc7c0a4..bbf0b081271b 100644 --- a/sys/sys/pool.h +++ b/sys/sys/pool.h @@ -1,4 +1,4 @@ -/* $NetBSD: pool.h,v 1.46 2005/10/02 17:29:31 chs Exp $ */ +/* $NetBSD: pool.h,v 1.47 2005/12/01 13:21:05 yamt Exp $ */ /*- * Copyright (c) 1997, 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -271,6 +271,7 @@ void pool_drain(void *); void pool_print(struct pool *, const char *); void pool_printit(struct pool *, const char *, void (*)(const char *, ...)); +void pool_printall(const char *, void (*)(const char *, ...)); int pool_chk(struct pool *, const char *); /*