rust/cargo-c: update to 0.10.9+cargo-0.85.0
[oi-userland.git] / components / sysutils / top / patches / 05.zfs_arc_stats.patch
blobcc88abfb44ffa799dd382575a4efac0b4c242672
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
4 @@ -294,6 +294,10 @@
5 #define MEMORY_TOTALSWAP 2
6 #define MEMORY_FREESWAP 3
8 +/* these are for detailing the ZFS ARC statistics */
9 +char *arcnames[] =
10 +{"K Total, ", "K MRU, ", "K MFU, ", "K Anon, ", "K Header, ", "K Other", NULL};
12 /* these are for detailing kernel statistics */
13 int kernel_stats[8];
14 char *kernelnames[] =
15 @@ -845,6 +849,7 @@
18 static kstat_t *ks_system_misc = NULL;
19 +static kstat_t *ks_arcstats = NULL;
21 #endif /* USE_KSTAT */
23 @@ -888,6 +893,66 @@
26 int
27 +get_arcstats(long arcstats[NUM_ZFS_ARC])
29 + #ifdef USE_KSTAT
30 + int status;
31 + kstat_named_t *kn;
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)
38 + {
39 + if ((kn = kstat_data_lookup(ks_arcstats, "size")) != NULL)
40 + {
41 + if(kn->value.ui64 > 0){
42 + arcstats[0] = (long) kn->value.ui64 / 1024;
43 + }
44 + }
45 + if ((kn = kstat_data_lookup(ks_arcstats, "mru_size")) != NULL)
46 + {
47 + if(kn->value.ui64 > 0){
48 + arcstats[1] = (long) kn->value.ui64 / 1024;
49 + }
50 + }
51 + if ((kn = kstat_data_lookup(ks_arcstats, "mfu_size")) != NULL)
52 + {
53 + if(kn->value.ui64 > 0){
54 + arcstats[2] = (long) kn->value.ui64 / 1024;
55 + }
56 + }
57 + if ((kn = kstat_data_lookup(ks_arcstats, "anon_size")) != NULL)
58 + {
59 + if(kn->value.ui64 > 0){
60 + arcstats[3] = (long) kn->value.ui64 / 1024;
61 + }
62 + }
63 + if ((kn = kstat_data_lookup(ks_arcstats, "hdr_size")) != NULL)
64 + {
65 + if(kn->value.ui64 > 0){
66 + arcstats[4] = (long) kn->value.ui64 / 1024;
67 + }
68 + }
69 + if ((kn = kstat_data_lookup(ks_arcstats, "other_size")) != NULL)
70 + {
71 + if(kn->value.ui64 > 0){
72 + arcstats[5] = (long) kn->value.ui64 / 1024;
73 + }
74 + }
75 + }
76 + dprintf("get_arcstats returns %d\n", status);
77 + return (status);
79 +#else /* !USE_KSTAT */
81 + return 0;
83 +#endif /* USE_KSTAT */
86 +int
87 get_ncpus()
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;
102 /* get boot time */
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)
108 int avenrun[3];
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
126 @@ -101,6 +101,8 @@
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;
146 +static int num_arc;
147 static int num_swap;
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;
157 #else
158 #define memory_cidx NULL
159 +#define arc_cidx NULL
160 #define swap_cidx NULL
161 #define kernel_cidx NULL
162 #endif
163 @@ -526,10 +532,10 @@
166 static void
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)
171 - register int num;
172 + register long num;
173 register char *thisname;
174 register char *lastname = NULL;
175 register int color;
176 @@ -762,18 +768,29 @@
177 kernel_names = statics->kernel_names;
178 if ((num_kernel = string_count(kernel_names)) > 0)
180 + /* adjust screen placements */
181 + y_mem++;
182 + y_swap++;
183 + y_message++;
184 + y_header++;
185 + y_idlecursor++;
186 + y_procs++;
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 */
194 - y_mem++;
195 - y_swap++;
196 y_message++;
197 y_header++;
198 y_idlecursor++;
199 y_procs++;
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)
206 + /* arc names */
207 + arc_names = statics->arc_names;
208 + if ((num_arc = string_count(arc_names)) > 0)
210 /* adjust screen placements */
211 y_message++;
212 @@ -799,6 +816,8 @@
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;
221 @@ -856,6 +875,16 @@
222 memory_cidx[i++] = color_tag(scratchbuf);
225 + /* color tags for memory */
226 + arc_cidx = (int *)malloc(num_arc * sizeof(int));
227 + i = 0;
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 */
236 if (num_swap > 0)
238 @@ -1316,6 +1345,28 @@
242 + * *_arc(stats) - print "ARC: " followed by the ARC summary string
243 + */
244 +void
245 +i_arc(long *stats)
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);
255 +void
256 +u_arc(long *stats)
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
278 @@ -58,6 +58,8 @@
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
289 @@ -58,6 +58,8 @@
290 #define Y_KERNEL 3
291 #define X_MEM 8
292 #define Y_MEM 3
293 +#define X_ARC 8
294 +#define Y_ARC 5
295 #define X_SWAP 6
296 #define Y_SWAP 4
297 #define Y_MESSAGE 4
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
300 @@ -50,6 +50,7 @@
301 char **procstate_names;
302 char **cpustate_names;
303 char **memory_names;
304 + char **arc_names;
305 char **swap_names; /* optional */
306 char **order_names; /* optional */
307 char **top_color_names; /* optional */
308 @@ -84,6 +85,7 @@
309 int *cpustates;
310 int *kernel;
311 long *memory;
312 + long arc[NUM_ZFS_ARC];
313 long *swap;
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
318 @@ -547,6 +547,7 @@
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));
325 i_header(hdr);
326 @@ -569,6 +570,7 @@
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));
333 u_header(hdr);
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
336 @@ -59,6 +59,7 @@
339 #define NUM_AVERAGES 3
340 +#define NUM_ZFS_ARC 7
342 struct ext_decl {
343 int (*f_minibar)(char *, int);