diff options
author | Nathan Scott <nathans@redhat.com> | 2020-08-20 18:24:35 +1000 |
---|---|---|
committer | Nathan Scott <nathans@redhat.com> | 2020-08-20 18:24:35 +1000 |
commit | 9a55efc8b52578a9465c5fd4d82c44ad48a16018 (patch) | |
tree | a3ffdebe913e85ffde0f183f1209b11082a8c056 /linux | |
parent | 31391b206c536cdcd46c335b58ea6ecf6deeba1f (diff) | |
parent | a267003f2f38df5d52ae3f07658c1bbd20b5fb5e (diff) |
Merge branch 'hishamhm-pull-920'3.0.0rc1
Diffstat (limited to 'linux')
-rw-r--r-- | linux/LinuxProcessList.c | 70 | ||||
-rw-r--r-- | linux/LinuxProcessList.h | 7 | ||||
-rw-r--r-- | linux/Platform.c | 15 | ||||
-rw-r--r-- | linux/Platform.h | 3 |
4 files changed, 95 insertions, 0 deletions
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index 64a4ffeb..bcdd5515 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -45,6 +45,7 @@ in the source distribution for its full text. /*{ #include "ProcessList.h" +#include "zfs/ZfsArcStats.h" extern long long btime; @@ -96,6 +97,8 @@ typedef struct LinuxProcessList_ { struct nl_sock *netlink_socket; int netlink_family; #endif + + ZfsArcStats zfs; } LinuxProcessList; #ifndef PROCDIR @@ -114,6 +117,10 @@ typedef struct LinuxProcessList_ { #define PROCMEMINFOFILE PROCDIR "/meminfo" #endif +#ifndef PROCARCSTATSFILE +#define PROCARCSTATSFILE PROCDIR "/spl/kstat/zfs/arcstats" +#endif + #ifndef PROCTTYDRIVERSFILE #define PROCTTYDRIVERSFILE PROCDIR "/tty/drivers" #endif @@ -1054,6 +1061,68 @@ static inline void LinuxProcessList_scanMemoryInfo(ProcessList* this) { fclose(file); } +static inline void LinuxProcessList_scanZfsArcstats(LinuxProcessList* lpl) { + unsigned long long int dbufSize; + unsigned long long int dnodeSize; + unsigned long long int bonusSize; + + FILE* file = fopen(PROCARCSTATSFILE, "r"); + if (file == NULL) { + lpl->zfs.enabled = 0; + return; + } + char buffer[128]; + while (fgets(buffer, 128, file)) { + #define tryRead(label, variable) do { if (String_startsWith(buffer, label) && sscanf(buffer + strlen(label), " %*2u %32llu", variable)) { break; } } while(0) + #define tryReadFlag(label, variable, flag) do { if (String_startsWith(buffer, label) && sscanf(buffer + strlen(label), " %*2u %32llu", variable)) { flag = 1; break; } else { flag = 0; } } while(0) + switch (buffer[0]) { + case 'c': + tryRead("c_max", &lpl->zfs.max); + tryReadFlag("compressed_size", &lpl->zfs.compressed, lpl->zfs.isCompressed); + break; + case 'u': + tryRead("uncompressed_size", &lpl->zfs.uncompressed); + break; + case 's': + tryRead("size", &lpl->zfs.size); + break; + case 'h': + tryRead("hdr_size", &lpl->zfs.header); + break; + case 'd': + tryRead("dbuf_size", &dbufSize); + tryRead("dnode_size", &dnodeSize); + break; + case 'b': + tryRead("bonus_size", &bonusSize); + break; + case 'a': + tryRead("anon_size", &lpl->zfs.anon); + break; + case 'm': + tryRead("mfu_size", &lpl->zfs.MFU); + tryRead("mru_size", &lpl->zfs.MRU); + break; + } + #undef tryRead + #undef tryReadFlag + } + fclose(file); + + lpl->zfs.enabled = (lpl->zfs.size > 0 ? 1 : 0); + lpl->zfs.size /= 1024; + lpl->zfs.max /= 1024; + lpl->zfs.MFU /= 1024; + lpl->zfs.MRU /= 1024; + lpl->zfs.anon /= 1024; + lpl->zfs.header /= 1024; + lpl->zfs.other = (dbufSize + dnodeSize + bonusSize) / 1024; + if ( lpl->zfs.isCompressed ) { + lpl->zfs.compressed /= 1024; + lpl->zfs.uncompressed /= 1024; + } +} + static inline double LinuxProcessList_scanCPUTime(LinuxProcessList* this) { FILE* file = fopen(PROCSTATFILE, "r"); @@ -1194,6 +1263,7 @@ void ProcessList_goThroughEntries(ProcessList* super) { LinuxProcessList* this = (LinuxProcessList*) super; LinuxProcessList_scanMemoryInfo(super); + LinuxProcessList_scanZfsArcstats(this); double period = LinuxProcessList_scanCPUTime(this); LinuxProcessList_scanCPUFrequency(this); diff --git a/linux/LinuxProcessList.h b/linux/LinuxProcessList.h index 24b94d87..86e9d3fd 100644 --- a/linux/LinuxProcessList.h +++ b/linux/LinuxProcessList.h @@ -18,6 +18,7 @@ in the source distribution for its full text. #include "ProcessList.h" +#include "zfs/ZfsArcStats.h" extern long long btime; @@ -69,6 +70,8 @@ typedef struct LinuxProcessList_ { struct nl_sock *netlink_socket; int netlink_family; #endif + + ZfsArcStats zfs; } LinuxProcessList; #ifndef PROCDIR @@ -87,6 +90,10 @@ typedef struct LinuxProcessList_ { #define PROCMEMINFOFILE PROCDIR "/meminfo" #endif +#ifndef PROCARCSTATSFILE +#define PROCARCSTATSFILE PROCDIR "/spl/kstat/zfs/arcstats" +#endif + #ifndef PROCTTYDRIVERSFILE #define PROCTTYDRIVERSFILE PROCDIR "/tty/drivers" #endif diff --git a/linux/Platform.c b/linux/Platform.c index 00a91a5e..1725eea9 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -22,6 +22,8 @@ in the source distribution for its full text. #include "PressureStallMeter.h" #include "ClockMeter.h" #include "HostnameMeter.h" +#include "zfs/ZfsArcMeter.h" +#include "zfs/ZfsCompressedArcMeter.h" #include "LinuxProcess.h" #include <math.h> @@ -135,6 +137,8 @@ MeterClass* Platform_meterTypes[] = { &PressureStallIOFullMeter_class, &PressureStallMemorySomeMeter_class, &PressureStallMemoryFullMeter_class, + &ZfsArcMeter_class, + &ZfsCompressedArcMeter_class, NULL }; @@ -225,6 +229,17 @@ void Platform_setSwapValues(Meter* this) { this->values[0] = pl->usedSwap; } +void Platform_setZfsArcValues(Meter* this) { + LinuxProcessList* lpl = (LinuxProcessList*) this->pl; + + ZfsArcMeter_readStats(this, &(lpl->zfs)); +} + +void Platform_setZfsCompressedArcValues(Meter* this) { + LinuxProcessList* lpl = (LinuxProcessList*) this->pl; + + ZfsCompressedArcMeter_readStats(this, &(lpl->zfs)); +} char* Platform_getProcessEnv(pid_t pid) { char procname[32+1]; xSnprintf(procname, 32, "/proc/%d/environ", pid); diff --git a/linux/Platform.h b/linux/Platform.h index bb2c4b09..bf163a54 100644 --- a/linux/Platform.h +++ b/linux/Platform.h @@ -43,6 +43,9 @@ extern void Platform_setMemoryValues(Meter* this); extern void Platform_setSwapValues(Meter* this); +extern void Platform_setZfsArcValues(Meter* this); + +extern void Platform_setZfsCompressedArcValues(Meter* this); extern char* Platform_getProcessEnv(pid_t pid); extern void Platform_getPressureStall(const char *file, bool some, double* ten, double* sixty, double* threehundred); |