summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryamt <yamt@NetBSD.org>2013-03-06 11:49:06 +0000
committeryamt <yamt@NetBSD.org>2013-03-06 11:49:06 +0000
commited689a7cc14f4af31354cf21622fcf8ea4e7d9bc (patch)
tree1ad7704e7cc3218682619406ad7e1d935166420e
parentd2ed859c39883c8983a02eb2c47c3ca9240ecfea (diff)
add -d option to disable lockstat
-rw-r--r--usr.sbin/lockstat/lockstat.810
-rw-r--r--usr.sbin/lockstat/main.c19
2 files changed, 21 insertions, 8 deletions
diff --git a/usr.sbin/lockstat/lockstat.8 b/usr.sbin/lockstat/lockstat.8
index 42079171c5d..6063bd9b492 100644
--- a/usr.sbin/lockstat/lockstat.8
+++ b/usr.sbin/lockstat/lockstat.8
@@ -1,4 +1,4 @@
-.\" $NetBSD: lockstat.8,v 1.9 2009/03/21 13:02:19 ad Exp $
+.\" $NetBSD: lockstat.8,v 1.10 2013/03/06 11:49:06 yamt Exp $
.\"
.\" Copyright (c) 2006, 2007, 2009 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd March 21, 2009
+.Dd March 6, 2013
.Dt LOCKSTAT 8
.Os
.Sh NAME
@@ -35,7 +35,7 @@
.Nd display kernel locking statistics
.Sh SYNOPSIS
.Nm
-.Op Fl ceflMmpstx
+.Op Fl cdeflMmpstx
.Op Fl b Ar nbuf
.Op Fl E Ar event
.Op Fl F Ar func
@@ -70,6 +70,10 @@ Adjust the number of trace buffers allocated by the kernel to
Report percentage of total events by count, and sort the output by number
of events.
The default is to key on event timings.
+.It Fl d
+Disable lockstat.
+This is useful when a program crashed leaving the lockstat kernel driver
+enabled.
.It Fl E Ar event
Limit tracing to one type of event.
Use the
diff --git a/usr.sbin/lockstat/main.c b/usr.sbin/lockstat/main.c
index a7ababcefec..0e56d5432c3 100644
--- a/usr.sbin/lockstat/main.c
+++ b/usr.sbin/lockstat/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.18 2011/08/30 19:20:20 joerg Exp $ */
+/* $NetBSD: main.c,v 1.19 2013/03/06 11:49:06 yamt Exp $ */
/*-
* Copyright (c) 2006, 2007, 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: main.c,v 1.18 2011/08/30 19:20:20 joerg Exp $");
+__RCSID("$NetBSD: main.c,v 1.19 2013/03/06 11:49:06 yamt Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -135,6 +135,7 @@ static bool lflag;
static bool fflag;
static int nbufs;
static bool cflag;
+static bool dflag;
static bool xflag;
static int lsfd;
static int displayed;
@@ -181,7 +182,7 @@ main(int argc, char **argv)
mflag = false;
Mflag = false;
- while ((ch = getopt(argc, argv, "E:F:L:MN:T:b:ceflmo:pstx")) != -1)
+ while ((ch = getopt(argc, argv, "E:F:L:MN:T:b:cdeflmo:pstx")) != -1)
switch (ch) {
case 'E':
eventtype = matchname(eventnames, optarg);
@@ -206,6 +207,9 @@ main(int argc, char **argv)
case 'c':
cflag = true;
break;
+ case 'd':
+ dflag = true;
+ break;
case 'e':
listnames(eventnames);
break;
@@ -242,7 +246,7 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
- if (*argv == NULL)
+ if (*argv == NULL && !dflag)
usage();
if (outf) {
@@ -308,6 +312,9 @@ main(int argc, char **argv)
errx(EXIT_FAILURE,
"incompatible lockstat interface version (%d, kernel %d)",
LS_VERSION, ch);
+ if (dflag) {
+ goto disable;
+ }
if (ioctl(lsfd, IOC_LOCKSTAT_ENABLE, &le))
err(EXIT_FAILURE, "cannot enable tracing");
@@ -316,6 +323,7 @@ main(int argc, char **argv)
*/
spawn(argc, argv);
+disable:
/*
* Stop tracing, and read the trace buffers from the kernel.
*/
@@ -395,7 +403,8 @@ usage(void)
"%s [options] <command>\n\n"
"-b nbuf\t\tset number of event buffers to allocate\n"
"-c\t\treport percentage of total events by count, not time\n"
- "-E event\t\tdisplay only one type of event\n"
+ "-d\t\tdisable lockstat\n"
+ "-E event\tdisplay only one type of event\n"
"-e\t\tlist event types\n"
"-F func\t\tlimit trace to one function\n"
"-f\t\ttrace only by function\n"