Module Name: src
Committed By: joerg
Date: Wed Jan 11 12:17:34 UTC 2017
Modified Files:
src/sys/ddb: db_command.c
src/sys/kern: vfs_subr.c
src/sys/sys: vnode.h
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 src/sys/ddb/db_command.c
cvs rdiff -u -r1.457 -r1.458 src/sys/kern/vfs_subr.c
cvs rdiff -u -r1.272 -r1.273 src/sys/sys/vnode.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/ddb/db_command.c
diff -u src/sys/ddb/db_command.c:1.147 src/sys/ddb/db_command.c:1.148
--- src/sys/ddb/db_command.c:1.147 Wed Apr 13 00:47:02 2016
+++ src/sys/ddb/db_command.c Wed Jan 11 12:17:34 2017
@@ -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_
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_c
#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
/*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)
{
Index: src/sys/kern/vfs_subr.c
diff -u src/sys/kern/vfs_subr.c:1.457 src/sys/kern/vfs_subr.c:1.458
--- src/sys/kern/vfs_subr.c:1.457 Wed Jan 11 09:08:58 2017
+++ src/sys/kern/vfs_subr.c Wed Jan 11 12:17:34 2017
@@ -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 fu
}
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];
Index: src/sys/sys/vnode.h
diff -u src/sys/sys/vnode.h:1.272 src/sys/sys/vnode.h:1.273
--- src/sys/sys/vnode.h:1.272 Wed Jan 11 09:08:59 2017
+++ src/sys/sys/vnode.h Wed Jan 11 12:17:34 2017
@@ -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 */