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.
This commit is contained in:
parent
9d57ec4a6c
commit
6ff696c6b4
@ -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,
|
||||
@ -1114,6 +1119,21 @@ db_vnode_print_cmd(db_expr_t addr, bool have_addr,
|
||||
#endif
|
||||
}
|
||||
|
||||
/*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,
|
||||
|
@ -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"
|
||||
@ -1539,6 +1539,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 *, ...))
|
||||
{
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user