2 * blktrace output analysis: generate a timeline & gather statistics
4 * Copyright (C) 2006 Alan D. Brunelle <Alan.Brunelle@hp.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 typedef struct avg_info *ai_dip_t;
25 ai_dip_t dip_q2q_dm_avg(struct d_info *dip) { return &dip->avgs.q2q_dm; }
26 ai_dip_t dip_q2a_dm_avg(struct d_info *dip) { return &dip->avgs.q2a_dm; }
27 ai_dip_t dip_q2c_dm_avg(struct d_info *dip) { return &dip->avgs.q2c_dm; }
29 ai_dip_t dip_q2q_avg(struct d_info *dip) { return &dip->avgs.q2q; }
30 ai_dip_t dip_q2c_avg(struct d_info *dip) { return &dip->avgs.q2c; }
31 ai_dip_t dip_q2a_avg(struct d_info *dip) { return &dip->avgs.q2a; }
32 ai_dip_t dip_q2g_avg(struct d_info *dip) { return &dip->avgs.q2g; }
33 ai_dip_t dip_g2i_avg(struct d_info *dip) { return &dip->avgs.g2i; }
34 ai_dip_t dip_q2m_avg(struct d_info *dip) { return &dip->avgs.q2m; }
35 ai_dip_t dip_i2d_avg(struct d_info *dip) { return &dip->avgs.i2d; }
36 ai_dip_t dip_d2c_avg(struct d_info *dip) { return &dip->avgs.d2c; }
38 typedef struct avg_info *ai_pip_t;
39 ai_pip_t pip_q2q_dm_avg(struct p_info *pip) { return &pip->avgs.q2q_dm; }
40 ai_pip_t pip_q2a_dm_avg(struct p_info *pip) { return &pip->avgs.q2a_dm; }
41 ai_pip_t pip_q2c_dm_avg(struct p_info *pip) { return &pip->avgs.q2c_dm; }
43 ai_pip_t pip_q2q_avg(struct p_info *pip) { return &pip->avgs.q2q; }
44 ai_pip_t pip_q2c_avg(struct p_info *pip) { return &pip->avgs.q2c; }
45 ai_pip_t pip_q2a_avg(struct p_info *pip) { return &pip->avgs.q2a; }
46 ai_pip_t pip_q2g_avg(struct p_info *pip) { return &pip->avgs.q2g; }
47 ai_pip_t pip_g2i_avg(struct p_info *pip) { return &pip->avgs.g2i; }
48 ai_pip_t pip_q2m_avg(struct p_info *pip) { return &pip->avgs.q2m; }
49 ai_pip_t pip_i2d_avg(struct p_info *pip) { return &pip->avgs.i2d; }
50 ai_pip_t pip_d2c_avg(struct p_info *pip) { return &pip->avgs.d2c; }
52 void output_section_hdr(FILE *ofp, char *hdr)
54 fprintf(ofp, "==================== ");
56 fprintf(ofp, " ====================\n\n");
59 void output_hdr(FILE *ofp, char *hdr)
61 fprintf(ofp, "%15s %13s %13s %13s %11s\n",
62 hdr, "MIN", "AVG", "MAX", "N" );
63 fprintf(ofp, "--------------- ------------- ------------- ------------- -----------\n");
66 void __output_avg(FILE *ofp, char *hdr, struct avg_info *ap)
69 ap->avg = BIT_TIME(ap->total) / (double)ap->n;
70 fprintf(ofp, "%-15s %13.9f %13.9f %13.9f %11d\n", hdr,
71 BIT_TIME(ap->min), ap->avg, BIT_TIME(ap->max), ap->n);
75 static inline char *avg2string(struct avg_info *ap, char *string)
78 sprintf(string, "%13.9f", ap->avg);
84 char *make_dev_hdr(char *pad, size_t len, struct d_info *dip)
87 snprintf(pad, len, "(%3d,%3d)",
88 MAJOR(dip->device), MINOR(dip->device));
90 snprintf(pad, len, "%s", dip->map->device);
95 char *make_dev_hdrX(char *pad, size_t len, struct d_info *dip)
98 snprintf(pad, len, "%d,%d",
99 MAJOR(dip->device), MINOR(dip->device));
101 snprintf(pad, len, "%s", dip->map->device);
108 ai_dip_t (*func)(struct d_info *);
110 void __output_dip_avg(struct d_info *dip, void *arg)
112 struct __oda *odap = arg;
113 ai_dip_t ap = odap->func(dip);
116 ap->avg = BIT_TIME(ap->total) / (double)ap->n;
117 __output_avg(odap->ofp, make_dev_hdr(dev_info, 15, dip), ap);
121 void output_dip_avg(FILE *ofp, char *hdr, ai_dip_t (*func)(struct d_info *))
123 struct __oda oda = { .ofp = ofp, .func = func};
124 output_hdr(ofp, hdr);
125 dip_foreach_out(__output_dip_avg, &oda);
134 void __output_q2d_histo(struct d_info *dip, void *arg)
136 struct __q2d *q2dp = arg;
138 if (q2d_ok(dip->q2d_priv)) {
140 FILE *ofp = q2dp->ofp;
142 fprintf(q2dp->ofp, "%10s | ", make_dev_hdr(dev_info, 15, dip));
143 q2d_display(ofp, dip->q2d_priv);
144 q2d_acc(q2dp->q2d_all, dip->q2d_priv);
149 void output_q2d_histo(FILE *ofp)
151 struct __q2d __q2d = {
153 .q2d_all = q2d_init(),
157 fprintf(ofp, "%10s | ", "DEV");
158 q2d_display_header(ofp);
159 fprintf(ofp, "--------- | ");
160 q2d_display_dashes(ofp);
161 dip_foreach_out(__output_q2d_histo, &__q2d);
164 fprintf(ofp, "========== | ");
165 q2d_display_dashes(ofp);
166 fprintf(ofp, "%10s | ", "AVG");
167 q2d_display(ofp, __q2d.q2d_all);
174 unsigned long long nq, nd, blkmin, blkmax, total;
176 void __output_dip_merge_ratio(struct d_info *dip, void *arg)
180 double ratio, q2c_n, d2c_n;
182 if (dip->n_qs == 0 || dip->n_ds == 0)
184 else if (dip->n_qs < dip->n_ds)
185 dip->n_qs = dip->n_ds;
189 if (q2c_n > 0.0 && d2c_n > 0.0) {
193 ratio = q2c_n / d2c_n;
194 blks_avg = (double)dip->avgs.blks.total / d2c_n;
196 "%10s | %8llu %8llu %7.1lf | %8llu %8llu %8llu %8llu\n",
197 make_dev_hdr(dev_info, 15, dip),
198 (unsigned long long)dip->n_qs,
199 (unsigned long long)dip->n_ds,
201 (unsigned long long)dip->avgs.blks.min,
202 (unsigned long long)blks_avg,
203 (unsigned long long)dip->avgs.blks.max,
204 (unsigned long long)dip->avgs.blks.total);
206 if (easy_parse_avgs) {
208 "DMI %s %llu %llu %.9lf %llu %llu %llu %llu\n",
209 make_dev_hdrX(dev_info, 15, dip),
210 (unsigned long long)dip->n_qs,
211 (unsigned long long)dip->n_ds,
213 (unsigned long long)dip->avgs.blks.min,
214 (unsigned long long)blks_avg,
215 (unsigned long long)dip->avgs.blks.max,
216 (unsigned long long)dip->avgs.blks.total);
219 if (n_merges++ == 0) {
220 merge_data.blkmin = dip->avgs.blks.min;
221 merge_data.blkmax = dip->avgs.blks.max;
224 merge_data.nq += dip->n_qs;
225 merge_data.nd += dip->n_ds;
226 merge_data.total += dip->avgs.blks.total;
227 if (dip->avgs.blks.min < merge_data.blkmin)
228 merge_data.blkmin = dip->avgs.blks.min;
229 if (dip->avgs.blks.max > merge_data.blkmax)
230 merge_data.blkmax = dip->avgs.blks.max;
234 void output_dip_merge_ratio(FILE *ofp)
236 fprintf(ofp, "%10s | %8s %8s %7s | %8s %8s %8s %8s\n", "DEV", "#Q", "#D", "Ratio", "BLKmin", "BLKavg", "BLKmax", "Total");
237 fprintf(ofp, "---------- | -------- -------- ------- | -------- -------- -------- --------\n");
238 dip_foreach_out(__output_dip_merge_ratio, ofp);
240 fprintf(ofp, "---------- | -------- -------- ------- | -------- -------- -------- --------\n");
241 fprintf(ofp, "%10s | %8s %8s %7s | %8s %8s %8s %8s\n", "DEV", "#Q", "#D", "Ratio", "BLKmin", "BLKavg", "BLKmax", "Total");
243 "%10s | %8llu %8llu %7.1lf | %8llu %8llu %8llu %8llu\n",
244 "TOTAL", merge_data.nq, merge_data.nd,
245 (float)merge_data.nq / (float)merge_data.nd,
247 merge_data.total / merge_data.nd,
248 merge_data.blkmax, merge_data.total);
253 struct __ohead_data {
260 struct __ohead_data q2g, g2i, q2m, i2d, d2c;
263 #define AVG(a,b) (100.0 * ((double)(a) / (double)(b)))
264 #define CALC_AVG(ap) (ap)->avg = ((ap)->n == 0 ? 0.0 : \
265 (BIT_TIME((ap)->total) / \
268 #define x_v_q2C(fld, dip, s, odp) \
270 if (dip->avgs. fld .n == 0) return " "; \
271 q2c = dip->avgs.g2i.avg + dip->avgs.g2i.avg + \
272 dip->avgs.i2d.avg + dip->avgs.d2c.avg; \
273 sprintf(s, "%8.4lf%%", AVG(dip->avgs. fld .avg, q2c)); \
274 odp-> fld .n += dip->avgs. fld .n; \
275 odp-> fld .total += dip->avgs. fld .total; \
278 char *q2g_v_q2C(struct d_info *dip, char *s, struct ohead_data *odp)
280 x_v_q2C(q2g, dip, s, odp);
283 char *g2i_v_q2C(struct d_info *dip, char *s, struct ohead_data *odp)
285 x_v_q2C(g2i, dip, s, odp);
288 char *q2m_v_q2C(struct d_info *dip, char *s, struct ohead_data *odp)
290 x_v_q2C(q2m, dip, s, odp);
293 char *i2d_v_q2C(struct d_info *dip, char *s, struct ohead_data *odp)
295 x_v_q2C(i2d, dip, s, odp);
298 char *d2c_v_q2C(struct d_info *dip, char *s, struct ohead_data *odp)
300 x_v_q2C(d2c, dip, s, odp);
303 void __output_dip_prep_ohead(struct d_info *dip, void *arg)
306 char s1[16], s2[16], s3[16], s4[16], s5[16];
307 struct ohead_data *odp = arg;
309 if (dip->avgs.q2g.n > 0 && dip->avgs.g2i.n > 0 &&
310 dip->avgs.i2d.n > 0 && dip->avgs.d2c.n > 0) {
311 CALC_AVG(&dip->avgs.q2g);
312 CALC_AVG(&dip->avgs.g2i);
313 CALC_AVG(&dip->avgs.q2m);
314 CALC_AVG(&dip->avgs.i2d);
315 CALC_AVG(&dip->avgs.d2c);
317 fprintf(odp->ofp, "%10s | %9s %9s %9s %9s %9s\n",
318 make_dev_hdr(dev_info, 15, dip),
319 q2g_v_q2C(dip, s1, odp),
320 g2i_v_q2C(dip, s2, odp),
321 q2m_v_q2C(dip, s3, odp),
322 i2d_v_q2C(dip, s4, odp),
323 d2c_v_q2C(dip, s5, odp));
327 #define OD_AVG(od, fld, q2c) \
328 (od. fld .n == 0) ? (double)0.0 : \
329 (100.0 * ((double)((od). fld . total) / q2c))
331 void output_dip_prep_ohead(FILE *ofp)
334 struct ohead_data od;
336 memset(&od, 0, sizeof(od));
339 fprintf(ofp, "%10s | %9s %9s %9s %9s %9s\n",
340 "DEV", "Q2G", "G2I", "Q2M", "I2D", "D2C");
341 fprintf(ofp, "---------- | --------- --------- --------- --------- ---------\n");
342 dip_foreach_out(__output_dip_prep_ohead, &od);
344 if (od.q2g.n == 0 && od.g2i.n == 0 && od.q2m.n == 0 &&
345 od.i2d.n == 0 && od.d2c.n == 0)
348 q2c = od.q2g.total + od.g2i.total + od.q2m.total +
349 od.i2d.total + od.d2c.total;
350 fprintf(ofp, "---------- | --------- --------- --------- --------- ---------\n");
351 fprintf(ofp, "%10s | %8.4lf%% %8.4lf%% %8.4lf%% %8.4lf%% %8.4lf%%\n", "Overall",
352 OD_AVG(od, q2g, q2c), OD_AVG(od, g2i, q2c),
353 OD_AVG(od, q2m, q2c), OD_AVG(od, i2d, q2c),
354 OD_AVG(od, d2c, q2c));
360 struct seek_mode_info {
361 struct seek_mode_info *next;
366 long long nseeks, median;
368 struct seek_mode_info *head;
372 void output_seek_mode_info(FILE *ofp, struct o_seek_info *sip)
374 struct seek_mode_info *p, *this, *new_list = NULL;
376 while ((this = sip->head) != NULL) {
377 sip->head = this->next;
380 if (new_list == NULL || this->nseeks > new_list->nseeks)
382 else if (this->nseeks == new_list->nseeks) {
383 for (p = new_list; p != NULL; p = p->next)
384 if (p->mode == this->mode)
388 this->nseeks += p->nseeks;
390 this->next = new_list;
395 fprintf(ofp, "%10s | %15lld %15.1lf %15lld | %lld(%d)",
396 "Average", sip->nseeks, sip->mean / sip->nseeks,
397 sip->median / sip->nseeks, new_list->mode, new_list->nseeks);
399 for (p = new_list->next; p != NULL; p = p->next)
400 fprintf(ofp, " %lld(%d)", p->mode, p->nseeks);
403 void add_seek_mode_info(struct o_seek_info *sip, struct mode *mp)
406 long long *lp = mp->modes;
407 struct seek_mode_info *smip;
410 for (i = 0; i < mp->nmds; i++, lp++) {
411 for (smip = sip->head; smip; smip = smip->next) {
412 if (smip->mode == *lp) {
413 smip->nseeks += mp->most_seeks;
418 struct seek_mode_info *new = malloc(sizeof(*new));
420 new->next = sip->head;
423 new->nseeks = mp->most_seeks;
430 static void do_output_dip_seek_info(struct d_info *dip, FILE *ofp, int is_q2q)
438 void *handle = is_q2q ? dip->q2q_handle : dip->seek_handle;
440 nseeks = seeki_nseeks(handle);
442 mean = seeki_mean(handle);
443 median = seeki_median(handle);
444 nmodes = seeki_mode(handle, &m);
446 fprintf(ofp, "%10s | %15lld %15.1lf %15lld | %lld(%d)",
447 make_dev_hdr(dev_info, 15, dip), nseeks, mean, median,
448 nmodes > 0 ? m.modes[0] : 0, m.most_seeks);
449 for (i = 1; i < nmodes; i++)
450 fprintf(ofp, " %lld", m.modes[i]);
453 if (easy_parse_avgs) {
454 char *rec = is_q2q ? "QSK" : "DSK";
456 "%s %s %lld %.9lf %lld %lld %d",
457 rec, make_dev_hdrX(dev_info, 15, dip),
458 nseeks, mean, median,
459 nmodes > 0 ? m.modes[0] : 0, m.most_seeks);
460 for (i = 1; i < nmodes; i++)
461 fprintf(xavgs_ofp, " %lld", m.modes[i]);
462 fprintf(xavgs_ofp, "\n");
465 seek_info.nseeks += nseeks;
466 seek_info.mean += (nseeks * mean);
467 seek_info.median += (nseeks * median);
468 add_seek_mode_info(&seek_info, &m);
473 void __output_dip_seek_info(struct d_info *dip, void *arg)
475 do_output_dip_seek_info(dip, (FILE *)arg, 0);
478 void __output_dip_q2q_seek_info(struct d_info *dip, void *arg)
480 do_output_dip_seek_info(dip, (FILE *)arg, 1);
483 void output_dip_seek_info(FILE *ofp)
486 memset(&seek_info, 0, sizeof(seek_info));
488 fprintf(ofp, "%10s | %15s %15s %15s | %-15s\n", "DEV", "NSEEKS",
489 "MEAN", "MEDIAN", "MODE");
490 fprintf(ofp, "---------- | --------------- --------------- --------------- | ---------------\n");
491 dip_foreach_out(__output_dip_seek_info, ofp);
493 fprintf(ofp, "---------- | --------------- --------------- --------------- | ---------------\n");
494 fprintf(ofp, "%10s | %15s %15s %15s | %-15s\n",
495 "Overall", "NSEEKS", "MEAN", "MEDIAN", "MODE");
496 output_seek_mode_info(ofp, &seek_info);
502 void output_dip_q2q_seek_info(FILE *ofp)
505 memset(&seek_info, 0, sizeof(seek_info));
507 fprintf(ofp, "%10s | %15s %15s %15s | %-15s\n", "DEV", "NSEEKS",
508 "MEAN", "MEDIAN", "MODE");
509 fprintf(ofp, "---------- | --------------- --------------- --------------- | ---------------\n");
510 dip_foreach_out(__output_dip_q2q_seek_info, ofp);
512 fprintf(ofp, "---------- | --------------- --------------- --------------- | ---------------\n");
513 fprintf(ofp, "%10s | %15s %15s %15s | %-15s\n",
514 "Overall", "NSEEKS", "MEAN", "MEDIAN", "MODE");
515 output_seek_mode_info(ofp, &seek_info);
523 ai_pip_t (*func)(struct p_info *);
526 void __output_pip_avg(struct p_info *pip, void *arg)
528 struct __opa *opap = arg;
529 ai_pip_t ap = opap->func(pip);
533 snprintf(proc_name, 15, pip->name);
535 ap->avg = BIT_TIME(ap->total) / (double)ap->n;
536 __output_avg(opap->ofp, proc_name, ap);
540 void output_pip_avg(FILE *ofp, char *hdr, ai_pip_t (*func)(struct p_info *))
542 struct __opa opa = { .ofp = ofp, .func = func };
544 output_hdr(ofp, hdr);
545 pip_foreach_out(__output_pip_avg, &opa);
551 long n_plugs, n_timer_unplugs;
555 void __dip_output_plug(struct d_info *dip, void *arg)
561 if (dip->nplugs > 0) {
562 if (dip->is_plugged) dip_unplug(dip->device, dip->end_time, 0);
563 delta = dip->end_time - dip->start_time;
564 pct = 100.0 * ((dip->plugged_time / delta) / delta);
566 fprintf(ofp, "%10s | %10d(%10d) | %13.9lf%%\n",
567 make_dev_hdr(dev_info, 15, dip),
568 dip->nplugs, dip->n_timer_unplugs, pct);
570 if (easy_parse_avgs) {
572 "PLG %s %d %d %.9lf\n",
573 make_dev_hdrX(dev_info, 15, dip),
574 dip->nplugs, dip->n_timer_unplugs, pct);
578 plug_info.n_plugs += dip->nplugs;
579 plug_info.n_timer_unplugs += dip->n_timer_unplugs;
580 plug_info.t_percent += pct;
584 void __dip_output_plug_all(FILE *ofp, struct plug_info *p)
586 fprintf(ofp, "---------- | ---------- ---------- | ----------------\n");
587 fprintf(ofp, "%10s | %10s %10s | %s\n",
588 "Overall", "# Plugs", "# Timer Us", "% Time Q Plugged");
589 fprintf(ofp, "%10s | %10ld(%10ld) | %13.9lf%%\n", "Average",
590 p->n_plugs / n_plugs, p->n_timer_unplugs / n_plugs,
591 p->t_percent / n_plugs);
595 __u64 n_nios_uplugs, n_nios_uplugs_t;
596 struct nios_plug_info {
597 __u64 tot_nios_up, tot_nios_up_t;
600 void __dip_output_plug_nios(struct d_info *dip, void *arg)
604 double a_nios_uplug = 0.0, a_nios_uplug_t = 0.0;
606 if (dip->nios_up && dip->nplugs) {
607 a_nios_uplug = (double)dip->nios_up / (double)dip->nplugs;
608 n_nios_uplugs += dip->nplugs;
609 nios_plug_info.tot_nios_up += dip->nios_up;
611 if (dip->nios_upt && dip->nplugs_t) {
612 a_nios_uplug_t = (double)dip->nios_upt / (double)dip->nplugs_t;
613 n_nios_uplugs_t += dip->nplugs_t;
614 nios_plug_info.tot_nios_up_t += dip->nios_upt;
617 fprintf(ofp, "%10s | %10.1lf %10.1lf\n",
618 make_dev_hdr(dev_info, 15, dip),
619 a_nios_uplug, a_nios_uplug_t);
621 if (easy_parse_avgs) {
623 "UPG %s %.9lf %.9lf\n",
624 make_dev_hdrX(dev_info, 15, dip),
625 a_nios_uplug, a_nios_uplug_t);
629 void __dip_output_uplug_all(FILE *ofp, struct nios_plug_info *p)
631 double ios_unp = 0.0, ios_unp_to = 0.0;
634 ios_unp = (double)p->tot_nios_up / (double)n_nios_uplugs;
636 ios_unp_to = (double)p->tot_nios_up_t / (double)n_nios_uplugs_t;
638 fprintf(ofp, "---------- | ---------- ----------\n");
639 fprintf(ofp, "%10s | %10s %10s\n",
640 "Overall", "IOs/Unp", "IOs/Unp(to)");
641 fprintf(ofp, "%10s | %10.1lf %10.1lf\n",
642 "Average", ios_unp, ios_unp_to);
645 void output_plug_info(FILE *ofp)
647 fprintf(ofp, "%10s | %10s %10s | %s\n",
648 "DEV", "# Plugs", "# Timer Us", "% Time Q Plugged");
649 fprintf(ofp, "---------- | ---------- ---------- | ----------------\n");
650 dip_foreach_out(__dip_output_plug, ofp);
652 __dip_output_plug_all(ofp, &plug_info);
655 fprintf(ofp, "%10s | %10s %10s\n",
656 "DEV", "IOs/Unp", "IOs/Unp(to)");
657 fprintf(ofp, "---------- | ---------- ----------\n");
658 dip_foreach_out(__dip_output_plug_nios, ofp);
659 if (n_nios_uplugs || n_nios_uplugs_t)
660 __dip_output_uplug_all(ofp, &nios_plug_info);
670 void __dip_output_actQ(struct d_info *dip, void *arg)
672 if (dip->n_qs > 0 && !remapper_dev(dip->device)) {
674 double a_actQs = (double)dip->t_act_q / (double)dip->n_qs;
676 fprintf((FILE *)arg, "%10s | %13.1lf\n",
677 make_dev_hdr(dev_info, 15, dip), a_actQs);
679 if (easy_parse_avgs) {
682 make_dev_hdrX(dev_info, 15, dip), a_actQs);
686 actQ_info.t_qs += dip->n_qs;
687 actQ_info.t_act_qs += dip->t_act_q;
691 void __dip_output_actQ_all(FILE *ofp, struct actQ_info *p)
693 fprintf(ofp, "---------- | -------------\n");
694 fprintf(ofp, "%10s | %13s\n", "Overall", "Avgs Reqs @ Q");
695 fprintf(ofp, "%10s | %13.1lf\n", "Average",
696 (double)p->t_act_qs / (double)p->t_qs);
699 void output_actQ_info(FILE *ofp)
701 fprintf(ofp, "%10s | %13s\n", "DEV", "Avg Reqs @ Q");
702 fprintf(ofp, "---------- | -------------\n");
703 dip_foreach_out(__dip_output_actQ, ofp);
705 __dip_output_actQ_all(ofp, &actQ_info);
709 void output_histos(void)
715 if (output_name == NULL) return;
717 sprintf(fname, "%s_qhist.dat", output_name);
718 ofp = fopen(fname, "w");
724 fprintf(ofp, "# BTT histogram data\n");
725 fprintf(ofp, "# Q buckets\n");
726 for (i = 0; i < (N_HIST_BKTS-1); i++)
727 fprintf(ofp, "%4d %lld\n", (i+1), (long long)q_histo[i]);
728 fprintf(ofp, "\n# Q bucket for > %d\n%4d %lld\n", (int)N_HIST_BKTS-1,
729 N_HIST_BKTS-1, (long long)q_histo[N_HIST_BKTS-1]);
732 sprintf(fname, "%s_dhist.dat", output_name);
733 ofp = fopen(fname, "w");
738 fprintf(ofp, "# D buckets\n");
739 for (i = 0; i < (N_HIST_BKTS-1); i++)
740 fprintf(ofp, "%4d %lld\n", (i+1), (long long)d_histo[i]);
741 fprintf(ofp, "\n# D bucket for > %d\n%4d %lld\n", (int)N_HIST_BKTS-1,
742 N_HIST_BKTS-1, (long long)d_histo[N_HIST_BKTS-1]);
746 int output_avgs(FILE *ofp)
748 if (output_all_data) {
749 if (exes == NULL || *exes != '\0') {
750 output_section_hdr(ofp, "Per Process");
751 output_pip_avg(ofp, "Q2Qdm", pip_q2q_dm_avg);
752 output_pip_avg(ofp, "Q2Adm", pip_q2a_dm_avg);
753 output_pip_avg(ofp, "Q2Cdm", pip_q2c_dm_avg);
756 output_pip_avg(ofp, "Q2Q", pip_q2q_avg);
757 output_pip_avg(ofp, "Q2A", pip_q2a_avg);
758 output_pip_avg(ofp, "Q2G", pip_q2g_avg);
759 output_pip_avg(ofp, "G2I", pip_g2i_avg);
760 output_pip_avg(ofp, "Q2M", pip_q2m_avg);
761 output_pip_avg(ofp, "I2D", pip_i2d_avg);
762 output_pip_avg(ofp, "D2C", pip_d2c_avg);
763 output_pip_avg(ofp, "Q2C", pip_q2c_avg);
766 output_section_hdr(ofp, "Per Device");
767 output_dip_avg(ofp, "Q2Qdm", dip_q2q_dm_avg);
768 output_dip_avg(ofp, "Q2Adm", dip_q2a_dm_avg);
769 output_dip_avg(ofp, "Q2Cdm", dip_q2c_dm_avg);
772 output_dip_avg(ofp, "Q2Q", dip_q2q_avg);
773 output_dip_avg(ofp, "Q2A", dip_q2a_avg);
774 output_dip_avg(ofp, "Q2G", dip_q2g_avg);
775 output_dip_avg(ofp, "G2I", dip_g2i_avg);
776 output_dip_avg(ofp, "Q2M", dip_q2m_avg);
777 output_dip_avg(ofp, "I2D", dip_i2d_avg);
778 output_dip_avg(ofp, "D2C", dip_d2c_avg);
779 output_dip_avg(ofp, "Q2C", dip_q2c_avg);
782 output_section_hdr(ofp, "All Devices");
783 output_hdr(ofp, "ALL");
784 __output_avg(ofp, "Q2Qdm", &all_avgs.q2q_dm);
785 __output_avg(ofp, "Q2Adm", &all_avgs.q2a_dm);
786 __output_avg(ofp, "Q2Cdm", &all_avgs.q2c_dm);
789 __output_avg(ofp, "Q2Q", &all_avgs.q2q);
790 __output_avg(ofp, "Q2A", &all_avgs.q2a);
791 __output_avg(ofp, "Q2G", &all_avgs.q2g);
792 __output_avg(ofp, "G2I", &all_avgs.g2i);
793 __output_avg(ofp, "Q2M", &all_avgs.q2m);
794 __output_avg(ofp, "I2D", &all_avgs.i2d);
795 __output_avg(ofp, "M2D", &all_avgs.m2d);
796 __output_avg(ofp, "D2C", &all_avgs.d2c);
797 __output_avg(ofp, "Q2C", &all_avgs.q2c);
800 output_section_hdr(ofp, "Device Overhead");
801 output_dip_prep_ohead(ofp);
803 output_section_hdr(ofp, "Device Merge Information");
804 output_dip_merge_ratio(ofp);
806 output_section_hdr(ofp, "Device Q2Q Seek Information");
807 output_dip_q2q_seek_info(ofp);
809 output_section_hdr(ofp, "Device D2D Seek Information");
810 output_dip_seek_info(ofp);
812 output_section_hdr(ofp, "Plug Information");
813 output_plug_info(ofp);
815 output_section_hdr(ofp, "Active Requests At Q Information");
816 output_actQ_info(ofp);
820 if (output_all_data) {
821 output_section_hdr(ofp, "Q2D Histogram");
822 output_q2d_histo(ofp);
828 void __output_ranges(FILE *ofp, struct list_head *head_p, float base)
830 struct range_info *rip;
832 float limit = base + 0.4;
834 __list_for_each(p, head_p) {
835 rip = list_entry(p, struct range_info, head);
836 fprintf(ofp, "%13.9lf %5.1f\n", BIT_TIME(rip->start), base);
837 fprintf(ofp, "%13.9lf %5.1f\n", BIT_TIME(rip->start), limit);
838 fprintf(ofp, "%13.9lf %5.1f\n", BIT_TIME(rip->end), limit);
839 fprintf(ofp, "%13.9lf %5.1f\n", BIT_TIME(rip->end), base);
843 int output_regions(FILE *ofp, char *header, struct region_info *reg,
846 if (list_len(®->qranges) == 0 && list_len(®->cranges) == 0)
849 fprintf(ofp, "# %16s : q activity\n", header);
850 __output_ranges(ofp, ®->qranges, base);
853 fprintf(ofp, "# %16s : c activity\n", header);
854 __output_ranges(ofp, ®->cranges, base + 0.5);
864 void __output_dev(struct d_info *dip, void *arg)
867 struct __od *odp = arg;
869 sprintf(header, "%d,%d", MAJOR(dip->device), MINOR(dip->device));
870 if (output_regions(odp->ofp, header, &dip->regions, odp->base))
874 float output_devs(FILE *ofp, float base)
876 struct __od od = { .ofp = ofp, .base = base };
878 fprintf(ofp, "# Per device\n" );
879 dip_foreach_out(__output_dev, &od);
883 static inline int exe_match(char *exe, char *name)
885 return (exe == NULL) || (strstr(name, exe) != NULL);
892 void __output_procs(struct p_info *pip, void *arg)
894 struct __op *opp = arg;
895 output_regions(opp->ofp, pip->name, &pip->regions, opp->base);
899 float output_procs(FILE *ofp, float base)
901 struct __op op = { .ofp = ofp, .base = base };
903 fprintf(ofp, "# Per process\n" );
904 pip_foreach_out(__output_procs, &op);
908 int output_ranges(FILE *ofp)
912 fprintf(ofp, "# %s\n", "Total System");
913 if (output_regions(ofp, "Total System", &all_regions, base))
917 base = output_devs(ofp, base);
919 base = output_procs(ofp, base);