Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/top/machine.c
Show First 20 Lines • Show All 182 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
int arc_stats[7]; | int arc_stats[7]; | ||||
char *arcnames[] = { | char *arcnames[] = { | ||||
"K Total, ", "K MFU, ", "K MRU, ", "K Anon, ", "K Header, ", "K Other", | "K Total, ", "K MFU, ", "K MRU, ", "K Anon, ", "K Header, ", "K Other", | ||||
NULL | NULL | ||||
}; | }; | ||||
int carc_stats[5]; | |||||
char *carcnames[] = { | |||||
"K Compressed, ", "K Uncompressed, ", ":1 Ratio, ", "K Overhead", | |||||
NULL | |||||
}; | |||||
int swap_stats[7]; | int swap_stats[7]; | ||||
char *swapnames[] = { | char *swapnames[] = { | ||||
"K Total, ", "K Used, ", "K Free, ", "% Inuse, ", "K In, ", "K Out", | "K Total, ", "K Used, ", "K Free, ", "% Inuse, ", "K In, ", "K Out", | ||||
NULL | NULL | ||||
}; | }; | ||||
/* these are for keeping track of the proc array */ | /* these are for keeping track of the proc array */ | ||||
Show All 19 Lines | |||||
/* total number of io operations */ | /* total number of io operations */ | ||||
static long total_inblock; | static long total_inblock; | ||||
static long total_oublock; | static long total_oublock; | ||||
static long total_majflt; | static long total_majflt; | ||||
/* these are for getting the memory statistics */ | /* these are for getting the memory statistics */ | ||||
static int arc_enabled; | static int arc_enabled; | ||||
static int carc_enabled; | |||||
static int pageshift; /* log base 2 of the pagesize */ | static int pageshift; /* log base 2 of the pagesize */ | ||||
/* define pagetok in terms of pageshift */ | /* define pagetok in terms of pageshift */ | ||||
#define pagetok(size) ((size) << pageshift) | #define pagetok(size) ((size) << pageshift) | ||||
/* swap usage */ | /* swap usage */ | ||||
#define ki_swap(kip) \ | #define ki_swap(kip) \ | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
/* Adjust display based on ncpus and the ARC state. */ | /* Adjust display based on ncpus and the ARC state. */ | ||||
static void | static void | ||||
update_layout(void) | update_layout(void) | ||||
{ | { | ||||
y_mem = 3; | y_mem = 3; | ||||
y_arc = 4; | y_arc = 4; | ||||
y_swap = 4 + arc_enabled; | y_carc = 5; | ||||
y_idlecursor = 5 + arc_enabled; | y_swap = 4 + arc_enabled + carc_enabled; | ||||
y_message = 5 + arc_enabled; | y_idlecursor = 5 + arc_enabled + carc_enabled; | ||||
y_header = 6 + arc_enabled; | y_message = 5 + arc_enabled + carc_enabled; | ||||
y_procs = 7 + arc_enabled; | y_header = 6 + arc_enabled + carc_enabled; | ||||
Header_lines = 7 + arc_enabled; | y_procs = 7 + arc_enabled + carc_enabled; | ||||
Header_lines = 7 + arc_enabled + carc_enabled; | |||||
if (pcpu_stats) { | if (pcpu_stats) { | ||||
y_mem += ncpus - 1; | y_mem += ncpus - 1; | ||||
y_arc += ncpus - 1; | y_arc += ncpus - 1; | ||||
y_carc += ncpus - 1; | |||||
y_swap += ncpus - 1; | y_swap += ncpus - 1; | ||||
y_idlecursor += ncpus - 1; | y_idlecursor += ncpus - 1; | ||||
y_message += ncpus - 1; | y_message += ncpus - 1; | ||||
y_header += ncpus - 1; | y_header += ncpus - 1; | ||||
y_procs += ncpus - 1; | y_procs += ncpus - 1; | ||||
Header_lines += ncpus - 1; | Header_lines += ncpus - 1; | ||||
} | } | ||||
} | } | ||||
Show All 10 Lines | machine_init(struct statics *statics, char do_unames) | ||||
if ((sysctlbyname("machdep.smp_active", &smpmode, &size, | if ((sysctlbyname("machdep.smp_active", &smpmode, &size, | ||||
NULL, 0) != 0 && | NULL, 0) != 0 && | ||||
sysctlbyname("kern.smp.active", &smpmode, &size, | sysctlbyname("kern.smp.active", &smpmode, &size, | ||||
NULL, 0) != 0) || | NULL, 0) != 0) || | ||||
size != sizeof(smpmode)) | size != sizeof(smpmode)) | ||||
smpmode = 0; | smpmode = 0; | ||||
size = sizeof(arc_size); | size = sizeof(arc_size); | ||||
if (sysctlbyname("vfs.zfs.compressed_arc_enabled", &arc_size, &size, | |||||
NULL, 0) == 0 && arc_size == 1) | |||||
carc_enabled = 1; | |||||
size = sizeof(arc_size); | |||||
if (sysctlbyname("kstat.zfs.misc.arcstats.size", &arc_size, &size, | if (sysctlbyname("kstat.zfs.misc.arcstats.size", &arc_size, &size, | ||||
NULL, 0) == 0 && arc_size != 0) | NULL, 0) == 0 && arc_size != 0) | ||||
arc_enabled = 1; | arc_enabled = 1; | ||||
if (do_unames) { | if (do_unames) { | ||||
while ((pw = getpwent()) != NULL) { | while ((pw = getpwent()) != NULL) { | ||||
if (strlen(pw->pw_name) > namelength) | if (strlen(pw->pw_name) > namelength) | ||||
namelength = strlen(pw->pw_name); | namelength = strlen(pw->pw_name); | ||||
Show All 33 Lines | machine_init(struct statics *statics, char do_unames) | ||||
/* fill in the statics information */ | /* fill in the statics information */ | ||||
statics->procstate_names = procstatenames; | statics->procstate_names = procstatenames; | ||||
statics->cpustate_names = cpustatenames; | statics->cpustate_names = cpustatenames; | ||||
statics->memory_names = memorynames; | statics->memory_names = memorynames; | ||||
if (arc_enabled) | if (arc_enabled) | ||||
statics->arc_names = arcnames; | statics->arc_names = arcnames; | ||||
else | else | ||||
statics->arc_names = NULL; | statics->arc_names = NULL; | ||||
if (carc_enabled) | |||||
statics->carc_names = carcnames; | |||||
else | |||||
statics->carc_names = NULL; | |||||
statics->swap_names = swapnames; | statics->swap_names = swapnames; | ||||
#ifdef ORDER | #ifdef ORDER | ||||
statics->order_names = ordernames; | statics->order_names = ordernames; | ||||
#endif | #endif | ||||
/* Allocate state for per-CPU stats. */ | /* Allocate state for per-CPU stats. */ | ||||
cpumask = 0; | cpumask = 0; | ||||
ncpus = 0; | ncpus = 0; | ||||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | if (arc_enabled) { | ||||
GETSYSCTL("vfs.zfs.anon_size", arc_stat); | GETSYSCTL("vfs.zfs.anon_size", arc_stat); | ||||
arc_stats[3] = arc_stat >> 10; | arc_stats[3] = arc_stat >> 10; | ||||
GETSYSCTL("kstat.zfs.misc.arcstats.hdr_size", arc_stat); | GETSYSCTL("kstat.zfs.misc.arcstats.hdr_size", arc_stat); | ||||
GETSYSCTL("kstat.zfs.misc.arcstats.l2_hdr_size", arc_stat2); | GETSYSCTL("kstat.zfs.misc.arcstats.l2_hdr_size", arc_stat2); | ||||
arc_stats[4] = arc_stat + arc_stat2 >> 10; | arc_stats[4] = arc_stat + arc_stat2 >> 10; | ||||
GETSYSCTL("kstat.zfs.misc.arcstats.other_size", arc_stat); | GETSYSCTL("kstat.zfs.misc.arcstats.other_size", arc_stat); | ||||
arc_stats[5] = arc_stat >> 10; | arc_stats[5] = arc_stat >> 10; | ||||
si->arc = arc_stats; | si->arc = arc_stats; | ||||
} | |||||
if (carc_enabled) { | |||||
GETSYSCTL("kstat.zfs.misc.arcstats.compressed_size", arc_stat); | |||||
carc_stats[0] = arc_stat >> 10; | |||||
GETSYSCTL("kstat.zfs.misc.arcstats.uncompressed_size", arc_stat); | |||||
carc_stats[1] = arc_stat >> 10; | |||||
carc_stats[2] = arc_stats[0]; /* ARC Total */ | |||||
GETSYSCTL("kstat.zfs.misc.arcstats.overhead_size", arc_stat); | |||||
carc_stats[3] = arc_stat >> 10; | |||||
si->carc = carc_stats; | |||||
} | } | ||||
/* set arrays and strings */ | /* set arrays and strings */ | ||||
if (pcpu_stats) { | if (pcpu_stats) { | ||||
si->cpustates = pcpu_cpu_states; | si->cpustates = pcpu_cpu_states; | ||||
si->ncpus = ncpus; | si->ncpus = ncpus; | ||||
} else { | } else { | ||||
si->cpustates = cpu_states; | si->cpustates = cpu_states; | ||||
▲ Show 20 Lines • Show All 1,084 Lines • Show Last 20 Lines |