Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F111612732
D9829.id25775.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
7 KB
Referenced Files
None
Subscribers
None
D9829.id25775.diff
View Options
Index: contrib/top/display.h
===================================================================
--- contrib/top/display.h
+++ contrib/top/display.h
@@ -16,6 +16,7 @@
void display_header(int t);
int display_init(struct statics *statics);
void i_arc(int *stats);
+void i_carc(int *stats);
void i_cpustates(int *states);
void i_loadave(int mpid, double *avenrun);
void i_memory(int *stats);
@@ -29,6 +30,7 @@
int readline(char *buffer, int size, int numeric);
char *trim_header(char *text);
void u_arc(int *stats);
+void u_carc(int *stats);
void u_cpustates(int *states);
void u_endscreen(int hi);
void u_header(char *text);
Index: contrib/top/display.c
===================================================================
--- contrib/top/display.c
+++ contrib/top/display.c
@@ -69,6 +69,7 @@
static char **cpustate_names;
static char **memory_names;
static char **arc_names;
+static char **carc_names;
static char **swap_names;
static int num_procstates;
@@ -105,6 +106,8 @@
int y_mem = 3;
int x_arc = 5;
int y_arc = 4;
+int x_carc = 16;
+int y_carc = 5;
int x_swap = 6;
int y_swap = 4;
int y_message = 5;
@@ -222,6 +225,7 @@
lmemory = (int *)malloc(num_memory * sizeof(int));
arc_names = statics->arc_names;
+ carc_names = statics->carc_names;
/* calculate starting columns where needed */
cpustate_total_length = 0;
@@ -684,6 +688,47 @@
line_update(arc_buffer, new, x_arc, y_arc);
}
+
+/*
+ * *_carc(stats) - print "Compressed ARC: " followed by the summary string
+ *
+ * Assumptions: cursor is on "lastline"
+ * for i_carc ONLY: cursor is on the previous line
+ */
+char carc_buffer[MAX_COLS];
+
+void
+i_carc(stats)
+
+int *stats;
+
+{
+ if (carc_names == NULL)
+ return;
+
+ fputs("\nCompressed ARC: ", stdout);
+ lastline++;
+
+ /* format and print the memory summary */
+ summary_format(carc_buffer, stats, carc_names);
+ fputs(carc_buffer, stdout);
+}
+
+void
+u_carc(stats)
+
+int *stats;
+
+{
+ static char new[MAX_COLS];
+
+ if (carc_names == NULL)
+ return;
+
+ /* format the new line */
+ summary_format(new, stats, carc_names);
+ line_update(carc_buffer, new, x_carc, y_carc);
+}
/*
* *_swap(stats) - print "Swap: " followed by the swap summary string
@@ -1174,6 +1219,7 @@
register int num;
register char *thisname;
register int useM = No;
+ char rbuf[6];
/* format each number followed by its string */
p = str;
@@ -1194,6 +1240,14 @@
/* skip over the K, since it was included by format_k */
p = strecpy(p, thisname+1);
}
+ /* is this number a ratio? */
+ else if (thisname[0] == ':')
+ {
+ (void) snprintf(rbuf, sizeof(rbuf), "%.2f",
+ (float)*(numbers - 2) / (float)num);
+ p = strecpy(p, rbuf);
+ p = strecpy(p, thisname);
+ }
else
{
p = strecpy(p, itoa(num));
Index: contrib/top/layout.h
===================================================================
--- contrib/top/layout.h
+++ contrib/top/layout.h
@@ -21,6 +21,8 @@
extern int y_mem; /* 3 */
extern int x_arc; /* 5 */
extern int y_arc; /* 4 */
+extern int x_carc; /* 16 */
+extern int y_carc; /* 5 */
extern int x_swap; /* 6 */
extern int y_swap; /* 4 */
extern int y_message; /* 5 */
Index: contrib/top/machine.h
===================================================================
--- contrib/top/machine.h
+++ contrib/top/machine.h
@@ -21,6 +21,7 @@
char **cpustate_names;
char **memory_names;
char **arc_names;
+ char **carc_names;
char **swap_names;
#ifdef ORDER
char **order_names;
@@ -48,6 +49,7 @@
int *cpustates;
int *memory;
int *arc;
+ int *carc;
int *swap;
struct timeval boottime;
int ncpus;
Index: contrib/top/top.c
===================================================================
--- contrib/top/top.c
+++ contrib/top/top.c
@@ -125,6 +125,7 @@
void (*d_cpustates)() = i_cpustates;
void (*d_memory)() = i_memory;
void (*d_arc)() = i_arc;
+void (*d_carc)() = i_carc;
void (*d_swap)() = i_swap;
void (*d_message)() = i_message;
void (*d_header)() = i_header;
@@ -658,6 +659,7 @@
/* display memory stats */
(*d_memory)(system_info.memory);
(*d_arc)(system_info.arc);
+ (*d_carc)(system_info.carc);
/* display swap stats */
(*d_swap)(system_info.swap);
@@ -724,6 +726,7 @@
d_cpustates = u_cpustates;
d_memory = u_memory;
d_arc = u_arc;
+ d_carc = u_carc;
d_swap = u_swap;
d_message = u_message;
d_header = u_header;
@@ -1190,6 +1193,7 @@
d_cpustates = i_cpustates;
d_memory = i_memory;
d_arc = i_arc;
+ d_carc = i_carc;
d_swap = i_swap;
d_message = i_message;
d_header = i_header;
Index: usr.bin/top/machine.c
===================================================================
--- usr.bin/top/machine.c
+++ usr.bin/top/machine.c
@@ -188,6 +188,12 @@
NULL
};
+int carc_stats[5];
+char *carcnames[] = {
+ "K Compressed, ", "K Uncompressed, ", ":1 Ratio, ", "K Overhead",
+ NULL
+};
+
int swap_stats[7];
char *swapnames[] = {
"K Total, ", "K Used, ", "K Free, ", "% Inuse, ", "K In, ", "K Out",
@@ -223,6 +229,7 @@
/* these are for getting the memory statistics */
static int arc_enabled;
+static int carc_enabled;
static int pageshift; /* log base 2 of the pagesize */
/* define pagetok in terms of pageshift */
@@ -283,16 +290,18 @@
y_mem = 3;
y_arc = 4;
- y_swap = 4 + arc_enabled;
- y_idlecursor = 5 + arc_enabled;
- y_message = 5 + arc_enabled;
- y_header = 6 + arc_enabled;
- y_procs = 7 + arc_enabled;
- Header_lines = 7 + arc_enabled;
+ y_carc = 5;
+ y_swap = 4 + arc_enabled + carc_enabled;
+ y_idlecursor = 5 + arc_enabled + carc_enabled;
+ y_message = 5 + arc_enabled + carc_enabled;
+ y_header = 6 + arc_enabled + carc_enabled;
+ y_procs = 7 + arc_enabled + carc_enabled;
+ Header_lines = 7 + arc_enabled + carc_enabled;
if (pcpu_stats) {
y_mem += ncpus - 1;
y_arc += ncpus - 1;
+ y_carc += ncpus - 1;
y_swap += ncpus - 1;
y_idlecursor += ncpus - 1;
y_message += ncpus - 1;
@@ -319,6 +328,10 @@
smpmode = 0;
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,
NULL, 0) == 0 && arc_size != 0)
arc_enabled = 1;
@@ -368,6 +381,10 @@
statics->arc_names = arcnames;
else
statics->arc_names = NULL;
+ if (carc_enabled)
+ statics->carc_names = carcnames;
+ else
+ statics->carc_names = NULL;
statics->swap_names = swapnames;
#ifdef ORDER
statics->order_names = ordernames;
@@ -559,6 +576,16 @@
arc_stats[5] = arc_stat >> 10;
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 */
if (pcpu_stats) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 7, 12:30 AM (15 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17022301
Default Alt Text
D9829.id25775.diff (7 KB)
Attached To
Mode
D9829: Add a summary line of the ZFS Compressed ARC to top(1)
Attached
Detach File
Event Timeline
Log In to Comment