1 $OpenIndiana: Feature https://www.illumos.org/issues/7305 - Franklin Ronald <franklin@wiselabs.com.br>$
2 --- top-3.8beta1/machine/m_sunos5.c.1 2016-09-09 15:23:31.208161429 -0300
3 +++ top-3.8beta1/machine/m_sunos5.c 2016-09-08 22:30:10.912171581 -0300
5 #define MEMORY_TOTALSWAP 2
6 #define MEMORY_FREESWAP 3
8 +/* these are for detailing the ZFS ARC statistics */
10 +{"K Total, ", "K MRU, ", "K MFU, ", "K Anon, ", "K Header, ", "K Other", NULL};
12 /* these are for detailing kernel statistics */
18 static kstat_t *ks_system_misc = NULL;
19 +static kstat_t *ks_arcstats = NULL;
21 #endif /* USE_KSTAT */
27 +get_arcstats(long arcstats[NUM_ZFS_ARC])
32 + memset(arcstats, 0, sizeof(long) * NUM_ZFS_ARC);
34 + dprintf("get_arcstats(%08x)\n", arcstats);
36 + if ((status = kstat_safe_retrieve(&ks_arcstats,
37 + "zfs", 0, "arcstats", NULL)) == 0)
39 + if ((kn = kstat_data_lookup(ks_arcstats, "size")) != NULL)
41 + if(kn->value.ui64 > 0){
42 + arcstats[0] = (long) kn->value.ui64 / 1024;
45 + if ((kn = kstat_data_lookup(ks_arcstats, "mru_size")) != NULL)
47 + if(kn->value.ui64 > 0){
48 + arcstats[1] = (long) kn->value.ui64 / 1024;
51 + if ((kn = kstat_data_lookup(ks_arcstats, "mfu_size")) != NULL)
53 + if(kn->value.ui64 > 0){
54 + arcstats[2] = (long) kn->value.ui64 / 1024;
57 + if ((kn = kstat_data_lookup(ks_arcstats, "anon_size")) != NULL)
59 + if(kn->value.ui64 > 0){
60 + arcstats[3] = (long) kn->value.ui64 / 1024;
63 + if ((kn = kstat_data_lookup(ks_arcstats, "hdr_size")) != NULL)
65 + if(kn->value.ui64 > 0){
66 + arcstats[4] = (long) kn->value.ui64 / 1024;
69 + if ((kn = kstat_data_lookup(ks_arcstats, "other_size")) != NULL)
71 + if(kn->value.ui64 > 0){
72 + arcstats[5] = (long) kn->value.ui64 / 1024;
76 + dprintf("get_arcstats returns %d\n", status);
79 +#else /* !USE_KSTAT */
83 +#endif /* USE_KSTAT */
90 @@ -1236,12 +1301,13 @@
91 statics->procstate_names = procstatenames;
92 statics->cpustate_names = cpustatenames;
93 statics->memory_names = memorynames;
94 + statics->arc_names = arcnames;
95 statics->kernel_names = kernelnames;
96 statics->order_names = ordernames;
97 statics->flags.fullcmds = 1;
98 statics->flags.warmup = 1;
99 statics->flags.threads = 1;
103 ut.ut_type = BOOT_TIME;
104 if ((up = getutxid(&ut)) != NULL)
105 @@ -1398,6 +1464,7 @@
106 get_system_info (struct system_info *si)
109 + long arcstats[NUM_ZFS_ARC];
111 static long cp_time[CPUSTATES];
112 static long cp_old[CPUSTATES];
113 @@ -1414,6 +1481,10 @@
115 /* get important information */
116 get_avenrun(avenrun);
118 + /* get ARC information */
119 + get_arcstats(arcstats);
120 + memcpy(si->arc, arcstats, sizeof(arcstats));
122 /* get the cpu statistics arrays */
123 cpustats = get_cpustats(&cpus, cpustats);
124 --- top-3.8beta1/display.c.1 2008-05-07 00:41:39.000000000 -0300
125 +++ top-3.8beta1/display.c 2016-09-09 13:50:10.209517852 -0300
127 static int y_kernel = Y_KERNEL;
128 static int x_mem = X_MEM;
129 static int y_mem = Y_MEM;
130 +static int x_arc = X_ARC;
131 +static int y_arc = Y_ARC;
132 static int x_swap = X_SWAP;
133 static int y_swap = Y_SWAP;
134 static int y_message = Y_MESSAGE;
135 @@ -132,12 +134,14 @@
136 static char **procstate_names;
137 static char **cpustate_names;
138 static char **memory_names;
139 +static char **arc_names;
140 static char **swap_names;
141 static char **kernel_names;
143 static int num_procstates;
144 static int num_cpustates;
145 static int num_memory;
148 static int num_kernel;
150 @@ -171,10 +175,12 @@
151 static int header_cidx;
152 static int *cpustate_cidx;
153 static int *memory_cidx;
154 +static int *arc_cidx;
155 static int *swap_cidx;
156 static int *kernel_cidx;
158 #define memory_cidx NULL
159 +#define arc_cidx NULL
160 #define swap_cidx NULL
161 #define kernel_cidx NULL
163 @@ -526,10 +532,10 @@
167 -summary_format(int x, int y, int *numbers, char **names, int *cidx)
168 +summary_format(int x, int y, long *numbers, char **names, int *cidx)
173 register char *thisname;
174 register char *lastname = NULL;
176 @@ -762,18 +768,29 @@
177 kernel_names = statics->kernel_names;
178 if ((num_kernel = string_count(kernel_names)) > 0)
180 + /* adjust screen placements */
189 + /* a swap line shifts parts of the display down one */
190 + swap_names = statics->swap_names;
191 + if ((num_swap = string_count(swap_names)) > 0)
193 /* adjust screen placements */
202 - /* a swap line shifts parts of the display down one */
203 - swap_names = statics->swap_names;
204 - if ((num_swap = string_count(swap_names)) > 0)
207 + arc_names = statics->arc_names;
208 + if ((num_arc = string_count(arc_names)) > 0)
210 /* adjust screen placements */
213 cpustate_columns = (int *)calloc(num_cpustates, sizeof(int));
214 memory_names = statics->memory_names;
215 num_memory = string_count(memory_names);
217 + arc_names = statics->arc_names;
219 /* calculate starting columns where needed */
220 cpustate_total_length = 0;
222 memory_cidx[i++] = color_tag(scratchbuf);
225 + /* color tags for memory */
226 + arc_cidx = (int *)malloc(num_arc * sizeof(int));
228 + p = strcpyend(scratchbuf, "arc.");
229 + while (i < num_arc)
231 + strcpy(p, homogenize(arc_names[i]+1));
232 + arc_cidx[i++] = color_tag(scratchbuf);
235 /* color tags for swap */
238 @@ -1316,6 +1345,28 @@
242 + * *_arc(stats) - print "ARC: " followed by the ARC summary string
248 + /* print the tag */
249 + display_write(0, y_arc, 0, 0, "ARC: ");
251 + /* format and print the swap summary */
252 + summary_format_memory(x_arc, y_arc, stats, arc_names, arc_cidx);
259 + /* format and print the swap summary */
260 + summary_format_memory(x_arc, y_arc, stats, arc_names, arc_cidx);
264 * *_swap(stats) - print "Swap: " followed by the swap summary string
266 * Assumptions: cursor is on "lastline", the previous line
267 @@ -1333,7 +1384,7 @@
268 display_write(0, y_swap, 0, 0, "Swap: ");
270 /* format and print the swap summary */
271 - summary_format_memory(x_swap, y_swap, stats, swap_names, swap_cidx);
272 + summary_format(x_swap, y_swap, stats, swap_names, swap_cidx);
276 --- top-3.8beta1/display.h.1 2008-05-07 00:41:39.000000000 -0300
277 +++ top-3.8beta1/display.h 2016-09-06 21:31:36.000000000 -0300
279 void u_kernel(int *stats);
280 void i_memory(long *stats);
281 void u_memory(long *stats);
282 +void i_arc(long *stats);
283 +void u_arc(long *stats);
284 void i_swap(long *stats);
285 void u_swap(long *stats);
286 void i_message(struct timeval *now);
287 --- top-3.8beta1/layout.h.1 2008-05-07 00:41:39.000000000 -0300
288 +++ top-3.8beta1/layout.h 2016-09-06 21:01:18.000000000 -0300
298 --- top-3.8beta1/machine.h.1 2008-05-07 00:41:39.000000000 -0300
299 +++ top-3.8beta1/machine.h 2016-09-06 22:28:37.000000000 -0300
301 char **procstate_names;
302 char **cpustate_names;
305 char **swap_names; /* optional */
306 char **order_names; /* optional */
307 char **top_color_names; /* optional */
312 + long arc[NUM_ZFS_ARC];
316 --- top-3.8beta1/top.c.1 2008-05-07 00:41:39.000000000 -0300
317 +++ top-3.8beta1/top.c 2016-09-06 22:24:56.000000000 -0300
320 i_kernel(system_info.kernel);
321 i_memory(system_info.memory);
322 + i_arc(system_info.arc);
323 i_swap(system_info.swap);
324 i_message(&(gstate->now));
327 u_cpustates(system_info.cpustates);
328 u_kernel(system_info.kernel);
329 u_memory(system_info.memory);
330 + u_arc(system_info.arc);
331 u_swap(system_info.swap);
332 u_message(&(gstate->now));
334 --- top-3.8beta1/top.1 2008-05-07 00:41:39.000000000 -0300
335 +++ top-3.8beta1/top.h 2016-09-06 22:28:10.000000000 -0300
339 #define NUM_AVERAGES 3
340 +#define NUM_ZFS_ARC 7
343 int (*f_minibar)(char *, int);