Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/intrctl add -z flag to intrctl list, which elides a...



details:   https://anonhg.NetBSD.org/src/rev/d5d5530cb937
branches:  trunk
changeset: 965602:d5d5530cb937
user:      mrg <mrg%NetBSD.org@localhost>
date:      Mon Sep 23 20:15:31 2019 +0000

description:
add -z flag to intrctl list, which elides all-zero rows.

diffstat:

 usr.sbin/intrctl/intrctl.8 |  10 +++++++---
 usr.sbin/intrctl/intrctl.c |  39 ++++++++++++++++++++++++++++++---------
 2 files changed, 37 insertions(+), 12 deletions(-)

diffs (133 lines):

diff -r 9537258234fa -r d5d5530cb937 usr.sbin/intrctl/intrctl.8
--- a/usr.sbin/intrctl/intrctl.8        Mon Sep 23 18:43:59 2019 +0000
+++ b/usr.sbin/intrctl/intrctl.8        Mon Sep 23 20:15:31 2019 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: intrctl.8,v 1.5 2019/09/23 09:17:19 mrg Exp $
+.\" $NetBSD: intrctl.8,v 1.6 2019/09/23 20:15:31 mrg Exp $
 .\"
 .\" Copyright (c) 2015 Internet Initiative Japan Inc.
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd September 22, 2019
+.Dd September 23, 2019
 .Dt INTRCTL 8
 .Os
 .Sh NAME
@@ -56,7 +56,7 @@
 If
 .Ar cpu_index
 is already enabled, this command has no effect.
-.It list Oo Fl c Oc Op Fl w Ar wait
+.It list Oo Fl c Oc Oo Fl w Ar wait Oc Op Fl z
 for each intrid in the system, display interrupt counts per CPU.
 The intrid is an interrupt name such as "ioapic0 pin 22" for x86.
 .Pp
@@ -72,6 +72,10 @@
 display the data continuously with a
 .Ar wait
 seconds delay between each iteration.
+.Pp
+If
+.Fl z
+is specified then rows with all CPUs having zero interrupts will be skipped.
 .It nointr Fl c Ar cpu_index
 disable to set an interrupt's affinity to
 .Ar cpu_index .
diff -r 9537258234fa -r d5d5530cb937 usr.sbin/intrctl/intrctl.c
--- a/usr.sbin/intrctl/intrctl.c        Mon Sep 23 18:43:59 2019 +0000
+++ b/usr.sbin/intrctl/intrctl.c        Mon Sep 23 20:15:31 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intrctl.c,v 1.9 2019/09/23 09:17:19 mrg Exp $  */
+/*     $NetBSD: intrctl.c,v 1.10 2019/09/23 20:15:31 mrg Exp $ */
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: intrctl.c,v 1.9 2019/09/23 09:17:19 mrg Exp $");
+__RCSID("$NetBSD: intrctl.c,v 1.10 2019/09/23 20:15:31 mrg Exp $");
 
 #include <sys/param.h>
 #include <sys/sysctl.h>
@@ -99,8 +99,9 @@
 {
        const char *progname = getprogname();
 
-       fprintf(stderr, "usage: %s list [-c] [-w secs]\n", progname);
-       fprintf(stderr, "       %s affinity -i interrupt_name -c cpu_index\n", progname);
+       fprintf(stderr, "usage: %s list [-c] [-w secs] [-z]\n", progname);
+       fprintf(stderr, "       %s affinity -i interrupt_name -c cpu_index\n",
+           progname);
        fprintf(stderr, "       %s intr -c cpu_index\n", progname);
        fprintf(stderr, "       %s nointr -c cpu_index\n", progname);
        exit(EXIT_FAILURE);
@@ -110,7 +111,7 @@
 static int intrctl_io_alloc_retry_count = 4;
 
 static void
-intrctl_list_one(int compact)
+intrctl_list_one(bool compact, bool skipzero)
 {
        char buf[64];
        struct intrio_list_line *illine;
@@ -169,6 +170,20 @@
            illine = intrctl_io_nextline(handle, illine)) {
                struct intrio_list_line_cpu *illc;
 
+               if (skipzero) {
+                       bool is_zero = true;
+
+                       for (i = 0; i < ncpus; i++) {
+                               illc = &illine->ill_cpu[i];
+                               if (illc->illc_count != 0) {
+                                       is_zero = false;
+                                       break;
+                               }
+                       }
+                       if (is_zero)
+                               continue;
+               }
+
                printf("%-*s ", (int)intridlen, illine->ill_intrid);
                if (compact) {
                        uint64_t total = 0;
@@ -209,13 +224,17 @@
 {
        int seconds = 0;
        bool compact = false;
+       bool skipzero = false;
        int ch;
 
-       while ((ch = getopt(argc, argv, "cw:")) != -1) {
+       while ((ch = getopt(argc, argv, "cw:z")) != -1) {
                switch (ch) {
                case 'c':
                        compact = true;
                        break;
+               case 'z':
+                       skipzero = true;
+                       break;
                case 'w':
                        seconds = atoi(optarg);
                        if (seconds < 0)
@@ -226,10 +245,12 @@
                }
        }
 
-       do {
-               intrctl_list_one(compact);
+       for (;;) {
+               intrctl_list_one(compact, skipzero);
+               if (seconds == 0)
+                       break;
                sleep(seconds);
-       } while (seconds);
+       }
 }
 
 static void



Home | Main Index | Thread Index | Old Index