summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason King <jason.king@joyent.com>2019-09-12 00:52:08 +0000
committerJason King <jason.king@joyent.com>2020-12-08 19:13:04 +0000
commit74cd4c72cbe1e6fdf471dfad935cc6011fe62590 (patch)
treee4cc286e2ea7cd2f031cdf90383697cb324fd218
parent64504b81f4af053d3882aaa5f5b8488c43ba6f9c (diff)
downloadillumos-joyent-74cd4c72cbe1e6fdf471dfad935cc6011fe62590.tar.gz
Add some consolidationintrd
-rw-r--r--usr/src/cmd/intrd/intrd.c51
-rw-r--r--usr/src/cmd/intrd/intrd_kstat.c16
2 files changed, 46 insertions, 21 deletions
diff --git a/usr/src/cmd/intrd/intrd.c b/usr/src/cmd/intrd/intrd.c
index 9ad576a906..4486f58bc7 100644
--- a/usr/src/cmd/intrd/intrd.c
+++ b/usr/src/cmd/intrd/intrd.c
@@ -10,8 +10,9 @@
*/
/*
- * Copyright 2018, Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
*/
+
#define __EXTENSIONS__
#include <err.h>
@@ -39,8 +40,8 @@
#include "intrd.h"
-#if 0
static int intrd_daemonize(void);
+#if 0
static void intrd_dfatal(int, const char *, ...);
#endif
@@ -54,6 +55,8 @@ uint_t cfg_idle_interval = 45;
uint_t max_cpu;
+extern const char *__progname;
+
#ifdef DEBUG
const char *
_umem_debug_init(void)
@@ -75,6 +78,16 @@ nomem(void)
return (UMEM_CALLBACK_EXIT(255));
}
+static void __NORETURN
+usage(void)
+{
+ (void) fprintf(stderr,
+ "Usage: %s [-d]\n"
+ "\t-d don't fork in the background\n",
+ __progname);
+ exit(EXIT_FAILURE);
+}
+
int
main(int argc, char **argv)
{
@@ -87,23 +100,35 @@ main(int argc, char **argv)
.cfg_statslen = 120,
.cfg_tooslow = 0.05
};
-#if 0
+ int c;
+ boolean_t opt_d = B_FALSE;
+
+ while ((c = getopt(argc, argv, "d")) != -1) {
+ switch (c) {
+ case 'd':
+ opt_d = B_TRUE;
+ break;
+ case '?':
+ (void) fprintf(stderr, "Unrecognized option -%c\n",
+ optopt);
+ usage();
+ }
+ }
+
int dfd, status;
-#endif
umem_nofail_callback(nomem);
-#if 0
- dfd = intrd_daemonize();
-#endif
+ if (!opt_d)
+ dfd = intrd_daemonize();
setup(&kcp, &cfg);
-#if 0
- status = 0;
- (void) write(dfd, &status, sizeof (status));
- (void) close(dfd);
-#endif
+ if (!opt_d) {
+ status = 0;
+ (void) write(dfd, &status, sizeof (status));
+ (void) close(dfd);
+ }
loop(&cfg, kcp);
@@ -111,7 +136,6 @@ main(int argc, char **argv)
return (0);
}
-#if 0
static int
intrd_daemonize(void)
{
@@ -193,7 +217,6 @@ intrd_daemonize(void)
return (pfds[1]);
}
-#endif
static void
setup(kstat_ctl_t **restrict kcpp, config_t *restrict cfg)
diff --git a/usr/src/cmd/intrd/intrd_kstat.c b/usr/src/cmd/intrd/intrd_kstat.c
index 635f528468..3379c68274 100644
--- a/usr/src/cmd/intrd/intrd_kstat.c
+++ b/usr/src/cmd/intrd/intrd_kstat.c
@@ -272,6 +272,14 @@ consolidate_ivec_cb(stats_t *stp, cpustat_t *cs, void *arg)
if (!ivec_shared_intr(iv, ivnext))
break;
+ (void) printf("combining:\n"
+ " %s %s %llu\n"
+ " %s %s %llu\n\n",
+ custr_cstr(iv->ivec_name), iv->ivec_buspath,
+ iv->ivec_ino,
+ custr_cstr(ivnext->ivec_name), ivnext->ivec_buspath,
+ ivnext->ivec_ino);
+
iv->ivec_nshared++;
iv->ivec_time += ivnext->ivec_time;
VERIFY0(custr_appendc(iv->ivec_name, '/'));
@@ -279,6 +287,7 @@ consolidate_ivec_cb(stats_t *stp, cpustat_t *cs, void *arg)
custr_cstr(ivnext->ivec_name)));
list_remove(ivlist, ivnext);
+ cs->cs_nivecs--;
ivec_free(ivnext);
}
}
@@ -295,19 +304,12 @@ consolidate_ivecs(stats_t *stp)
static boolean_t
ivec_shared_intr(const ivec_t *i1, const ivec_t *i2)
{
- /*
- * XXX This needs to be revisited
- */
-#if 0
if (i1->ivec_ino != i2->ivec_ino)
return (B_FALSE);
if (strcmp(i1->ivec_buspath, i2->ivec_buspath) != 0)
return (B_FALSE);
return (B_TRUE);
-#else
- return (B_FALSE);
-#endif
}
#if 0