From 55a751c9d5e4e0cc2dd885afd0e04ba4b875b23d Mon Sep 17 00:00:00 2001 From: chs Date: Fri, 24 Nov 2000 07:25:50 +0000 Subject: [PATCH] add ddb commands "show uvmexp" and "show ncache". the former used to be "call uvm_dump", the latter is new. --- sys/ddb/db_command.c | 31 +++++++++++++++++++++---- sys/ddb/db_command.h | 4 +++- sys/kern/vfs_cache.c | 29 ++++++++++++++++++++++- sys/sys/namei.h | 3 ++- sys/uvm/uvm_ddb.h | 22 +++++++++--------- sys/uvm/uvm_stat.c | 55 ++++++++++++++++++++++++-------------------- 6 files changed, 101 insertions(+), 43 deletions(-) diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 171adb1fa17f..60388a3b5a70 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_command.c,v 1.50 2000/07/08 17:10:22 sommerfeld Exp $ */ +/* $NetBSD: db_command.c,v 1.51 2000/11/24 07:25:51 chs Exp $ */ /* * Mach Operating System @@ -38,6 +38,7 @@ #include #include #include +#include #include /* type definitions */ @@ -427,8 +428,29 @@ db_pool_print_cmd(addr, have_addr, count, modif) db_expr_t count; char * modif; { + pool_printit((struct pool *)addr, modif, db_printf); +} - pool_printit((struct pool *) addr, modif, db_printf); +/*ARGSUSED*/ +void +db_namecache_print_cmd(addr, have_addr, count, modif) + db_expr_t addr; + int have_addr; + db_expr_t count; + char * modif; +{ + namecache_print((struct vnode *)addr, db_printf); +} + +/*ARGSUSED*/ +void +db_uvmexp_print_cmd(addr, have_addr, count, modif) + db_expr_t addr; + int have_addr; + db_expr_t count; + char * modif; +{ + uvmexp_print(db_printf); } /* @@ -453,6 +475,8 @@ struct db_command db_show_cmds[] = { { "buf", db_buf_print_cmd, 0, NULL }, { "vnode", db_vnode_print_cmd, 0, NULL }, { "pool", db_pool_print_cmd, 0, NULL }, + { "ncache", db_namecache_print_cmd, 0, NULL }, + { "uvmexp", db_uvmexp_print_cmd, 0, NULL }, { "registers", db_show_regs, 0, NULL }, { "watches", db_listwatch_cmd, 0, NULL }, { NULL, NULL, 0, NULL } @@ -462,7 +486,6 @@ struct db_command db_command_table[] = { { "break", db_breakpoint_cmd, 0, NULL }, { "c", db_continue_cmd, 0, NULL }, { "call", db_fncall, CS_OWN, NULL }, - { "callout", db_show_callout, 0, NULL }, { "continue", db_continue_cmd, 0, NULL }, { "d", db_delete_cmd, 0, NULL }, { "delete", db_delete_cmd, 0, NULL }, @@ -681,7 +704,7 @@ db_sifting_cmd(addr, have_addr, count, omodif) } else mode = 0; - if (t==tIDENT) + if (t == tIDENT) db_sifting(db_tok_string, mode); else { db_printf("Bad argument (non-string)\n"); diff --git a/sys/ddb/db_command.h b/sys/ddb/db_command.h index 531fac198a36..71c689aa818d 100644 --- a/sys/ddb/db_command.h +++ b/sys/ddb/db_command.h @@ -1,4 +1,4 @@ -/* $NetBSD: db_command.h,v 1.17 2000/05/26 03:34:31 jhawk Exp $ */ +/* $NetBSD: db_command.h,v 1.18 2000/11/24 07:25:50 chs Exp $ */ /* * Mach Operating System @@ -43,6 +43,8 @@ void db_page_print_cmd __P((db_expr_t, int, db_expr_t, char *)); void db_buf_print_cmd __P((db_expr_t, int, db_expr_t, char *)); void db_vnode_print_cmd __P((db_expr_t, int, db_expr_t, char *)); void db_pool_print_cmd __P((db_expr_t, int, db_expr_t, char *)); +void db_namecache_print_cmd __P((db_expr_t, int, db_expr_t, char *)); +void db_uvmexp_print_cmd __P((db_expr_t, int, db_expr_t, char *)); void db_machine_commands_install __P((struct db_command *)); void db_command_loop __P((void)); void db_error __P((char *)); diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 3db92592b1c6..7f3a87a21656 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_cache.c,v 1.27 2000/11/24 05:02:23 chs Exp $ */ +/* $NetBSD: vfs_cache.c,v 1.28 2000/11/24 07:25:51 chs Exp $ */ /* * Copyright (c) 1989, 1993 @@ -35,6 +35,8 @@ * @(#)vfs_cache.c 8.3 (Berkeley) 8/22/94 */ +#include "opt_ddb.h" + #include #include #include @@ -463,3 +465,28 @@ cache_purgevfs(mp) } } +#ifdef DDB +void +namecache_print(struct vnode *vp, void (*pr)(const char *, ...)) +{ + struct vnode *dvp = NULL; + struct namecache *ncp; + + TAILQ_FOREACH(ncp, &nclruhead, nc_lru) { + if (ncp->nc_vp == vp && ncp->nc_vpid == vp->v_id) { + (*pr)("name %.*s\n", ncp->nc_nlen, ncp->nc_name); + dvp = ncp->nc_dvp; + } + } + if (dvp == NULL) { + (*pr)("name not found\n"); + return; + } + vp = dvp; + TAILQ_FOREACH(ncp, &nclruhead, nc_lru) { + if (ncp->nc_vp == vp && ncp->nc_vpid == vp->v_id) { + (*pr)("parent %.*s\n", ncp->nc_nlen, ncp->nc_name); + } + } +} +#endif diff --git a/sys/sys/namei.h b/sys/sys/namei.h index d0ca78e7352b..f33dd3865ba2 100644 --- a/sys/sys/namei.h +++ b/sys/sys/namei.h @@ -1,4 +1,4 @@ -/* $NetBSD: namei.h,v 1.19 2000/08/03 20:41:35 thorpej Exp $ */ +/* $NetBSD: namei.h,v 1.20 2000/11/24 07:25:52 chs Exp $ */ /* * Copyright (c) 1985, 1989, 1991, 1993 @@ -192,6 +192,7 @@ void cache_enter __P((struct vnode *, struct vnode *, struct componentname *)); void nchinit __P((void)); struct mount; void cache_purgevfs __P((struct mount *)); +void namecache_print(struct vnode *, void (*)(const char *, ...)); #endif /* diff --git a/sys/uvm/uvm_ddb.h b/sys/uvm/uvm_ddb.h index 146e65886f36..6529abdb6295 100644 --- a/sys/uvm/uvm_ddb.h +++ b/sys/uvm/uvm_ddb.h @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_ddb.h,v 1.3 1999/06/21 17:25:11 thorpej Exp $ */ +/* $NetBSD: uvm_ddb.h,v 1.4 2000/11/24 07:25:52 chs Exp $ */ /* * @@ -40,16 +40,16 @@ #ifdef _KERNEL #ifdef DDB -void uvm_map_print __P((vm_map_t, boolean_t)); -void uvm_map_printit __P((vm_map_t, boolean_t, - void (*) __P((const char *, ...)))); - -void uvm_object_print __P((struct uvm_object *, boolean_t)); -void uvm_object_printit __P((struct uvm_object *, boolean_t, - void (*) __P((const char *, ...)))); -void uvm_page_print __P((struct vm_page *, boolean_t)); -void uvm_page_printit __P((struct vm_page *, boolean_t, - void (*) __P((const char *, ...)))); +void uvm_map_print __P((vm_map_t, boolean_t)); +void uvm_map_printit __P((vm_map_t, boolean_t, + void (*) __P((const char *, ...)))); +void uvm_object_print __P((struct uvm_object *, boolean_t)); +void uvm_object_printit __P((struct uvm_object *, boolean_t, + void (*) __P((const char *, ...)))); +void uvm_page_print __P((struct vm_page *, boolean_t)); +void uvm_page_printit __P((struct vm_page *, boolean_t, + void (*) __P((const char *, ...)))); +void uvmexp_print(void (*)(const char *, ...)); #endif /* DDB */ #endif /* _KERNEL */ diff --git a/sys/uvm/uvm_stat.c b/sys/uvm/uvm_stat.c index 7333f95066eb..5defb868c9ee 100644 --- a/sys/uvm/uvm_stat.c +++ b/sys/uvm/uvm_stat.c @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_stat.c,v 1.14 2000/06/27 17:29:35 mrg Exp $ */ +/* $NetBSD: uvm_stat.c,v 1.15 2000/11/24 07:25:52 chs Exp $ */ /* * @@ -35,6 +35,7 @@ */ #include "opt_uvmhist.h" +#include "opt_ddb.h" /* * uvm_stat.c @@ -44,6 +45,7 @@ #include #include +#include /* * globals @@ -59,6 +61,8 @@ struct uvm_history_head uvm_histories; int uvmhist_print_enabled = 1; #endif +#ifdef DDB + /* * prototypes */ @@ -69,7 +73,6 @@ void uvm_hist __P((u_int32_t)); static void uvmhist_dump_histories __P((struct uvm_history *[])); #endif void uvmcnt_dump __P((void)); -void uvm_dump __P((void)); #ifdef UVMHIST @@ -199,54 +202,56 @@ uvmcnt_dump() } /* - * uvm_dump: ddb hook to dump interesting uvm counters + * uvmexp_print: ddb hook to print interesting uvm counters */ -void -uvm_dump() +void +uvmexp_print(void (*pr)(const char *, ...)) { - printf("Current UVM status:\n"); - printf(" pagesize=%d (0x%x), pagemask=0x%x, pageshift=%d\n", + (*pr)("Current UVM status:\n"); + (*pr)(" pagesize=%d (0x%x), pagemask=0x%x, pageshift=%d\n", uvmexp.pagesize, uvmexp.pagesize, uvmexp.pagemask, uvmexp.pageshift); - printf(" %d VM pages: %d active, %d inactive, %d wired, %d free\n", + (*pr)(" %d VM pages: %d active, %d inactive, %d wired, %d free\n", uvmexp.npages, uvmexp.active, uvmexp.inactive, uvmexp.wired, uvmexp.free); - printf(" freemin=%d, free-target=%d, inactive-target=%d, " + (*pr)(" freemin=%d, free-target=%d, inactive-target=%d, " "wired-max=%d\n", uvmexp.freemin, uvmexp.freetarg, uvmexp.inactarg, uvmexp.wiredmax); - printf(" faults=%d, traps=%d, intrs=%d, ctxswitch=%d\n", + (*pr)(" faults=%d, traps=%d, intrs=%d, ctxswitch=%d\n", uvmexp.faults, uvmexp.traps, uvmexp.intrs, uvmexp.swtch); - printf(" softint=%d, syscalls=%d, swapins=%d, swapouts=%d\n", + (*pr)(" softint=%d, syscalls=%d, swapins=%d, swapouts=%d\n", uvmexp.softs, uvmexp.syscalls, uvmexp.swapins, uvmexp.swapouts); - printf(" fault counts:\n"); - printf(" noram=%d, noanon=%d, pgwait=%d, pgrele=%d\n", + (*pr)(" fault counts:\n"); + (*pr)(" noram=%d, noanon=%d, pgwait=%d, pgrele=%d\n", uvmexp.fltnoram, uvmexp.fltnoanon, uvmexp.fltpgwait, uvmexp.fltpgrele); - printf(" ok relocks(total)=%d(%d), anget(retrys)=%d(%d), " + (*pr)(" ok relocks(total)=%d(%d), anget(retrys)=%d(%d), " "amapcopy=%d\n", uvmexp.fltrelckok, uvmexp.fltrelck, uvmexp.fltanget, uvmexp.fltanretry, uvmexp.fltamcopy); - printf(" neighbor anon/obj pg=%d/%d, gets(lock/unlock)=%d/%d\n", + (*pr)(" neighbor anon/obj pg=%d/%d, gets(lock/unlock)=%d/%d\n", uvmexp.fltnamap, uvmexp.fltnomap, uvmexp.fltlget, uvmexp.fltget); - printf(" cases: anon=%d, anoncow=%d, obj=%d, prcopy=%d, przero=%d\n", + (*pr)(" cases: anon=%d, anoncow=%d, obj=%d, prcopy=%d, przero=%d\n", uvmexp.flt_anon, uvmexp.flt_acow, uvmexp.flt_obj, uvmexp.flt_prcopy, uvmexp.flt_przero); - printf(" daemon and swap counts:\n"); - printf(" woke=%d, revs=%d, scans=%d, swout=%d\n", uvmexp.pdwoke, - uvmexp.pdrevs, uvmexp.pdscans, uvmexp.pdswout); - printf(" busy=%d, freed=%d, reactivate=%d, deactivate=%d\n", + (*pr)(" daemon and swap counts:\n"); + (*pr)(" woke=%d, revs=%d, scans=%d, obscans=%d, anscans=%d\n", + uvmexp.pdwoke, uvmexp.pdrevs, uvmexp.pdscans, uvmexp.pdobscan, + uvmexp.pdanscan); + (*pr)(" busy=%d, freed=%d, reactivate=%d, deactivate=%d\n", uvmexp.pdbusy, uvmexp.pdfreed, uvmexp.pdreact, uvmexp.pddeact); - printf(" pageouts=%d, pending=%d, nswget=%d\n", uvmexp.pdpageouts, + (*pr)(" pageouts=%d, pending=%d, nswget=%d\n", uvmexp.pdpageouts, uvmexp.pdpending, uvmexp.nswget); - printf(" nswapdev=%d, nanon=%d, nanonneeded=%d nfreeanon=%d\n", + (*pr)(" nswapdev=%d, nanon=%d, nanonneeded=%d nfreeanon=%d\n", uvmexp.nswapdev, uvmexp.nanon, uvmexp.nanonneeded, uvmexp.nfreeanon); - printf(" swpages=%d, swpginuse=%d, swpgonly=%d paging=%d\n", + (*pr)(" swpages=%d, swpginuse=%d, swpgonly=%d paging=%d\n", uvmexp.swpages, uvmexp.swpginuse, uvmexp.swpgonly, uvmexp.paging); - printf(" kernel pointers:\n"); - printf(" objs(kern/kmem/mb)=%p/%p/%p\n", uvm.kernel_object, + (*pr)(" kernel pointers:\n"); + (*pr)(" objs(kern/kmem/mb)=%p/%p/%p\n", uvm.kernel_object, uvmexp.kmem_object, uvmexp.mb_object); } +#endif