Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add ddb command to find a vnode by the address of its lock.



details:   https://anonhg.NetBSD.org/src/rev/823c10461ec3
branches:  trunk
changeset: 350428:823c10461ec3
user:      joerg <joerg%NetBSD.org@localhost>
date:      Wed Jan 11 12:17:34 2017 +0000

description:
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:

 sys/ddb/db_command.c |  24 ++++++++++++++++++++++--
 sys/kern/vfs_subr.c  |  19 +++++++++++++++++--
 sys/sys/vnode.h      |   4 +++-
 3 files changed, 42 insertions(+), 5 deletions(-)

diffs (117 lines):

diff -r 42de834900fa -r 823c10461ec3 sys/ddb/db_command.c
--- a/sys/ddb/db_command.c      Wed Jan 11 12:14:32 2017 +0000
+++ b/sys/ddb/db_command.c      Wed Jan 11 12:17:34 2017 +0000
@@ -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_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 @@
 #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 @@
 
 /*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 -r 42de834900fa -r 823c10461ec3 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c       Wed Jan 11 12:14:32 2017 +0000
+++ b/sys/kern/vfs_subr.c       Wed Jan 11 12:17:34 2017 +0000
@@ -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 @@
 }
 
 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 -r 42de834900fa -r 823c10461ec3 sys/sys/vnode.h
--- a/sys/sys/vnode.h   Wed Jan 11 12:14:32 2017 +0000
+++ b/sys/sys/vnode.h   Wed Jan 11 12:17:34 2017 +0000
@@ -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 @@
 #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 */



Home | Main Index | Thread Index | Old Index