Module Name: src
Committed By: ozaki-r
Date: Fri Mar 16 04:37:55 UTC 2018
Modified Files:
src/share/man/man4: ddb.4
src/sys/ddb: db_command.c
src/sys/sys: lockdebug.h
Log Message:
Add a new command, show lockstat, which shows statistics of locks
Currently the command shows the number of allocated locks.
The command is useful only if LOCKDEBUG is enabled.
To generate a diff of this commit:
cvs rdiff -u -r1.174 -r1.175 src/share/man/man4/ddb.4
cvs rdiff -u -r1.149 -r1.150 src/sys/ddb/db_command.c
cvs rdiff -u -r1.16 -r1.17 src/sys/sys/lockdebug.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/share/man/man4/ddb.4
diff -u src/share/man/man4/ddb.4:1.174 src/share/man/man4/ddb.4:1.175
--- src/share/man/man4/ddb.4:1.174 Mon Feb 19 10:31:53 2018
+++ src/share/man/man4/ddb.4 Fri Mar 16 04:37:55 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: ddb.4,v 1.174 2018/02/19 10:31:53 wiz Exp $
+.\" $NetBSD: ddb.4,v 1.175 2018/03/16 04:37:55 ozaki-r Exp $
.\"
.\" Copyright (c) 1997 - 2009 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -56,7 +56,7 @@
.\" any improvements or extensions that they make and grant Carnegie Mellon
.\" the rights to redistribute these changes.
.\"
-.Dd February 17, 2018
+.Dd March 16, 2018
.Dt DDB 4
.Os
.Sh NAME
@@ -650,6 +650,10 @@ Display information about a lock at
.Ar address .
This command is useful only if a kernel is compiled with
.Cd options LOCKDEBUG .
+.It Ic show lockstat
+Display information about statistics of locks.
+This command is useful only if a kernel is compiled with
+.Cd options LOCKDEBUG .
.It Ic show map Ns Oo Cm /f Oc Ar address
Print the vm_map at
.Ar address .
Index: src/sys/ddb/db_command.c
diff -u src/sys/ddb/db_command.c:1.149 src/sys/ddb/db_command.c:1.150
--- src/sys/ddb/db_command.c:1.149 Sun Mar 4 07:14:50 2018
+++ src/sys/ddb/db_command.c Fri Mar 16 04:37:55 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: db_command.c,v 1.149 2018/03/04 07:14:50 mlelstv Exp $ */
+/* $NetBSD: db_command.c,v 1.150 2018/03/16 04:37:55 ozaki-r 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.149 2018/03/04 07:14:50 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.150 2018/03/16 04:37:55 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_aio.h"
@@ -190,6 +190,7 @@ static void db_event_print_cmd(db_expr_t
static void db_fncall(db_expr_t, bool, db_expr_t, const char *);
static void db_help_print_cmd(db_expr_t, bool, db_expr_t, const char *);
static void db_lock_print_cmd(db_expr_t, bool, db_expr_t, const char *);
+static void db_show_lockstat(db_expr_t, bool, db_expr_t, const char *);
static void db_mount_print_cmd(db_expr_t, bool, db_expr_t, const char *);
static void db_mbuf_print_cmd(db_expr_t, bool, db_expr_t, const char *);
static void db_map_print_cmd(db_expr_t, bool, db_expr_t, const char *);
@@ -248,6 +249,9 @@ static const struct db_command db_show_c
"Print the files open by process at address",
"[/f] address", NULL) },
{ DDB_ADD_CMD("lock", db_lock_print_cmd, 0,NULL,NULL,NULL) },
+ { DDB_ADD_CMD("lockstat",
+ db_show_lockstat, 0,
+ "Print statistics of locks", NULL, NULL) },
{ DDB_ADD_CMD("map", db_map_print_cmd, 0,
"Print the vm_map at address.", "[/f] address",NULL) },
{ DDB_ADD_CMD("module", db_show_module_cmd, 0,
@@ -1226,6 +1230,16 @@ db_lock_print_cmd(db_expr_t addr, bool h
#endif
}
+static void
+db_show_lockstat(db_expr_t addr, bool have_addr,
+ db_expr_t count, const char *modif)
+{
+
+#ifdef _KERNEL /* XXX CRASH(8) */
+ lockdebug_show_lockstat(db_printf);
+#endif
+}
+
/*
* Call random function:
* !expr(arg,arg,arg)
Index: src/sys/sys/lockdebug.h
diff -u src/sys/sys/lockdebug.h:1.16 src/sys/sys/lockdebug.h:1.17
--- src/sys/sys/lockdebug.h:1.16 Sat Sep 16 23:54:41 2017
+++ src/sys/sys/lockdebug.h Fri Mar 16 04:37:55 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: lockdebug.h,v 1.16 2017/09/16 23:54:41 christos Exp $ */
+/* $NetBSD: lockdebug.h,v 1.17 2018/03/16 04:37:55 ozaki-r Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -58,6 +58,7 @@ void lockdebug_abort(const char *, size_
void lockdebug_lock_print(void *, void (*)(const char *, ...)
__printflike(1, 2));
+void lockdebug_show_lockstat(void (*)(const char *, ...) __printflike(1, 2));
#ifdef LOCKDEBUG