about summary refs log tree commit diff
path: root/users/multi/pkgs/htop/zfs-arc-stats/0006-ZFS-arcstats-for-Solaris.patch
diff options
context:
space:
mode:
Diffstat (limited to 'users/multi/pkgs/htop/zfs-arc-stats/0006-ZFS-arcstats-for-Solaris.patch')
-rw-r--r--users/multi/pkgs/htop/zfs-arc-stats/0006-ZFS-arcstats-for-Solaris.patch187
1 files changed, 187 insertions, 0 deletions
diff --git a/users/multi/pkgs/htop/zfs-arc-stats/0006-ZFS-arcstats-for-Solaris.patch b/users/multi/pkgs/htop/zfs-arc-stats/0006-ZFS-arcstats-for-Solaris.patch
new file mode 100644
index 000000000000..96f8d31591e8
--- /dev/null
+++ b/users/multi/pkgs/htop/zfs-arc-stats/0006-ZFS-arcstats-for-Solaris.patch
@@ -0,0 +1,187 @@
+From ff6914e4ad4b78749bcee5471a33ef206b0a7d03 Mon Sep 17 00:00:00 2001
+From: Ross Williams <ross@ross-williams.net>
+Date: Mon, 8 Jul 2019 02:43:39 +0000
+Subject: [PATCH 6/9] ZFS arcstats for Solaris
+
+---
+ Makefile.am                  |  7 +++++--
+ solaris/Platform.c           | 19 ++++++++++++++++++
+ solaris/Platform.h           |  2 ++
+ solaris/SolarisProcessList.c | 37 ++++++++++++++++++++++++++++++++++++
+ solaris/SolarisProcessList.h |  3 +++
+ 5 files changed, 66 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index 5eee631..204a8b7 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -157,14 +157,17 @@ solaris_platform_headers = \
+ 	solaris/SolarisProcess.h \
+ 	solaris/SolarisProcessList.h \
+ 	solaris/SolarisCRT.h \
+-	solaris/Battery.h
++	solaris/Battery.h \
++	zfs/ZfsArcMeter.h \
++	zfs/ZfsArcStats.h
+ 
+ all_platform_headers += $(solaris_platform_headers)
+ 
+ if HTOP_SOLARIS
+ myhtopplatsources = solaris/Platform.c \
+ solaris/SolarisProcess.c solaris/SolarisProcessList.c \
+-solaris/SolarisCRT.c solaris/Battery.c
++solaris/SolarisCRT.c solaris/Battery.c \
++zfs/ZfsArcMeter.c zfs/ZfsArcStats.c
+ 
+ myhtopplatheaders = $(solaris_platform_headers)
+ endif
+diff --git a/solaris/Platform.c b/solaris/Platform.c
+index a29fcb4..8084d1f 100644
+--- a/solaris/Platform.c
++++ b/solaris/Platform.c
+@@ -17,6 +17,7 @@ in the source distribution for its full text.
+ #include "ClockMeter.h"
+ #include "HostnameMeter.h"
+ #include "UptimeMeter.h"
++#include "zfs/ZfsArcMeter.h"
+ #include "SolarisProcess.h"
+ #include "SolarisProcessList.h"
+ 
+@@ -122,6 +123,7 @@ MeterClass* Platform_meterTypes[] = {
+    &RightCPUsMeter_class,
+    &LeftCPUs2Meter_class,
+    &RightCPUs2Meter_class,
++   &ZfsArcMeter_class,
+    &BlankMeter_class,
+    NULL
+ };
+@@ -220,6 +222,23 @@ void Platform_setSwapValues(Meter* this) {
+    this->values[0] = pl->usedSwap;
+ }
+ 
++void Platform_setZfsArcValues(Meter* this) {
++   SolarisProcessList* spl = (SolarisProcessList*) this->pl;
++
++   this->total = spl->zfs.max;
++   this->values[0] = spl->zfs.MFU;
++   this->values[1] = spl->zfs.MRU;
++   this->values[2] = spl->zfs.anon;
++   this->values[3] = spl->zfs.header;
++   this->values[4] = spl->zfs.other;
++
++   // "Hide" the last value so it can
++   // only be accessed by index and is not
++   // displayed by the Bar or Graph style
++   Meter_setItems(this, 5);
++   this->values[5] = spl->zfs.size;
++}
++
+ static int Platform_buildenv(void *accum, struct ps_prochandle *Phandle, uintptr_t addr, const char *str) {
+    envAccum *accump = accum;
+    (void) Phandle;
+diff --git a/solaris/Platform.h b/solaris/Platform.h
+index f961b91..62757ff 100644
+--- a/solaris/Platform.h
++++ b/solaris/Platform.h
+@@ -60,6 +60,8 @@ void Platform_setMemoryValues(Meter* this);
+ 
+ void Platform_setSwapValues(Meter* this);
+ 
++void Platform_setZfsArcValues(Meter* this);
++
+ char* Platform_getProcessEnv(pid_t pid);
+ 
+ #endif
+diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c
+index 2c68185..b6bc6f5 100644
+--- a/solaris/SolarisProcessList.c
++++ b/solaris/SolarisProcessList.c
+@@ -27,6 +27,8 @@ in the source distribution for its full text.
+ 
+ /*{
+ 
++#include "zfs/ZfsArcStats.h"
++
+ #include <kstat.h>
+ #include <sys/param.h>
+ #include <sys/uio.h>
+@@ -55,6 +57,7 @@ typedef struct SolarisProcessList_ {
+    ProcessList super;
+    kstat_ctl_t* kd;
+    CPUData* cpus;
++   ZfsArcStats zfs;
+ } SolarisProcessList;
+ 
+ }*/
+@@ -230,6 +233,39 @@ static inline void SolarisProcessList_scanMemoryInfo(ProcessList* pl) {
+    pl->usedSwap  = pl->totalSwap - (totalfree * PAGE_SIZE_KB); 
+ }
+ 
++static inline void SolarisProcessList_scanZfsArcstats(ProcessList* pl) {
++   SolarisProcessList* spl = (SolarisProcessList*) pl;
++   kstat_t             *arcstats = NULL;
++   int                 ksrphyserr = -1;
++   kstat_named_t       *cur_kstat = NULL;
++
++   if (spl->kd != NULL)  { arcstats   = kstat_lookup(spl->kd,"zfs",0,"arcstats"); }
++   if (arcstats != NULL) { ksrphyserr = kstat_read(spl->kd,arcstats,NULL); }
++   if (ksrphyserr != -1) {
++      cur_kstat = kstat_data_lookup( arcstats, "size" );
++      spl->zfs.size = cur_kstat->value.ui64 / 1024;
++      spl->zfs.enabled = spl->zfs.size > 0 ? 1 : 0;
++
++      cur_kstat = kstat_data_lookup( arcstats, "c_max" );
++      spl->zfs.max = cur_kstat->value.ui64 / 1024;
++
++      cur_kstat = kstat_data_lookup( arcstats, "mfu_size" );
++      spl->zfs.MFU = cur_kstat->value.ui64 / 1024;
++
++      cur_kstat = kstat_data_lookup( arcstats, "mru_size" );
++      spl->zfs.MRU = cur_kstat->value.ui64 / 1024;
++
++      cur_kstat = kstat_data_lookup( arcstats, "anon_size" );
++      spl->zfs.anon = cur_kstat->value.ui64 / 1024;
++
++      cur_kstat = kstat_data_lookup( arcstats, "hdr_size" );
++      spl->zfs.header = cur_kstat->value.ui64 / 1024;
++
++      cur_kstat = kstat_data_lookup( arcstats, "other_size" );
++      spl->zfs.other = cur_kstat->value.ui64 / 1024;
++   }
++}
++
+ void ProcessList_delete(ProcessList* pl) {
+    SolarisProcessList* spl = (SolarisProcessList*) pl;
+    ProcessList_done(pl);
+@@ -367,6 +403,7 @@ int SolarisProcessList_walkproc(psinfo_t *_psinfo, lwpsinfo_t *_lwpsinfo, void *
+ void ProcessList_goThroughEntries(ProcessList* this) {
+    SolarisProcessList_scanCPUTime(this);
+    SolarisProcessList_scanMemoryInfo(this);
++   SolarisProcessList_scanZfsArcstats(this);
+    this->kernelThreads = 1;
+    proc_walk(&SolarisProcessList_walkproc, this, PR_WALK_LWP);
+ }
+diff --git a/solaris/SolarisProcessList.h b/solaris/SolarisProcessList.h
+index a5f2fbc..26bf449 100644
+--- a/solaris/SolarisProcessList.h
++++ b/solaris/SolarisProcessList.h
+@@ -13,6 +13,8 @@ in the source distribution for its full text.
+ #define MAXCMDLINE 255
+ 
+ 
++#include "zfs/ZfsArcStats.h"
++
+ #include <kstat.h>
+ #include <sys/param.h>
+ #include <sys/uio.h>
+@@ -41,6 +43,7 @@ typedef struct SolarisProcessList_ {
+    ProcessList super;
+    kstat_ctl_t* kd;
+    CPUData* cpus;
++   ZfsArcStats zfs;
+ } SolarisProcessList;
+ 
+ 
+-- 
+2.20.1
+