Module Name: src Committed By: yamt Date: Wed Mar 6 11:49:06 UTC 2013
Modified Files: src/usr.sbin/lockstat: lockstat.8 main.c Log Message: add -d option to disable lockstat To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/lockstat/lockstat.8 cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/lockstat/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/lockstat/lockstat.8 diff -u src/usr.sbin/lockstat/lockstat.8:1.9 src/usr.sbin/lockstat/lockstat.8:1.10 --- src/usr.sbin/lockstat/lockstat.8:1.9 Sat Mar 21 13:02:19 2009 +++ src/usr.sbin/lockstat/lockstat.8 Wed Mar 6 11:49:06 2013 @@ -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 alloc 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 Index: src/usr.sbin/lockstat/main.c diff -u src/usr.sbin/lockstat/main.c:1.18 src/usr.sbin/lockstat/main.c:1.19 --- src/usr.sbin/lockstat/main.c:1.18 Tue Aug 30 19:20:20 2011 +++ src/usr.sbin/lockstat/main.c Wed Mar 6 11:49:06 2013 @@ -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"