Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/lockstat add -d option to disable lockstat



details:   https://anonhg.NetBSD.org/src/rev/d94f049df033
branches:  trunk
changeset: 785268:d94f049df033
user:      yamt <yamt%NetBSD.org@localhost>
date:      Wed Mar 06 11:49:06 2013 +0000

description:
add -d option to disable lockstat

diffstat:

 usr.sbin/lockstat/lockstat.8 |  10 +++++++---
 usr.sbin/lockstat/main.c     |  19 ++++++++++++++-----
 2 files changed, 21 insertions(+), 8 deletions(-)

diffs (120 lines):

diff -r c80e5d353842 -r d94f049df033 usr.sbin/lockstat/lockstat.8
--- a/usr.sbin/lockstat/lockstat.8      Wed Mar 06 11:44:11 2013 +0000
+++ b/usr.sbin/lockstat/lockstat.8      Wed Mar 06 11:49:06 2013 +0000
@@ -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 @@
 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 -r c80e5d353842 -r d94f049df033 usr.sbin/lockstat/main.c
--- a/usr.sbin/lockstat/main.c  Wed Mar 06 11:44:11 2013 +0000
+++ b/usr.sbin/lockstat/main.c  Wed Mar 06 11:49:06 2013 +0000
@@ -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            fflag;
 static int             nbufs;
 static bool            cflag;
+static bool            dflag;
 static bool            xflag;
 static int             lsfd;
 static int             displayed;
@@ -181,7 +182,7 @@
        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 @@
                case 'c':
                        cflag = true;
                        break;
+               case 'd':
+                       dflag = true;
+                       break;
                case 'e':
                        listnames(eventnames);
                        break;
@@ -242,7 +246,7 @@
        argc -= optind;
        argv += optind;
 
-       if (*argv == NULL)
+       if (*argv == NULL && !dflag)
                usage();
 
        if (outf) {
@@ -308,6 +312,9 @@
                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 @@
         */
        spawn(argc, argv);
 
+disable:
        /*
         * Stop tracing, and read the trace buffers from the kernel.
         */
@@ -395,7 +403,8 @@
            "%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"



Home | Main Index | Thread Index | Old Index