summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Mooney <pmooney@pfmooney.com>2016-03-11 22:25:51 +0000
committerPatrick Mooney <pmooney@pfmooney.com>2016-03-11 22:55:07 +0000
commit9ec912c21521e92e1de73a78ac141cf60433b5b3 (patch)
tree34c8ddf1359018335a9357aeac5673fc97123206
parente3e17e7e2383f385142571c19b60d2ecec66c4cd (diff)
downloadillumos-joyent-9ec912c21521e92e1de73a78ac141cf60433b5b3.tar.gz
OS-5233 lxbrand mapr wants /proc/vmstat
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
-rw-r--r--usr/src/uts/common/brand/lx/procfs/lx_proc.h1
-rw-r--r--usr/src/uts/common/brand/lx/procfs/lx_prvnops.c58
2 files changed, 58 insertions, 1 deletions
diff --git a/usr/src/uts/common/brand/lx/procfs/lx_proc.h b/usr/src/uts/common/brand/lx/procfs/lx_proc.h
index f2867bc19d..cd4d440450 100644
--- a/usr/src/uts/common/brand/lx/procfs/lx_proc.h
+++ b/usr/src/uts/common/brand/lx/procfs/lx_proc.h
@@ -223,6 +223,7 @@ typedef enum lxpr_nodetype {
LXPR_SYS_VM_SWAPPINESS, /* /proc/sys/vm/swappiness */
LXPR_UPTIME, /* /proc/uptime */
LXPR_VERSION, /* /proc/version */
+ LXPR_VMSTAT, /* /proc/vmstat */
LXPR_NFILES /* number of lx /proc file types */
} lxpr_nodetype_t;
diff --git a/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c b/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c
index e0986523b7..2ce11340f3 100644
--- a/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c
+++ b/usr/src/uts/common/brand/lx/procfs/lx_prvnops.c
@@ -164,6 +164,7 @@ static void lxpr_read_stat(lxpr_node_t *, lxpr_uiobuf_t *);
static void lxpr_read_swaps(lxpr_node_t *, lxpr_uiobuf_t *);
static void lxpr_read_uptime(lxpr_node_t *, lxpr_uiobuf_t *);
static void lxpr_read_version(lxpr_node_t *, lxpr_uiobuf_t *);
+static void lxpr_read_vmstat(lxpr_node_t *, lxpr_uiobuf_t *);
static void lxpr_read_pid_auxv(lxpr_node_t *, lxpr_uiobuf_t *);
static void lxpr_read_pid_cgroup(lxpr_node_t *, lxpr_uiobuf_t *);
@@ -306,7 +307,8 @@ static lxpr_dirent_t lx_procdir[] = {
{ LXPR_SWAPS, "swaps" },
{ LXPR_SYSDIR, "sys" },
{ LXPR_UPTIME, "uptime" },
- { LXPR_VERSION, "version" }
+ { LXPR_VERSION, "version" },
+ { LXPR_VMSTAT, "vmstat" }
};
#define PROCDIRFILES (sizeof (lx_procdir) / sizeof (lx_procdir[0]))
@@ -729,6 +731,7 @@ static void (*lxpr_read_function[LXPR_NFILES])() = {
lxpr_read_sys_vm_swappiness, /* /proc/sys/vm/swappiness */
lxpr_read_uptime, /* /proc/uptime */
lxpr_read_version, /* /proc/version */
+ lxpr_read_vmstat, /* /proc/vmstat */
};
/*
@@ -850,6 +853,7 @@ static vnode_t *(*lxpr_lookup_function[LXPR_NFILES])() = {
lxpr_lookup_not_a_dir, /* /proc/sys/vm/swappiness */
lxpr_lookup_not_a_dir, /* /proc/uptime */
lxpr_lookup_not_a_dir, /* /proc/version */
+ lxpr_lookup_not_a_dir, /* /proc/vmstat */
};
/*
@@ -971,6 +975,7 @@ static int (*lxpr_readdir_function[LXPR_NFILES])() = {
lxpr_readdir_not_a_dir, /* /proc/sys/vm/swappiness */
lxpr_readdir_not_a_dir, /* /proc/uptime */
lxpr_readdir_not_a_dir, /* /proc/version */
+ lxpr_readdir_not_a_dir, /* /proc/vmstat */
};
@@ -3774,6 +3779,57 @@ lxpr_read_version(lxpr_node_t *lxpnp, lxpr_uiobuf_t *uiobuf)
version);
}
+/* ARGSUSED */
+static void
+lxpr_read_vmstat(lxpr_node_t *lxpnp, lxpr_uiobuf_t *uiobuf)
+{
+ cpu_t *cp, *cpstart;
+ int pools_enabled;
+
+ ulong_t pgpgin_cum = 0;
+ ulong_t pgpgout_cum = 0;
+ ulong_t pgswapout_cum = 0;
+ ulong_t pgswapin_cum = 0;
+
+ mutex_enter(&cpu_lock);
+ pools_enabled = pool_pset_enabled();
+ /* Calculate cumulative stats */
+ cp = cpstart = CPU->cpu_part->cp_cpulist;
+ do {
+ /* Only count CPUs which are present and active. */
+ if ((cp->cpu_flags & CPU_EXISTS) == 0) {
+ continue;
+ }
+
+ pgpgin_cum += CPU_STATS(cp, vm.pgpgin);
+ pgpgout_cum += CPU_STATS(cp, vm.pgpgout);
+ pgswapin_cum += CPU_STATS(cp, vm.pgswapin);
+ pgswapout_cum += CPU_STATS(cp, vm.pgswapout);
+
+ if (pools_enabled)
+ cp = cp->cpu_next_part;
+ else
+ cp = cp->cpu_next;
+ } while (cp != cpstart);
+ mutex_exit(&cpu_lock);
+
+ /*
+ * Needless to say, the metrics presented by vmstat are very specific
+ * to the internals of the Linux kernel. There is little per-zone
+ * information which can be translated in a meaningful way to fit the
+ * expected fields. For the time being, the output is kept sparse.
+ */
+ lxpr_uiobuf_printf(uiobuf,
+ "pgpgin %lu\n"
+ "pgpgout %lu\n"
+ "pswpin %lu\n"
+ "pswpout %lu\n",
+ pgpgin_cum,
+ pgpgout_cum,
+ pgswapin_cum,
+ pgswapout_cum);
+}
+
/*
* lxpr_read_stat(): read the contents of the "stat" file.
*