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 -c option to list command for compact l...
details: https://anonhg.NetBSD.org/src/rev/3894217c9a38
branches: trunk
changeset: 348335:3894217c9a38
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Sat Oct 15 12:06:27 2016 +0000
description:
add -c option to list command for compact list, it displays totals rather then
per-CPU stats
diffstat:
usr.sbin/intrctl/intrctl.8 | 11 +++++--
usr.sbin/intrctl/intrctl.c | 64 +++++++++++++++++++++++++++++++++++++--------
2 files changed, 60 insertions(+), 15 deletions(-)
diffs (139 lines):
diff -r 45561bf2adbd -r 3894217c9a38 usr.sbin/intrctl/intrctl.8
--- a/usr.sbin/intrctl/intrctl.8 Sat Oct 15 11:44:09 2016 +0000
+++ b/usr.sbin/intrctl/intrctl.8 Sat Oct 15 12:06:27 2016 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: intrctl.8,v 1.3 2016/10/12 21:47:37 jdolecek Exp $
+.\" $NetBSD: intrctl.8,v 1.4 2016/10/15 12:06:27 jdolecek 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 October 12, 2016
+.Dd October 15, 2016
.Dt INTRCTL 8
.Os
.Sh NAME
@@ -56,9 +56,14 @@
If
.Ar cpu_index
is already enabled, this command has no effect.
-.It list
+.It list Op Fl c
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
+If
+.Fl c
+is specified, display compact list with total counts per interrupt,
+and CPU affinity as comma separated list of CPU indexes.
.It nointr Fl c Ar cpu_index
disable to set an interrupt's affinity to
.Ar cpu_index .
diff -r 45561bf2adbd -r 3894217c9a38 usr.sbin/intrctl/intrctl.c
--- a/usr.sbin/intrctl/intrctl.c Sat Oct 15 11:44:09 2016 +0000
+++ b/usr.sbin/intrctl/intrctl.c Sat Oct 15 12:06:27 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intrctl.c,v 1.3 2016/09/19 18:46:39 ryo Exp $ */
+/* $NetBSD: intrctl.c,v 1.4 2016/10/15 12:06:27 jdolecek Exp $ */
/*
* Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: intrctl.c,v 1.3 2016/09/19 18:46:39 ryo Exp $");
+__RCSID("$NetBSD: intrctl.c,v 1.4 2016/10/15 12:06:27 jdolecek Exp $");
#include <sys/param.h>
#include <sys/sysctl.h>
@@ -99,7 +99,7 @@
{
const char *progname = getprogname();
- fprintf(stderr, "usage: %s list\n", progname);
+ fprintf(stderr, "usage: %s list [-c]\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);
@@ -117,6 +117,18 @@
int i, ncpus, *cpucol;
void *handle;
size_t intridlen;
+ int compact = 0;
+ char ch;
+
+ while ((ch = getopt(argc, argv, "c")) != -1) {
+ switch (ch) {
+ case 'c':
+ compact = 1;
+ break;
+ default:
+ usage();
+ }
+ }
handle = intrctl_io_alloc(intrctl_io_alloc_retry_count);
if (handle == NULL)
@@ -152,21 +164,49 @@
}
/* header */
- printf("%-*s ", (int)intridlen, "interrupt id");
- for (i = 0; i < ncpus; i++) {
- snprintf(buf, sizeof(buf), "CPU%u", i);
- printf("%*s ", cpucol[i], buf);
+ printf("%-*s", (int)intridlen, "interrupt id");
+ if (compact) {
+ printf(" %20s ", "total");
+ printf(" %20s ", "affinity");
+ } else {
+ for (i = 0; i < ncpus; i++) {
+ snprintf(buf, sizeof(buf), "CPU%u", i);
+ printf("%*s ", cpucol[i], buf);
+ }
}
printf("device name(s)\n");
/* body */
for (illine = intrctl_io_firstline(handle); illine != NULL;
illine = intrctl_io_nextline(handle, illine)) {
- printf("%-*s ", (int)intridlen, illine->ill_intrid);
- for (i = 0; i < ncpus; i++) {
- struct intrio_list_line_cpu *illc = &illine->ill_cpu[i];
- printf("%*" PRIu64 "%c ", cpucol[i], illc->illc_count,
- illc->illc_assigned ? '*' : ' ');
+ struct intrio_list_line_cpu *illc;
+
+ printf("%-*s ", (int)intridlen, illine->ill_intrid);
+ if (compact) {
+ uint64_t total = 0;
+ char *affinity, *oaffinity = NULL;
+ for (i = 0; i < ncpus; i++) {
+ illc = &illine->ill_cpu[i];
+ total += illc->illc_count;
+ if (illc->illc_assigned) {
+ asprintf(&affinity, "%s%s%d",
+ oaffinity ? oaffinity : "",
+ oaffinity ? ", " : "",
+ i);
+ if (oaffinity)
+ free(oaffinity);
+ oaffinity = affinity;
+ }
+ }
+ printf("%20" PRIu64 " ", total);
+ printf("%20s ", affinity ? affinity : "none");
+ free(affinity);
+ } else {
+ for (i = 0; i < ncpus; i++) {
+ illc = &illine->ill_cpu[i];
+ printf("%*" PRIu64 "%c ", cpucol[i], illc->illc_count,
+ illc->illc_assigned ? '*' : ' ');
+ }
}
printf("%s\n", illine->ill_xname);
}
Home |
Main Index |
Thread Index |
Old Index