mirror of https://github.com/xzeldon/htop.git
Refactor common OpenZFS sysctl access
Darwin and FreeBSD export zfs kstats through the same APIs, so moving functions into a common file.
This commit is contained in:
parent
fc8e9a2d3e
commit
a88d2e313d
21
Makefile.am
21
Makefile.am
|
@ -36,10 +36,6 @@ TasksMeter.h UptimeMeter.h TraceScreen.h UsersTable.h Vector.h Process.h \
|
||||||
AffinityPanel.h HostnameMeter.h OpenFilesScreen.h Affinity.h IncSet.h Action.h \
|
AffinityPanel.h HostnameMeter.h OpenFilesScreen.h Affinity.h IncSet.h Action.h \
|
||||||
EnvScreen.h InfoScreen.h XAlloc.h
|
EnvScreen.h InfoScreen.h XAlloc.h
|
||||||
|
|
||||||
zfs_platform_sources = zfs/ZfsArcMeter.c
|
|
||||||
|
|
||||||
zfs_platform_headers = zfs/ZfsArcMeter.h
|
|
||||||
|
|
||||||
all_platform_headers =
|
all_platform_headers =
|
||||||
|
|
||||||
# Linux
|
# Linux
|
||||||
|
@ -53,7 +49,8 @@ linux_platform_headers = \
|
||||||
linux/LinuxProcessList.h \
|
linux/LinuxProcessList.h \
|
||||||
linux/LinuxCRT.h \
|
linux/LinuxCRT.h \
|
||||||
linux/Battery.h \
|
linux/Battery.h \
|
||||||
$(zfs_platform_headers)
|
zfs/ZfsArcMeter.h \
|
||||||
|
zfs/ZfsArcStats.h
|
||||||
|
|
||||||
all_platform_headers += $(linux_platform_headers)
|
all_platform_headers += $(linux_platform_headers)
|
||||||
|
|
||||||
|
@ -61,7 +58,7 @@ if HTOP_LINUX
|
||||||
AM_CFLAGS += -rdynamic
|
AM_CFLAGS += -rdynamic
|
||||||
myhtopplatsources = linux/Platform.c linux/IOPriorityPanel.c linux/IOPriority.c \
|
myhtopplatsources = linux/Platform.c linux/IOPriorityPanel.c linux/IOPriority.c \
|
||||||
linux/LinuxProcess.c linux/LinuxProcessList.c linux/LinuxCRT.c linux/Battery.c \
|
linux/LinuxProcess.c linux/LinuxProcessList.c linux/LinuxCRT.c linux/Battery.c \
|
||||||
$(zfs_platform_sources)
|
zfs/ZfsArcMeter.c zfs/ZfsArcStats.c
|
||||||
|
|
||||||
myhtopplatheaders = $(linux_platform_headers)
|
myhtopplatheaders = $(linux_platform_headers)
|
||||||
endif
|
endif
|
||||||
|
@ -75,14 +72,16 @@ freebsd_platform_headers = \
|
||||||
freebsd/FreeBSDProcess.h \
|
freebsd/FreeBSDProcess.h \
|
||||||
freebsd/FreeBSDCRT.h \
|
freebsd/FreeBSDCRT.h \
|
||||||
freebsd/Battery.h \
|
freebsd/Battery.h \
|
||||||
$(zfs_platform_headers)
|
zfs/ZfsArcMeter.h \
|
||||||
|
zfs/ZfsArcStats.h \
|
||||||
|
zfs/openzfs_sysctl.h
|
||||||
|
|
||||||
all_platform_headers += $(freebsd_platform_headers)
|
all_platform_headers += $(freebsd_platform_headers)
|
||||||
|
|
||||||
if HTOP_FREEBSD
|
if HTOP_FREEBSD
|
||||||
myhtopplatsources = freebsd/Platform.c freebsd/FreeBSDProcessList.c \
|
myhtopplatsources = freebsd/Platform.c freebsd/FreeBSDProcessList.c \
|
||||||
freebsd/FreeBSDProcess.c freebsd/FreeBSDCRT.c freebsd/Battery.c \
|
freebsd/FreeBSDProcess.c freebsd/FreeBSDCRT.c freebsd/Battery.c \
|
||||||
$(zfs_platform_sources)
|
zfs/ZfsArcMeter.c zfs/ZfsArcStats.c zfs/openzfs_sysctl.c
|
||||||
|
|
||||||
myhtopplatheaders = $(freebsd_platform_headers)
|
myhtopplatheaders = $(freebsd_platform_headers)
|
||||||
endif
|
endif
|
||||||
|
@ -135,7 +134,9 @@ darwin_platform_headers = \
|
||||||
darwin/DarwinProcessList.h \
|
darwin/DarwinProcessList.h \
|
||||||
darwin/DarwinCRT.h \
|
darwin/DarwinCRT.h \
|
||||||
darwin/Battery.h \
|
darwin/Battery.h \
|
||||||
$(zfs_platform_headers)
|
zfs/ZfsArcMeter.h \
|
||||||
|
zfs/ZfsArcStats.h \
|
||||||
|
zfs/openzfs_sysctl.h
|
||||||
|
|
||||||
all_platform_headers += $(darwin_platform_headers)
|
all_platform_headers += $(darwin_platform_headers)
|
||||||
|
|
||||||
|
@ -143,7 +144,7 @@ if HTOP_DARWIN
|
||||||
AM_LDFLAGS += -framework IOKit -framework CoreFoundation
|
AM_LDFLAGS += -framework IOKit -framework CoreFoundation
|
||||||
myhtopplatsources = darwin/Platform.c darwin/DarwinProcess.c \
|
myhtopplatsources = darwin/Platform.c darwin/DarwinProcess.c \
|
||||||
darwin/DarwinProcessList.c darwin/DarwinCRT.c darwin/Battery.c \
|
darwin/DarwinProcessList.c darwin/DarwinCRT.c darwin/Battery.c \
|
||||||
$(zfs_platform_sources)
|
zfs/ZfsArcMeter.c zfs/ZfsArcStats.c zfs/openzfs_sysctl.c
|
||||||
|
|
||||||
myhtopplatheaders = $(darwin_platform_headers)
|
myhtopplatheaders = $(darwin_platform_headers)
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -9,6 +9,8 @@ in the source distribution for its full text.
|
||||||
#include "DarwinProcess.h"
|
#include "DarwinProcess.h"
|
||||||
#include "DarwinProcessList.h"
|
#include "DarwinProcessList.h"
|
||||||
#include "CRT.h"
|
#include "CRT.h"
|
||||||
|
#include "zfs/ZfsArcStats.h"
|
||||||
|
#include "zfs/openzfs_sysctl.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -69,27 +71,11 @@ typedef struct DarwinProcessList_ {
|
||||||
uint64_t user_threads;
|
uint64_t user_threads;
|
||||||
uint64_t global_diff;
|
uint64_t global_diff;
|
||||||
|
|
||||||
int zfsArcEnabled;
|
ZfsArcStats zfs;
|
||||||
unsigned long long int zfsArcMax;
|
|
||||||
unsigned long long int zfsArcSize;
|
|
||||||
unsigned long long int zfsArcMFU;
|
|
||||||
unsigned long long int zfsArcMRU;
|
|
||||||
unsigned long long int zfsArcAnon;
|
|
||||||
unsigned long long int zfsArcHeader;
|
|
||||||
unsigned long long int zfsArcOther;
|
|
||||||
|
|
||||||
} DarwinProcessList;
|
} DarwinProcessList;
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
static int MIB_kstat_zfs_misc_arcstats_c_max[5];
|
|
||||||
static int MIB_kstat_zfs_misc_arcstats_size[5];
|
|
||||||
static int MIB_kstat_zfs_misc_arcstats_mfu_size[5];
|
|
||||||
static int MIB_kstat_zfs_misc_arcstats_mru_size[5];
|
|
||||||
static int MIB_kstat_zfs_misc_arcstats_anon_size[5];
|
|
||||||
static int MIB_kstat_zfs_misc_arcstats_hdr_size[5];
|
|
||||||
static int MIB_kstat_zfs_misc_arcstats_other_size[5];
|
|
||||||
|
|
||||||
void ProcessList_getHostInfo(host_basic_info_data_t *p) {
|
void ProcessList_getHostInfo(host_basic_info_data_t *p) {
|
||||||
mach_msg_type_number_t info_size = HOST_BASIC_INFO_COUNT;
|
mach_msg_type_number_t info_size = HOST_BASIC_INFO_COUNT;
|
||||||
|
|
||||||
|
@ -150,48 +136,6 @@ struct kinfo_proc *ProcessList_getKInfoProcs(size_t *count) {
|
||||||
return processes;
|
return processes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void DarwinProcessList_scanZfsArcstats(DarwinProcessList* dpl) {
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
if (dpl->zfsArcEnabled) {
|
|
||||||
len = sizeof(dpl->zfsArcSize);
|
|
||||||
sysctl(MIB_kstat_zfs_misc_arcstats_size, 5, &(dpl->zfsArcSize), &len , NULL, 0);
|
|
||||||
/* TODO: adjust reported memory in use to move ARC from wired to inactive
|
|
||||||
Like:
|
|
||||||
// In bytes
|
|
||||||
dpl->vm_stats.wire_count -= dpl->zfsArcSize / vm_page_size;
|
|
||||||
dpl->vm_stats.inactive_count += dpl->zfsArcSize / vm_page_size;
|
|
||||||
// Would purgable_count be more true?
|
|
||||||
// Then convert to KB:
|
|
||||||
*/
|
|
||||||
dpl->zfsArcSize /= 1024;
|
|
||||||
|
|
||||||
len = sizeof(dpl->zfsArcMax);
|
|
||||||
sysctl(MIB_kstat_zfs_misc_arcstats_c_max, 5, &(dpl->zfsArcMax), &len , NULL, 0);
|
|
||||||
dpl->zfsArcMax /= 1024;
|
|
||||||
|
|
||||||
len = sizeof(dpl->zfsArcMFU);
|
|
||||||
sysctl(MIB_kstat_zfs_misc_arcstats_mfu_size, 5, &(dpl->zfsArcMFU), &len , NULL, 0);
|
|
||||||
dpl->zfsArcMFU /= 1024;
|
|
||||||
|
|
||||||
len = sizeof(dpl->zfsArcMRU);
|
|
||||||
sysctl(MIB_kstat_zfs_misc_arcstats_mru_size, 5, &(dpl->zfsArcMRU), &len , NULL, 0);
|
|
||||||
dpl->zfsArcMRU /= 1024;
|
|
||||||
|
|
||||||
len = sizeof(dpl->zfsArcAnon);
|
|
||||||
sysctl(MIB_kstat_zfs_misc_arcstats_anon_size, 5, &(dpl->zfsArcAnon), &len , NULL, 0);
|
|
||||||
dpl->zfsArcAnon /= 1024;
|
|
||||||
|
|
||||||
len = sizeof(dpl->zfsArcHeader);
|
|
||||||
sysctl(MIB_kstat_zfs_misc_arcstats_hdr_size, 5, &(dpl->zfsArcHeader), &len , NULL, 0);
|
|
||||||
dpl->zfsArcHeader /= 1024;
|
|
||||||
|
|
||||||
len = sizeof(dpl->zfsArcOther);
|
|
||||||
sysctl(MIB_kstat_zfs_misc_arcstats_other_size, 5, &(dpl->zfsArcOther), &len , NULL, 0);
|
|
||||||
dpl->zfsArcOther /= 1024;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
|
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
|
||||||
size_t len;
|
size_t len;
|
||||||
DarwinProcessList* this = xCalloc(1, sizeof(DarwinProcessList));
|
DarwinProcessList* this = xCalloc(1, sizeof(DarwinProcessList));
|
||||||
|
@ -207,22 +151,8 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui
|
||||||
ProcessList_getVMStats(&this->vm_stats);
|
ProcessList_getVMStats(&this->vm_stats);
|
||||||
|
|
||||||
/* Initialize the ZFS kstats, if zfs.kext loaded */
|
/* Initialize the ZFS kstats, if zfs.kext loaded */
|
||||||
len = sizeof(this->zfsArcSize);
|
this->zfs.enabled = openzfs_sysctl_init();
|
||||||
if (sysctlbyname("kstat.zfs.misc.arcstats.size", &this->zfsArcSize, &len,
|
openzfs_sysctl_updateArcStats(&this->zfs);
|
||||||
NULL, 0) == 0 && this->zfsArcSize != 0) {
|
|
||||||
this->zfsArcEnabled = 1;
|
|
||||||
|
|
||||||
len = 5;
|
|
||||||
sysctlnametomib("kstat.zfs.misc.arcstats.size", MIB_kstat_zfs_misc_arcstats_size, &len);
|
|
||||||
sysctlnametomib("kstat.zfs.misc.arcstats.c_max", MIB_kstat_zfs_misc_arcstats_c_max, &len);
|
|
||||||
sysctlnametomib("kstat.zfs.misc.arcstats.mfu_size", MIB_kstat_zfs_misc_arcstats_mfu_size, &len);
|
|
||||||
sysctlnametomib("kstat.zfs.misc.arcstats.mru_size", MIB_kstat_zfs_misc_arcstats_mru_size, &len);
|
|
||||||
sysctlnametomib("kstat.zfs.misc.arcstats.anon_size", MIB_kstat_zfs_misc_arcstats_anon_size, &len);
|
|
||||||
sysctlnametomib("kstat.zfs.misc.arcstats.hdr_size", MIB_kstat_zfs_misc_arcstats_hdr_size, &len);
|
|
||||||
sysctlnametomib("kstat.zfs.misc.arcstats.other_size", MIB_kstat_zfs_misc_arcstats_other_size, &len);
|
|
||||||
} else {
|
|
||||||
this->zfsArcEnabled = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->super.kernelThreads = 0;
|
this->super.kernelThreads = 0;
|
||||||
this->super.userlandThreads = 0;
|
this->super.userlandThreads = 0;
|
||||||
|
@ -252,7 +182,7 @@ void ProcessList_goThroughEntries(ProcessList* super) {
|
||||||
dpl->prev_load = dpl->curr_load;
|
dpl->prev_load = dpl->curr_load;
|
||||||
ProcessList_allocateCPULoadInfo(&dpl->curr_load);
|
ProcessList_allocateCPULoadInfo(&dpl->curr_load);
|
||||||
ProcessList_getVMStats(&dpl->vm_stats);
|
ProcessList_getVMStats(&dpl->vm_stats);
|
||||||
DarwinProcessList_scanZfsArcstats(dpl);
|
openzfs_sysctl_updateArcStats(&dpl->zfs);
|
||||||
|
|
||||||
/* Get the time difference */
|
/* Get the time difference */
|
||||||
dpl->global_diff = 0;
|
dpl->global_diff = 0;
|
||||||
|
|
|
@ -21,6 +21,7 @@ negative value if more than the installed version
|
||||||
int CompareKernelVersion(short int major, short int minor, short int component);
|
int CompareKernelVersion(short int major, short int minor, short int component);
|
||||||
|
|
||||||
#include "ProcessList.h"
|
#include "ProcessList.h"
|
||||||
|
#include "zfs/ZfsArcStats.h"
|
||||||
#include <mach/mach_host.h>
|
#include <mach/mach_host.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
|
@ -35,15 +36,7 @@ typedef struct DarwinProcessList_ {
|
||||||
uint64_t user_threads;
|
uint64_t user_threads;
|
||||||
uint64_t global_diff;
|
uint64_t global_diff;
|
||||||
|
|
||||||
int zfsArcEnabled;
|
ZfsArcStats zfs;
|
||||||
unsigned long long int zfsArcMax;
|
|
||||||
unsigned long long int zfsArcSize;
|
|
||||||
unsigned long long int zfsArcMFU;
|
|
||||||
unsigned long long int zfsArcMRU;
|
|
||||||
unsigned long long int zfsArcAnon;
|
|
||||||
unsigned long long int zfsArcHeader;
|
|
||||||
unsigned long long int zfsArcOther;
|
|
||||||
|
|
||||||
} DarwinProcessList;
|
} DarwinProcessList;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -246,18 +246,18 @@ void Platform_setSwapValues(Meter* mtr) {
|
||||||
void Platform_setZfsArcValues(Meter* this) {
|
void Platform_setZfsArcValues(Meter* this) {
|
||||||
DarwinProcessList* dpl = (DarwinProcessList*) this->pl;
|
DarwinProcessList* dpl = (DarwinProcessList*) this->pl;
|
||||||
|
|
||||||
this->total = dpl->zfsArcMax;
|
this->total = dpl->zfs.max;
|
||||||
this->values[0] = dpl->zfsArcMFU;
|
this->values[0] = dpl->zfs.MFU;
|
||||||
this->values[1] = dpl->zfsArcMRU;
|
this->values[1] = dpl->zfs.MRU;
|
||||||
this->values[2] = dpl->zfsArcAnon;
|
this->values[2] = dpl->zfs.anon;
|
||||||
this->values[3] = dpl->zfsArcHeader;
|
this->values[3] = dpl->zfs.header;
|
||||||
this->values[4] = dpl->zfsArcOther;
|
this->values[4] = dpl->zfs.other;
|
||||||
|
|
||||||
// "Hide" the last value so it can
|
// "Hide" the last value so it can
|
||||||
// only be accessed by index and is not
|
// only be accessed by index and is not
|
||||||
// displayed by the Bar or Graph style
|
// displayed by the Bar or Graph style
|
||||||
Meter_setItems(this, 5);
|
Meter_setItems(this, 5);
|
||||||
this->values[5] = dpl->zfsArcSize;
|
this->values[5] = dpl->zfs.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* Platform_getProcessEnv(pid_t pid) {
|
char* Platform_getProcessEnv(pid_t pid) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ void Platform_setMemoryValues(Meter* mtr);
|
||||||
|
|
||||||
void Platform_setSwapValues(Meter* mtr);
|
void Platform_setSwapValues(Meter* mtr);
|
||||||
|
|
||||||
void Platform_setZfsArcValues(Meter* mtr);
|
void Platform_setZfsArcValues(Meter* this);
|
||||||
|
|
||||||
char* Platform_getProcessEnv(pid_t pid);
|
char* Platform_getProcessEnv(pid_t pid);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ in the source distribution for its full text.
|
||||||
#include "ProcessList.h"
|
#include "ProcessList.h"
|
||||||
#include "FreeBSDProcessList.h"
|
#include "FreeBSDProcessList.h"
|
||||||
#include "FreeBSDProcess.h"
|
#include "FreeBSDProcess.h"
|
||||||
|
#include "zfs/ZfsArcStats.h"
|
||||||
|
#include "zfs/openzfs_sysctl.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -21,6 +23,8 @@ in the source distribution for its full text.
|
||||||
|
|
||||||
/*{
|
/*{
|
||||||
|
|
||||||
|
#include "zfs/ZfsArcStats.h"
|
||||||
|
|
||||||
#include <kvm.h>
|
#include <kvm.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/jail.h>
|
#include <sys/jail.h>
|
||||||
|
@ -45,20 +49,12 @@ typedef struct FreeBSDProcessList_ {
|
||||||
ProcessList super;
|
ProcessList super;
|
||||||
kvm_t* kd;
|
kvm_t* kd;
|
||||||
|
|
||||||
int zfsArcEnabled;
|
|
||||||
|
|
||||||
unsigned long long int memWire;
|
unsigned long long int memWire;
|
||||||
unsigned long long int memActive;
|
unsigned long long int memActive;
|
||||||
unsigned long long int memInactive;
|
unsigned long long int memInactive;
|
||||||
unsigned long long int memFree;
|
unsigned long long int memFree;
|
||||||
unsigned long long int memZfsArc;
|
|
||||||
|
|
||||||
unsigned long long int zfsArcMax;
|
ZfsArcStats zfs;
|
||||||
unsigned long long int zfsArcMFU;
|
|
||||||
unsigned long long int zfsArcMRU;
|
|
||||||
unsigned long long int zFsArcAnon;
|
|
||||||
unsigned long long int zFsArcHeader;
|
|
||||||
unsigned long long int zFsArcOther;
|
|
||||||
|
|
||||||
CPUData* cpus;
|
CPUData* cpus;
|
||||||
|
|
||||||
|
@ -86,14 +82,6 @@ static int MIB_vm_stats_vm_v_free_count[4];
|
||||||
|
|
||||||
static int MIB_vfs_bufspace[2];
|
static int MIB_vfs_bufspace[2];
|
||||||
|
|
||||||
static int MIB_kstat_zfs_misc_arcstats_size[5];
|
|
||||||
static int MIB_vfs_zfs_arc_max[3];
|
|
||||||
static int MIB_kstat_zfs_misc_arcstats_mfu_size[5];
|
|
||||||
static int MIB_kstat_zfs_misc_arcstats_mru_size[5];
|
|
||||||
static int MIB_kstat_zfs_misc_arcstats_anon_size[5];
|
|
||||||
static int MIB_kstat_zfs_misc_arcstats_hdr_size[5];
|
|
||||||
static int MIB_kstat_zfs_misc_arcstats_other_size[5];
|
|
||||||
|
|
||||||
static int MIB_kern_cp_time[2];
|
static int MIB_kern_cp_time[2];
|
||||||
static int MIB_kern_cp_times[2];
|
static int MIB_kern_cp_times[2];
|
||||||
static int kernelFScale;
|
static int kernelFScale;
|
||||||
|
@ -130,25 +118,8 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui
|
||||||
|
|
||||||
len = 2; sysctlnametomib("vfs.bufspace", MIB_vfs_bufspace, &len);
|
len = 2; sysctlnametomib("vfs.bufspace", MIB_vfs_bufspace, &len);
|
||||||
|
|
||||||
len = sizeof(fpl->memZfsArc);
|
fpl->zfs.enabled = openzfs_sysctl_init();
|
||||||
if (sysctlbyname("kstat.zfs.misc.arcstats.size", &fpl->memZfsArc, &len,
|
openzfs_sysctl_updateArcStats(&fpl->zfs);
|
||||||
NULL, 0) == 0 && fpl->memZfsArc != 0) {
|
|
||||||
len = 5; sysctlnametomib("kstat.zfs.misc.arcstats.size", MIB_kstat_zfs_misc_arcstats_size, &len);
|
|
||||||
fpl->zfsArcEnabled = 1;
|
|
||||||
|
|
||||||
len = 3;
|
|
||||||
sysctlnametomib("vfs.zfs.arc_max", MIB_vfs_zfs_arc_max, &len);
|
|
||||||
|
|
||||||
len = 5;
|
|
||||||
sysctlnametomib("kstat.zfs.misc.arcstats.mfu_size", MIB_kstat_zfs_misc_arcstats_mfu_size, &len);
|
|
||||||
sysctlnametomib("kstat.zfs.misc.arcstats.mru_size", MIB_kstat_zfs_misc_arcstats_mru_size, &len);
|
|
||||||
sysctlnametomib("kstat.zfs.misc.arcstats.anon_size", MIB_kstat_zfs_misc_arcstats_anon_size, &len);
|
|
||||||
sysctlnametomib("kstat.zfs.misc.arcstats.hdr_size", MIB_kstat_zfs_misc_arcstats_hdr_size, &len);
|
|
||||||
sysctlnametomib("kstat.zfs.misc.arcstats.other_size", MIB_kstat_zfs_misc_arcstats_other_size, &len);
|
|
||||||
} else {
|
|
||||||
fpl->zfsArcEnabled = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int smp = 0;
|
int smp = 0;
|
||||||
len = sizeof(smp);
|
len = sizeof(smp);
|
||||||
|
@ -339,36 +310,9 @@ static inline void FreeBSDProcessList_scanMemoryInfo(ProcessList* pl) {
|
||||||
sysctl(MIB_vm_stats_vm_v_cache_count, 4, &(pl->cachedMem), &len, NULL, 0);
|
sysctl(MIB_vm_stats_vm_v_cache_count, 4, &(pl->cachedMem), &len, NULL, 0);
|
||||||
pl->cachedMem *= pageSizeKb;
|
pl->cachedMem *= pageSizeKb;
|
||||||
|
|
||||||
if (fpl->zfsArcEnabled) {
|
if (fpl->zfs.enabled) {
|
||||||
len = sizeof(fpl->memZfsArc);
|
fpl->memWire -= fpl->zfs.size;
|
||||||
sysctl(MIB_kstat_zfs_misc_arcstats_size, 5, &(fpl->memZfsArc), &len , NULL, 0);
|
pl->cachedMem += fpl->zfs.size;
|
||||||
fpl->memZfsArc /= 1024;
|
|
||||||
fpl->memWire -= fpl->memZfsArc;
|
|
||||||
pl->cachedMem += fpl->memZfsArc;
|
|
||||||
|
|
||||||
len = sizeof(fpl->zfsArcMax);
|
|
||||||
sysctl(MIB_vfs_zfs_arc_max, 3, &(fpl->zfsArcMax), &len , NULL, 0);
|
|
||||||
fpl->zfsArcMax /= 1024;
|
|
||||||
|
|
||||||
len = sizeof(fpl->zfsArcMFU);
|
|
||||||
sysctl(MIB_kstat_zfs_misc_arcstats_mfu_size, 5, &(fpl->zfsArcMFU), &len , NULL, 0);
|
|
||||||
fpl->zfsArcMFU /= 1024;
|
|
||||||
|
|
||||||
len = sizeof(fpl->zfsArcMRU);
|
|
||||||
sysctl(MIB_kstat_zfs_misc_arcstats_mru_size, 5, &(fpl->zfsArcMRU), &len , NULL, 0);
|
|
||||||
fpl->zfsArcMRU /= 1024;
|
|
||||||
|
|
||||||
len = sizeof(fpl->zfsArcAnon);
|
|
||||||
sysctl(MIB_kstat_zfs_misc_arcstats_anon_size, 5, &(fpl->zfsArcAnon), &len , NULL, 0);
|
|
||||||
fpl->zfsArcAnon /= 1024;
|
|
||||||
|
|
||||||
len = sizeof(fpl->zfsArcHeader);
|
|
||||||
sysctl(MIB_kstat_zfs_misc_arcstats_hdr_size, 5, &(fpl->zfsArcHeader), &len , NULL, 0);
|
|
||||||
fpl->zfsArcHeader /= 1024;
|
|
||||||
|
|
||||||
len = sizeof(fpl->zfsArcOther);
|
|
||||||
sysctl(MIB_kstat_zfs_misc_arcstats_other_size, 5, &(fpl->zfsArcOther), &len , NULL, 0);
|
|
||||||
fpl->zfsArcOther /= 1024;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pl->usedMem = fpl->memActive + fpl->memWire;
|
pl->usedMem = fpl->memActive + fpl->memWire;
|
||||||
|
@ -466,6 +410,7 @@ void ProcessList_goThroughEntries(ProcessList* this) {
|
||||||
bool hideKernelThreads = settings->hideKernelThreads;
|
bool hideKernelThreads = settings->hideKernelThreads;
|
||||||
bool hideUserlandThreads = settings->hideUserlandThreads;
|
bool hideUserlandThreads = settings->hideUserlandThreads;
|
||||||
|
|
||||||
|
openzfs_sysctl_updateArcStats(&fpl->zfs);
|
||||||
FreeBSDProcessList_scanMemoryInfo(this);
|
FreeBSDProcessList_scanMemoryInfo(this);
|
||||||
FreeBSDProcessList_scanCPUTime(this);
|
FreeBSDProcessList_scanCPUTime(this);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "zfs/ZfsArcStats.h"
|
||||||
|
|
||||||
#include <kvm.h>
|
#include <kvm.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/jail.h>
|
#include <sys/jail.h>
|
||||||
|
@ -34,20 +36,12 @@ typedef struct FreeBSDProcessList_ {
|
||||||
ProcessList super;
|
ProcessList super;
|
||||||
kvm_t* kd;
|
kvm_t* kd;
|
||||||
|
|
||||||
int zfsArcEnabled;
|
|
||||||
|
|
||||||
unsigned long long int memWire;
|
unsigned long long int memWire;
|
||||||
unsigned long long int memActive;
|
unsigned long long int memActive;
|
||||||
unsigned long long int memInactive;
|
unsigned long long int memInactive;
|
||||||
unsigned long long int memFree;
|
unsigned long long int memFree;
|
||||||
unsigned long long int memZfsArc;
|
|
||||||
|
|
||||||
unsigned long long int zfsArcMax;
|
ZfsArcStats zfs;
|
||||||
unsigned long long int zfsArcMFU;
|
|
||||||
unsigned long long int zfsArcMRU;
|
|
||||||
unsigned long long int zfsArcAnon;
|
|
||||||
unsigned long long int zfsArcHeader;
|
|
||||||
unsigned long long int zfsArcOther;
|
|
||||||
|
|
||||||
CPUData* cpus;
|
CPUData* cpus;
|
||||||
|
|
||||||
|
|
|
@ -202,18 +202,18 @@ void Platform_setSwapValues(Meter* this) {
|
||||||
void Platform_setZfsArcValues(Meter* this) {
|
void Platform_setZfsArcValues(Meter* this) {
|
||||||
FreeBSDProcessList* fpl = (FreeBSDProcessList*) this->pl;
|
FreeBSDProcessList* fpl = (FreeBSDProcessList*) this->pl;
|
||||||
|
|
||||||
this->total = fpl->zfsArcMax;
|
this->total = fpl->zfs.max;
|
||||||
this->values[0] = fpl->zfsArcMFU;
|
this->values[0] = fpl->zfs.MFU;
|
||||||
this->values[1] = fpl->zfsArcMRU;
|
this->values[1] = fpl->zfs.MRU;
|
||||||
this->values[2] = fpl->zfsArcAnon;
|
this->values[2] = fpl->zfs.anon;
|
||||||
this->values[3] = fpl->zfsArcHeader;
|
this->values[3] = fpl->zfs.header;
|
||||||
this->values[4] = fpl->zfsArcOther;
|
this->values[4] = fpl->zfs.other;
|
||||||
|
|
||||||
// "Hide" the last value so it can
|
// "Hide" the last value so it can
|
||||||
// only be accessed by index and is not
|
// only be accessed by index and is not
|
||||||
// displayed by the Bar or Graph style
|
// displayed by the Bar or Graph style
|
||||||
Meter_setItems(this, 5);
|
Meter_setItems(this, 5);
|
||||||
this->values[5] = fpl->memZfsArc;
|
this->values[5] = fpl->zfs.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform_setTasksValues(Meter* this) {
|
void Platform_setTasksValues(Meter* this) {
|
||||||
|
|
|
@ -46,6 +46,7 @@ in the source distribution for its full text.
|
||||||
/*{
|
/*{
|
||||||
|
|
||||||
#include "ProcessList.h"
|
#include "ProcessList.h"
|
||||||
|
#include "zfs/ZfsArcStats.h"
|
||||||
|
|
||||||
extern long long btime;
|
extern long long btime;
|
||||||
|
|
||||||
|
@ -95,14 +96,7 @@ typedef struct LinuxProcessList_ {
|
||||||
int netlink_family;
|
int netlink_family;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int zfsArcEnabled;
|
ZfsArcStats zfs;
|
||||||
unsigned long long int memZfsArc;
|
|
||||||
unsigned long long int zfsArcMax;
|
|
||||||
unsigned long long int zfsArcMFU;
|
|
||||||
unsigned long long int zfsArcMRU;
|
|
||||||
unsigned long long int zfsArcAnon;
|
|
||||||
unsigned long long int zfsArcHeader;
|
|
||||||
unsigned long long int zfsArcOther;
|
|
||||||
} LinuxProcessList;
|
} LinuxProcessList;
|
||||||
|
|
||||||
#ifndef PROCDIR
|
#ifndef PROCDIR
|
||||||
|
@ -984,7 +978,7 @@ static inline void LinuxProcessList_scanZfsArcstats(LinuxProcessList* lpl) {
|
||||||
|
|
||||||
FILE* file = fopen(PROCARCSTATSFILE, "r");
|
FILE* file = fopen(PROCARCSTATSFILE, "r");
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
lpl->zfsArcEnabled = 0;
|
lpl->zfs.enabled = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
|
@ -992,13 +986,13 @@ static inline void LinuxProcessList_scanZfsArcstats(LinuxProcessList* lpl) {
|
||||||
#define tryRead(label, variable) do { if (String_startsWith(buffer, label) && sscanf(buffer + strlen(label), " %*2u %32llu", variable)) { break; } } while(0)
|
#define tryRead(label, variable) do { if (String_startsWith(buffer, label) && sscanf(buffer + strlen(label), " %*2u %32llu", variable)) { break; } } while(0)
|
||||||
switch (buffer[0]) {
|
switch (buffer[0]) {
|
||||||
case 'c':
|
case 'c':
|
||||||
tryRead("c_max", &lpl->zfsArcMax);
|
tryRead("c_max", &lpl->zfs.max);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
tryRead("size", &lpl->memZfsArc);
|
tryRead("size", &lpl->zfs.size);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
tryRead("hdr_size", &lpl->zfsArcHeader);
|
tryRead("hdr_size", &lpl->zfs.header);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
tryRead("dbuf_size", &dbufSize);
|
tryRead("dbuf_size", &dbufSize);
|
||||||
|
@ -1008,25 +1002,25 @@ static inline void LinuxProcessList_scanZfsArcstats(LinuxProcessList* lpl) {
|
||||||
tryRead("bonus_size", &bonusSize);
|
tryRead("bonus_size", &bonusSize);
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
tryRead("anon_size", &lpl->zfsArcAnon);
|
tryRead("anon_size", &lpl->zfs.anon);
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
tryRead("mfu_size", &lpl->zfsArcMFU);
|
tryRead("mfu_size", &lpl->zfs.MFU);
|
||||||
tryRead("mru_size", &lpl->zfsArcMRU);
|
tryRead("mru_size", &lpl->zfs.MRU);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#undef tryRead
|
#undef tryRead
|
||||||
}
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
lpl->zfsArcEnabled = (lpl->memZfsArc > 0 ? 1 : 0);
|
lpl->zfs.enabled = (lpl->zfs.size > 0 ? 1 : 0);
|
||||||
lpl->memZfsArc /= 1024;
|
lpl->zfs.size /= 1024;
|
||||||
lpl->zfsArcMax /= 1024;
|
lpl->zfs.max /= 1024;
|
||||||
lpl->zfsArcMFU /= 1024;
|
lpl->zfs.MFU /= 1024;
|
||||||
lpl->zfsArcMRU /= 1024;
|
lpl->zfs.MRU /= 1024;
|
||||||
lpl->zfsArcAnon /= 1024;
|
lpl->zfs.anon /= 1024;
|
||||||
lpl->zfsArcHeader /= 1024;
|
lpl->zfs.header /= 1024;
|
||||||
lpl->zfsArcOther = (dbufSize + dnodeSize + bonusSize) / 1024;
|
lpl->zfs.other = (dbufSize + dnodeSize + bonusSize) / 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double LinuxProcessList_scanCPUTime(LinuxProcessList* this) {
|
static inline double LinuxProcessList_scanCPUTime(LinuxProcessList* this) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ in the source distribution for its full text.
|
||||||
|
|
||||||
|
|
||||||
#include "ProcessList.h"
|
#include "ProcessList.h"
|
||||||
|
#include "zfs/ZfsArcStats.h"
|
||||||
|
|
||||||
extern long long btime;
|
extern long long btime;
|
||||||
|
|
||||||
|
@ -68,14 +69,7 @@ typedef struct LinuxProcessList_ {
|
||||||
int netlink_family;
|
int netlink_family;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int zfsArcEnabled;
|
ZfsArcStats zfs;
|
||||||
unsigned long long int memZfsArc;
|
|
||||||
unsigned long long int zfsArcMax;
|
|
||||||
unsigned long long int zfsArcMFU;
|
|
||||||
unsigned long long int zfsArcMRU;
|
|
||||||
unsigned long long int zfsArcAnon;
|
|
||||||
unsigned long long int zfsArcHeader;
|
|
||||||
unsigned long long int zfsArcOther;
|
|
||||||
} LinuxProcessList;
|
} LinuxProcessList;
|
||||||
|
|
||||||
#ifndef PROCDIR
|
#ifndef PROCDIR
|
||||||
|
|
|
@ -218,18 +218,18 @@ void Platform_setSwapValues(Meter* this) {
|
||||||
void Platform_setZfsArcValues(Meter* this) {
|
void Platform_setZfsArcValues(Meter* this) {
|
||||||
LinuxProcessList* lpl = (LinuxProcessList*) this->pl;
|
LinuxProcessList* lpl = (LinuxProcessList*) this->pl;
|
||||||
|
|
||||||
this->total = lpl->zfsArcMax;
|
this->total = lpl->zfs.max;
|
||||||
this->values[0] = lpl->zfsArcMFU;
|
this->values[0] = lpl->zfs.MFU;
|
||||||
this->values[1] = lpl->zfsArcMRU;
|
this->values[1] = lpl->zfs.MRU;
|
||||||
this->values[2] = lpl->zfsArcAnon;
|
this->values[2] = lpl->zfs.anon;
|
||||||
this->values[3] = lpl->zfsArcHeader;
|
this->values[3] = lpl->zfs.header;
|
||||||
this->values[4] = lpl->zfsArcOther;
|
this->values[4] = lpl->zfs.other;
|
||||||
|
|
||||||
// "Hide" the last value so it can
|
// "Hide" the last value so it can
|
||||||
// only be accessed by index and is not
|
// only be accessed by index and is not
|
||||||
// displayed by the Bar or Graph style
|
// displayed by the Bar or Graph style
|
||||||
Meter_setItems(this, 5);
|
Meter_setItems(this, 5);
|
||||||
this->values[5] = lpl->memZfsArc;
|
this->values[5] = lpl->zfs.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* Platform_getProcessEnv(pid_t pid) {
|
char* Platform_getProcessEnv(pid_t pid) {
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
htop - ZfsArcStats.c
|
||||||
|
(C) 2014 Hisham H. Muhammad
|
||||||
|
Released under the GNU GPL, see the COPYING file
|
||||||
|
in the source distribution for its full text.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*{
|
||||||
|
typedef struct ZfsArcStats_ {
|
||||||
|
int enabled;
|
||||||
|
unsigned long long int max;
|
||||||
|
unsigned long long int size;
|
||||||
|
unsigned long long int MFU;
|
||||||
|
unsigned long long int MRU;
|
||||||
|
unsigned long long int anon;
|
||||||
|
unsigned long long int header;
|
||||||
|
unsigned long long int other;
|
||||||
|
} ZfsArcStats;
|
||||||
|
}*/
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* Do not edit this file. It was automatically generated. */
|
||||||
|
|
||||||
|
#ifndef HEADER_ZfsArcStats
|
||||||
|
#define HEADER_ZfsArcStats
|
||||||
|
/*
|
||||||
|
htop - ZfsArcStats.h
|
||||||
|
(C) 2014 Hisham H. Muhammad
|
||||||
|
Released under the GNU GPL, see the COPYING file
|
||||||
|
in the source distribution for its full text.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct ZfsArcStats_ {
|
||||||
|
int enabled;
|
||||||
|
unsigned long long int max;
|
||||||
|
unsigned long long int size;
|
||||||
|
unsigned long long int MFU;
|
||||||
|
unsigned long long int MRU;
|
||||||
|
unsigned long long int anon;
|
||||||
|
unsigned long long int header;
|
||||||
|
unsigned long long int other;
|
||||||
|
} ZfsArcStats;
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,81 @@
|
||||||
|
/*
|
||||||
|
htop - zfs/openzfs_sysctl.c
|
||||||
|
(C) 2014 Hisham H. Muhammad
|
||||||
|
Released under the GNU GPL, see the COPYING file
|
||||||
|
in the source distribution for its full text.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "zfs/openzfs_sysctl.h"
|
||||||
|
#include "zfs/ZfsArcStats.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
|
static int MIB_kstat_zfs_misc_arcstats_size[5];
|
||||||
|
static int MIB_kstat_zfs_misc_arcstats_c_max[5];
|
||||||
|
static int MIB_kstat_zfs_misc_arcstats_mfu_size[5];
|
||||||
|
static int MIB_kstat_zfs_misc_arcstats_mru_size[5];
|
||||||
|
static int MIB_kstat_zfs_misc_arcstats_anon_size[5];
|
||||||
|
static int MIB_kstat_zfs_misc_arcstats_hdr_size[5];
|
||||||
|
static int MIB_kstat_zfs_misc_arcstats_other_size[5];
|
||||||
|
|
||||||
|
/*{
|
||||||
|
#include "zfs/ZfsArcStats.h"
|
||||||
|
}*/
|
||||||
|
|
||||||
|
int openzfs_sysctl_init() {
|
||||||
|
size_t len;
|
||||||
|
unsigned long long int arcSize;
|
||||||
|
|
||||||
|
len = sizeof(arcSize);
|
||||||
|
if (sysctlbyname("kstat.zfs.misc.arcstats.size", &arcSize, &len,
|
||||||
|
NULL, 0) == 0 && arcSize != 0) {
|
||||||
|
len = 5; sysctlnametomib("kstat.zfs.misc.arcstats.size", MIB_kstat_zfs_misc_arcstats_size, &len);
|
||||||
|
|
||||||
|
sysctlnametomib("kstat.zfs.misc.arcstats.c_max", MIB_kstat_zfs_misc_arcstats_c_max, &len);
|
||||||
|
sysctlnametomib("kstat.zfs.misc.arcstats.mfu_size", MIB_kstat_zfs_misc_arcstats_mfu_size, &len);
|
||||||
|
sysctlnametomib("kstat.zfs.misc.arcstats.mru_size", MIB_kstat_zfs_misc_arcstats_mru_size, &len);
|
||||||
|
sysctlnametomib("kstat.zfs.misc.arcstats.anon_size", MIB_kstat_zfs_misc_arcstats_anon_size, &len);
|
||||||
|
sysctlnametomib("kstat.zfs.misc.arcstats.hdr_size", MIB_kstat_zfs_misc_arcstats_hdr_size, &len);
|
||||||
|
sysctlnametomib("kstat.zfs.misc.arcstats.other_size", MIB_kstat_zfs_misc_arcstats_other_size, &len);
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void openzfs_sysctl_updateArcStats(ZfsArcStats *stats) {
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if (stats->enabled) {
|
||||||
|
len = sizeof(stats->size);
|
||||||
|
sysctl(MIB_kstat_zfs_misc_arcstats_size, 5, &(stats->size), &len , NULL, 0);
|
||||||
|
stats->size /= 1024;
|
||||||
|
|
||||||
|
len = sizeof(stats->max);
|
||||||
|
sysctl(MIB_kstat_zfs_misc_arcstats_c_max, 5, &(stats->max), &len , NULL, 0);
|
||||||
|
stats->max /= 1024;
|
||||||
|
|
||||||
|
len = sizeof(stats->MFU);
|
||||||
|
sysctl(MIB_kstat_zfs_misc_arcstats_mfu_size, 5, &(stats->MFU), &len , NULL, 0);
|
||||||
|
stats->MFU /= 1024;
|
||||||
|
|
||||||
|
len = sizeof(stats->MRU);
|
||||||
|
sysctl(MIB_kstat_zfs_misc_arcstats_mru_size, 5, &(stats->MRU), &len , NULL, 0);
|
||||||
|
stats->MRU /= 1024;
|
||||||
|
|
||||||
|
len = sizeof(stats->anon);
|
||||||
|
sysctl(MIB_kstat_zfs_misc_arcstats_anon_size, 5, &(stats->anon), &len , NULL, 0);
|
||||||
|
stats->anon /= 1024;
|
||||||
|
|
||||||
|
len = sizeof(stats->header);
|
||||||
|
sysctl(MIB_kstat_zfs_misc_arcstats_hdr_size, 5, &(stats->header), &len , NULL, 0);
|
||||||
|
stats->header /= 1024;
|
||||||
|
|
||||||
|
len = sizeof(stats->other);
|
||||||
|
sysctl(MIB_kstat_zfs_misc_arcstats_other_size, 5, &(stats->other), &len , NULL, 0);
|
||||||
|
stats->other /= 1024;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
/* Do not edit this file. It was automatically generated. */
|
||||||
|
|
||||||
|
#ifndef HEADER_openzfs
|
||||||
|
#define HEADER_openzfs
|
||||||
|
/*
|
||||||
|
htop - zfs/openzfs_sysctl.h
|
||||||
|
(C) 2014 Hisham H. Muhammad
|
||||||
|
Released under the GNU GPL, see the COPYING file
|
||||||
|
in the source distribution for its full text.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "zfs/ZfsArcStats.h"
|
||||||
|
|
||||||
|
int openzfs_sysctl_init();
|
||||||
|
|
||||||
|
void openzfs_sysctl_updateArcStats(ZfsArcStats *stats);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue