summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason King <jason.king@joyent.com>2018-10-18 10:43:27 -0500
committerJason King <jason.king@joyent.com>2020-12-08 19:13:02 +0000
commit6269987a15679faab5f29cb989ae7cf912c8023e (patch)
tree12eea7e188f2ca9b8e5c362a0779f6d106db0a17
parent520f42e61cb7ed430d51d3fc3c783c9387001f1d (diff)
downloadillumos-joyent-6269987a15679faab5f29cb989ae7cf912c8023e.tar.gz
Display loads for debugging
-rw-r--r--usr/src/cmd/intrd/intrd.c64
-rw-r--r--usr/src/cmd/intrd/intrd.h2
2 files changed, 36 insertions, 30 deletions
diff --git a/usr/src/cmd/intrd/intrd.c b/usr/src/cmd/intrd/intrd.c
index 62a27f3d96..5a3db4b0d0 100644
--- a/usr/src/cmd/intrd/intrd.c
+++ b/usr/src/cmd/intrd/intrd.c
@@ -43,6 +43,8 @@ static void intrd_dfatal(int, const char *, ...);
static void setup(kstat_ctl_t **restrict, config_t *restrict);
static void loop(const config_t *restrict, kstat_ctl_t *restrict);
static void delta_save(stats_t **, size_t, stats_t *, uint_t);
+static load_t *calc_load(stats_t *);
+static void load_free(load_t *);
uint_t max_cpu;
@@ -210,8 +212,6 @@ setup(kstat_ctl_t **restrict kcpp, config_t *restrict cfg)
static void
loop(const config_t *restrict cfg, kstat_ctl_t *restrict kcp)
{
- printf("avg int: %u interval: %u\n", cfg->cfg_avginterval, cfg->cfg_interval); fflush(stdout);
-
const size_t deltas_sz = cfg->cfg_avginterval / cfg->cfg_interval + 1;
stats_t *stats[2] = { 0 };
@@ -242,8 +242,30 @@ loop(const config_t *restrict cfg, kstat_ctl_t *restrict kcp)
delta_save(deltas, deltas_sz, delta, cfg->cfg_statslen);
sum = stats_sum(deltas, deltas_sz, &ndeltas);
- printf("Delta\n");
- stats_dump(delta);
+ {
+ stats_t *st = (sum != NULL) ? sum : delta;
+ load_t *load = calc_load(st);
+
+ for (size_t i = 0; i < st->sts_ncpu; i++) {
+ load_t *cpuload;
+ int cpuid = st->sts_cpu[i]->cs_cpuid;
+ double pct;
+
+ cpuload = LOAD_CPU(load, cpuid);
+ pct = (double)cpuload->ld_intrtotal /
+ cpuload->ld_total;
+ (void) printf("CPU %3d %.1f%% intr\n", cpuid,
+ pct);
+ if (cpuload->ld_bigint == NULL)
+ continue;
+
+ (void) printf(" Big intr: %s int#%llu\n",
+ custr_cstr(cpuload->ld_bigint->ivec_name),
+ cpuload->ld_bigint->ivec_ino);
+ }
+
+ load_free(load);
+ }
}
}
@@ -324,8 +346,7 @@ calc_load(stats_t *stp)
for (iv = list_head(&cs->cs_ivecs); iv != NULL;
iv = list_next(&cs->cs_ivecs, iv)) {
lcpu->ld_intrtotal += iv->ivec_time;
- if (lcpu->ld_bigint == NULL ||
- lcpu->ld_bigint->ivec_time < iv->ivec_time)
+ if (LOAD_BIGINT_LOAD(lcpu) < iv->ivec_time)
lcpu->ld_bigint = iv;
}
@@ -339,29 +360,6 @@ calc_load(stats_t *stp)
return (ld);
}
-static void *
-filter(void *arr, size_t n, void *(*cb)(void *, void *), void *arg)
-{
- char **pp = arr;
- char **new = xcalloc(n, sizeof (char *));
- size_t len = 0;
-
- for (size_t i = 0; i < n; i++) {
- void *p = cb(pp[i], arg);
-
- if (p != NULL) {
- new[len++] = p;
- }
- }
-
- if (len == 0) {
- free(new);
- return (NULL);
- }
-
- return (xreallocarray(new, len, sizeof (char *)));
-}
-
int
cpustat_cmp_id(const void *a, const void *b)
{
@@ -418,6 +416,14 @@ ivec_cmp_cpu(const void *a, const void *b)
return (0);
}
+static void
+load_free(load_t *ld)
+{
+ if (ld == NULL)
+ return;
+ free(ld);
+}
+
char *
xstrdup(const char *s)
{
diff --git a/usr/src/cmd/intrd/intrd.h b/usr/src/cmd/intrd/intrd.h
index 4541008256..63126b62f9 100644
--- a/usr/src/cmd/intrd/intrd.h
+++ b/usr/src/cmd/intrd/intrd.h
@@ -115,7 +115,7 @@ typedef struct load {
#define LOAD_LGRP(_load, _id) ((_load) + max_cpu + (_id))
#define LOAD_CPU(_load, _id) ((_load) + (_id))
#define LOAD_BIGINT_LOAD(_load) \
- (((_load)->ld_bigint != NULL) ? (_load)->ld_bigint : 0)
+ (((_load)->ld_bigint != NULL) ? (_load)->ld_bigint->ivec_time : 0)
#define LOAD_MAXINT(_l1, _l2) \
((LOAD_BIGINT_LOAD(_l1) > LOAD_BIGINT_LOAD(_l2)) ? \
(_l1)->ld_bigint : (_l2)->ld_bigint)