diff options
| author | joerg <joerg@NetBSD.org> | 2017-01-11 12:17:34 +0000 |
|---|---|---|
| committer | joerg <joerg@NetBSD.org> | 2017-01-11 12:17:34 +0000 |
| commit | 1d64ea8a7a165f3c7c6f787682008ec49f12f3ba (patch) | |
| tree | 893c8f76e42af217a32a48e3e71931849ef26593 /sys | |
| parent | a5b0782db3067e90336e29292023c3d689d758ef (diff) | |
Add ddb command to find a vnode by the address of its lock.
This makes it much easier to convert lockstat traces into understandable
data.
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/ddb/db_command.c | 24 | ||||
| -rw-r--r-- | sys/kern/vfs_subr.c | 19 | ||||
| -rw-r--r-- | sys/sys/vnode.h | 4 |
3 files changed, 42 insertions, 5 deletions
diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 0d4b3e308d9..6d1ec350f18 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_command.c,v 1.147 2016/04/13 00:47:02 ozaki-r Exp $ */ +/* $NetBSD: db_command.c,v 1.148 2017/01/11 12:17:34 joerg Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.147 2016/04/13 00:47:02 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.148 2017/01/11 12:17:34 joerg Exp $"); #ifdef _KERNEL_OPT #include "opt_aio.h" @@ -209,6 +209,8 @@ static void db_uvmexp_print_cmd(db_expr_t, bool, db_expr_t, const char *); static void db_kernhist_print_cmd(db_expr_t, bool, db_expr_t, const char *); #endif static void db_vnode_print_cmd(db_expr_t, bool, db_expr_t, const char *); +static void db_vnode_lock_print_cmd(db_expr_t, bool, db_expr_t, + const char *); static void db_vmem_print_cmd(db_expr_t, bool, db_expr_t, const char *); static const struct db_command db_show_cmds[] = { @@ -282,6 +284,9 @@ static const struct db_command db_show_cmds[] = { #endif { DDB_ADD_CMD("vnode", db_vnode_print_cmd, 0, "Print the vnode at address.", "[/f] address",NULL) }, + { DDB_ADD_CMD("vnode_lock", db_vnode_lock_print_cmd, 0, + "Print the vnode having that address as v_lock.", + "[/f] address",NULL) }, { DDB_ADD_CMD("vmem", db_vmem_print_cmd, 0, "Print the vmem usage.", "[/a] address", NULL) }, { DDB_ADD_CMD("vmems", db_show_all_vmems, 0, @@ -1116,6 +1121,21 @@ db_vnode_print_cmd(db_expr_t addr, bool have_addr, /*ARGSUSED*/ static void +db_vnode_lock_print_cmd(db_expr_t addr, bool have_addr, + db_expr_t count, const char *modif) +{ +#ifdef _KERNEL /* XXX CRASH(8) */ + bool full = false; + + if (modif[0] == 'f') + full = true; + + vfs_vnode_lock_print((struct vnode *)(uintptr_t) addr, full, db_printf); +#endif +} + +/*ARGSUSED*/ +static void db_vmem_print_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif) { diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index df6178eb70f..13cc72ee105 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.457 2017/01/11 09:08:58 hannken Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.458 2017/01/11 12:17:34 joerg Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.457 2017/01/11 09:08:58 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.458 2017/01/11 12:17:34 joerg Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1540,6 +1540,21 @@ vfs_vnode_print(struct vnode *vp, int full, void (*pr)(const char *, ...)) } void +vfs_vnode_lock_print(void *vlock, int full, void (*pr)(const char *, ...)) +{ + struct mount *mp; + struct vnode *vp; + + TAILQ_FOREACH(mp, &mountlist, mnt_list) { + TAILQ_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) { + if (&vp->v_lock != vlock) + continue; + vfs_vnode_print(vp, full, pr); + } + } +} + +void vfs_mount_print(struct mount *mp, int full, void (*pr)(const char *, ...)) { char sbuf[256]; diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 8ab495a1aa7..6e33411580d 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1,4 +1,4 @@ -/* $NetBSD: vnode.h,v 1.272 2017/01/11 09:08:59 hannken Exp $ */ +/* $NetBSD: vnode.h,v 1.273 2017/01/11 12:17:34 joerg Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -569,6 +569,8 @@ void vfs_timestamp(struct timespec *); #if defined(DDB) || defined(DEBUGPRINT) void vfs_vnode_print(struct vnode *, int, void (*)(const char *, ...) __printflike(1, 2)); +void vfs_vnode_lock_print(void *, int, void (*)(const char *, ...) + __printflike(1, 2)); void vfs_mount_print(struct mount *, int, void (*)(const char *, ...) __printflike(1, 2)); #endif /* DDB */ |
