7 #include "../io_ddir.h"
11 #include "../blktrace_api.h"
14 #include "../minmax.h"
15 #include "../oslib/linux-dev-lookup.h"
17 #define TRACE_FIFO_SIZE 8192
19 static unsigned int rt_threshold = 1000000;
20 static unsigned int ios_threshold = 10;
21 static unsigned int rate_threshold;
22 static unsigned int set_rate;
23 static unsigned int max_depth = 256;
24 static int output_ascii = 1;
25 static char *filename;
27 static char **add_opts;
28 static int n_add_opts;
33 static unsigned int collapse_entries = 0;
34 static unsigned int depth_diff = 1;
35 static unsigned int random_diff = 5;
49 unsigned long ios[DDIR_RWDIR_CNT];
50 unsigned long merges[DDIR_RWDIR_CNT];
52 uint64_t last_end[DDIR_RWDIR_CNT];
53 uint64_t seq[DDIR_RWDIR_CNT];
55 struct bs *bs[DDIR_RWDIR_CNT];
56 unsigned int nr_bs[DDIR_RWDIR_CNT];
63 uint64_t first_ttime[DDIR_RWDIR_CNT];
64 uint64_t last_ttime[DDIR_RWDIR_CNT];
65 uint64_t kib[DDIR_RWDIR_CNT];
71 struct flist_head hash_list;
72 struct flist_head pid_list;
76 unsigned int nr_merge_pids;
78 struct trace_file *files;
80 unsigned int last_major, last_minor;
88 struct flist_head list;
93 #define PID_HASH_BITS 10
94 #define PID_HASH_SIZE (1U << PID_HASH_BITS)
96 static struct flist_head pid_hash[PID_HASH_SIZE];
97 static FLIST_HEAD(pid_list);
99 #define INFLIGHT_HASH_BITS 8
100 #define INFLIGHT_HASH_SIZE (1U << INFLIGHT_HASH_BITS)
101 static struct flist_head inflight_hash[INFLIGHT_HASH_SIZE];
103 static uint64_t first_ttime = -1ULL;
105 static struct inflight *inflight_find(uint64_t sector)
107 struct flist_head *inflight_list;
108 struct flist_head *e;
110 inflight_list = &inflight_hash[hash_long(sector, INFLIGHT_HASH_BITS)];
112 flist_for_each(e, inflight_list) {
113 struct inflight *i = flist_entry(e, struct inflight, list);
115 if (i->end_sector == sector)
122 static void inflight_remove(struct inflight *i)
124 struct btrace_out *o = &i->p->o;
127 assert(o->inflight >= 0);
132 static void __inflight_add(struct inflight *i)
134 struct flist_head *list;
136 list = &inflight_hash[hash_long(i->end_sector, INFLIGHT_HASH_BITS)];
137 flist_add_tail(&i->list, list);
140 static void inflight_add(struct btrace_pid *p, uint64_t sector, uint32_t len)
142 struct btrace_out *o = &p->o;
145 i = calloc(1, sizeof(*i));
148 if (!o->depth_disabled) {
149 o->depth = max((int) o->depth, o->inflight);
150 if (o->depth >= max_depth && !o->complete_seen) {
151 o->depth_disabled = 1;
152 o->depth = max_depth;
155 i->end_sector = sector + (len >> 9);
159 static void inflight_merge(struct inflight *i, int rw, unsigned int size)
161 i->p->o.merges[rw]++;
163 i->end_sector += (size >> 9);
170 * fifo refill frontend, to avoid reading data in trace sized bites
172 static int refill_fifo(struct fifo *fifo, int fd)
174 char buf[TRACE_FIFO_SIZE];
179 if (total > fifo_room(fifo))
180 total = fifo_room(fifo);
182 ret = read(fd, buf, total);
184 perror("read refill");
189 ret = fifo_put(fifo, buf, ret);
195 * Retrieve 'len' bytes from the fifo, refilling if necessary.
197 static int trace_fifo_get(struct fifo *fifo, int fd, void *buf,
200 if (fifo_len(fifo) < len) {
201 int ret = refill_fifo(fifo, fd);
207 return fifo_get(fifo, buf, len);
211 * Just discard the pdu by seeking past it.
213 static int discard_pdu(struct fifo *fifo, int fd, struct blk_io_trace *t)
218 return trace_fifo_get(fifo, fd, NULL, t->pdu_len);
221 static int handle_trace_notify(struct blk_io_trace *t)
225 //printf("got process notify: %x, %d\n", t->action, t->pid);
227 case BLK_TN_TIMESTAMP:
228 //printf("got timestamp notify: %x, %d\n", t->action, t->pid);
233 log_err("unknown trace act %x\n", t->action);
240 static void __add_bs(struct btrace_out *o, unsigned int len, int rw)
242 o->bs[rw] = realloc(o->bs[rw], (o->nr_bs[rw] + 1) * sizeof(struct bs));
243 o->bs[rw][o->nr_bs[rw]].bs = len;
244 o->bs[rw][o->nr_bs[rw]].nr = 1;
248 static void add_bs(struct btrace_out *o, unsigned int len, int rw)
250 struct bs *bs = o->bs[rw];
254 __add_bs(o, len, rw);
258 for (i = 0; i < o->nr_bs[rw]; i++) {
259 if (bs[i].bs == len) {
265 __add_bs(o, len, rw);
268 #define FMINORBITS 20
269 #define FMINORMASK ((1U << FMINORBITS) - 1)
270 #define FMAJOR(dev) ((unsigned int) ((dev) >> FMINORBITS))
271 #define FMINOR(dev) ((unsigned int) ((dev) & FMINORMASK))
273 static int btrace_add_file(struct btrace_pid *p, uint32_t devno)
275 unsigned int maj = FMAJOR(devno);
276 unsigned int min = FMINOR(devno);
277 struct trace_file *f;
283 if (p->last_major == maj && p->last_minor == min)
290 * check for this file in our list
292 for (i = 0; i < p->nr_files; i++) {
295 if (f->major == maj && f->minor == min)
300 if (!blktrace_lookup_device(NULL, dev, maj, min)) {
301 log_err("fio: failed to find device %u/%u\n", maj, min);
303 log_err("fio: use -d to specify device\n");
309 p->files = realloc(p->files, (p->nr_files + 1) * sizeof(*f));
310 f = &p->files[p->nr_files];
311 f->name = strdup(dev);
318 static int t_to_rwdir(struct blk_io_trace *t)
320 if (t->action & BLK_TC_ACT(BLK_TC_DISCARD))
323 return (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
326 static int handle_trace_discard(struct blk_io_trace *t, struct btrace_pid *p)
328 struct btrace_out *o = &p->o;
330 if (btrace_add_file(p, t->device))
333 if (o->first_ttime[2] == -1ULL)
334 o->first_ttime[2] = t->time;
337 add_bs(o, t->bytes, DDIR_TRIM);
341 static int handle_trace_fs(struct blk_io_trace *t, struct btrace_pid *p)
343 struct btrace_out *o = &p->o;
346 if (btrace_add_file(p, t->device))
349 first_ttime = min(first_ttime, (uint64_t) t->time);
351 rw = (t->action & BLK_TC_ACT(BLK_TC_WRITE)) != 0;
353 if (o->first_ttime[rw] == -1ULL)
354 o->first_ttime[rw] = t->time;
356 add_bs(o, t->bytes, rw);
359 if (t->sector == o->last_end[rw] || o->last_end[rw] == -1ULL)
362 o->last_end[rw] = t->sector + (t->bytes >> 9);
366 static int handle_queue_trace(struct blk_io_trace *t, struct btrace_pid *p)
368 if (t->action & BLK_TC_ACT(BLK_TC_NOTIFY))
369 return handle_trace_notify(t);
370 else if (t->action & BLK_TC_ACT(BLK_TC_DISCARD))
371 return handle_trace_discard(t, p);
373 return handle_trace_fs(t, p);
376 static int handle_trace(struct blk_io_trace *t, struct btrace_pid *p)
378 unsigned int act = t->action & 0xffff;
381 if (act == __BLK_TA_QUEUE) {
382 inflight_add(p, t->sector, t->bytes);
383 ret = handle_queue_trace(t, p);
384 } else if (act == __BLK_TA_BACKMERGE) {
387 i = inflight_find(t->sector + (t->bytes >> 9));
391 i = inflight_find(t->sector);
393 inflight_merge(i, t_to_rwdir(t), t->bytes);
394 } else if (act == __BLK_TA_FRONTMERGE) {
397 i = inflight_find(t->sector + (t->bytes >> 9));
401 i = inflight_find(t->sector);
403 inflight_merge(i, t_to_rwdir(t), 0);
404 } else if (act == __BLK_TA_COMPLETE) {
407 i = inflight_find(t->sector + (t->bytes >> 9));
409 i->p->o.kib[t_to_rwdir(t)] += (t->bytes >> 10);
410 i->p->o.complete_seen = 1;
418 static void byteswap_trace(struct blk_io_trace *t)
420 t->magic = fio_swap32(t->magic);
421 t->sequence = fio_swap32(t->sequence);
422 t->time = fio_swap64(t->time);
423 t->sector = fio_swap64(t->sector);
424 t->bytes = fio_swap32(t->bytes);
425 t->action = fio_swap32(t->action);
426 t->pid = fio_swap32(t->pid);
427 t->device = fio_swap32(t->device);
428 t->cpu = fio_swap32(t->cpu);
429 t->error = fio_swap16(t->error);
430 t->pdu_len = fio_swap16(t->pdu_len);
433 static struct btrace_pid *pid_hash_find(pid_t pid, struct flist_head *list)
435 struct flist_head *e;
436 struct btrace_pid *p;
438 flist_for_each(e, list) {
439 p = flist_entry(e, struct btrace_pid, hash_list);
447 static struct btrace_pid *pid_hash_get(pid_t pid)
449 struct flist_head *hash_list;
450 struct btrace_pid *p;
452 hash_list = &pid_hash[hash_long(pid, PID_HASH_BITS)];
454 p = pid_hash_find(pid, hash_list);
458 p = calloc(1, sizeof(*p));
460 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
461 p->o.first_ttime[i] = -1ULL;
462 p->o.last_ttime[i] = -1ULL;
463 p->o.last_end[i] = -1ULL;
468 flist_add_tail(&p->hash_list, hash_list);
469 flist_add_tail(&p->pid_list, &pid_list);
476 * Load a blktrace file by reading all the blk_io_trace entries, and storing
477 * them as io_pieces like the fio text version would do.
479 static int load_blktrace(const char *fname, int need_swap)
481 struct btrace_pid *p;
482 unsigned long traces;
483 struct blk_io_trace t;
487 fd = open(fname, O_RDONLY);
489 perror("open trace file\n");
493 fifo = fifo_alloc(TRACE_FIFO_SIZE);
497 ret = trace_fifo_get(fifo, fd, &t, sizeof(t));
502 else if (ret < (int) sizeof(t)) {
503 log_err("fio: short fifo get\n");
510 if ((t.magic & 0xffffff00) != BLK_IO_TRACE_MAGIC) {
511 log_err("fio: bad magic in blktrace data: %x\n", t.magic);
514 if ((t.magic & 0xff) != BLK_IO_TRACE_VERSION) {
515 log_err("fio: bad blktrace version %d\n", t.magic & 0xff);
518 ret = discard_pdu(fifo, fd, &t);
520 log_err("blktrace lseek\n");
522 } else if (t.pdu_len != ret) {
523 log_err("fio: discarded %d of %d\n", ret, t.pdu_len);
527 p = pid_hash_get(t.pid);
528 ret = handle_trace(&t, p);
531 p->o.last_ttime[t_to_rwdir(&t)] = t.time;
542 printf("Traces loaded: %lu\n", traces);
551 static int bs_cmp(const void *ba, const void *bb)
553 const struct bs *bsa = ba;
554 const struct bs *bsb = bb;
556 return bsb->nr - bsa->nr;
559 static unsigned long o_to_kib_rate(struct btrace_out *o, int rw)
561 uint64_t usec = (o->last_ttime[rw] - o->first_ttime[rw]) / 1000ULL;
571 val = o->kib[rw] * 1000ULL;
575 static uint64_t o_first_ttime(struct btrace_out *o)
579 first = min(o->first_ttime[0], o->first_ttime[1]);
580 return min(first, o->first_ttime[2]);
583 static uint64_t o_longest_ttime(struct btrace_out *o)
588 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
591 diff = o->last_ttime[i] - o->first_ttime[i];
592 ret = max(diff, ret);
598 static void __output_p_ascii(struct btrace_pid *p, unsigned long *ios)
600 const char *msg[] = { "reads", "writes", "trims" };
601 struct btrace_out *o = &p->o;
602 unsigned long total, usec;
605 printf("[pid:\t%u", p->pid);
606 if (p->nr_merge_pids)
607 for (i = 0; i < p->nr_merge_pids; i++)
608 printf(", %u", p->merge_pids[i]);
611 total = ddir_rw_sum(o->ios);
612 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
618 ios[i] += o->ios[i] + o->merges[i];
619 printf("%s\n", msg[i]);
620 perc = ((float) o->ios[i] * 100.0) / (float) total;
621 printf("\tios: %lu (perc=%3.2f%%)\n", o->ios[i], perc);
622 perc = ((float) o->merges[i] * 100.0) / (float) total;
623 printf("\tmerges: %lu (perc=%3.2f%%)\n", o->merges[i], perc);
624 perc = ((float) o->seq[i] * 100.0) / (float) o->ios[i];
625 printf("\tseq: %lu (perc=%3.2f%%)\n", (unsigned long) o->seq[i], perc);
626 printf("\trate: %lu KiB/sec\n", o_to_kib_rate(o, i));
628 for (j = 0; j < o->nr_bs[i]; j++) {
629 struct bs *bs = &o->bs[i][j];
631 perc = (((float) bs->nr * 100.0) / (float) o->ios[i]);
632 printf("\tbs=%u, perc=%3.2f%%\n", bs->bs, perc);
636 printf("depth:\t%u\n", o->depth);
637 usec = o_longest_ttime(o) / 1000ULL;
638 printf("usec:\t%lu (delay=%llu)\n", usec, (unsigned long long) o->start_delay);
641 for (i = 0; i < p->nr_files; i++)
642 printf("%s,", p->files[i].name);
648 static int __output_p_fio(struct btrace_pid *p, unsigned long *ios)
650 struct btrace_out *o = &p->o;
652 unsigned long long time;
656 if ((o->ios[0] + o->ios[1]) && o->ios[2]) {
657 log_err("fio: trace has both read/write and trim\n");
661 log_err("fio: no devices found\n");
665 printf("[pid%u", p->pid);
666 if (p->nr_merge_pids)
667 for (i = 0; i < p->nr_merge_pids; i++)
668 printf(",pid%u", p->merge_pids[i]);
671 printf("numjobs=%u\n", p->numjobs);
672 printf("direct=1\n");
674 printf("ioengine=sync\n");
676 printf("ioengine=libaio\niodepth=%u\n", o->depth);
678 if (o->ios[0] && !o->ios[1])
679 printf("rw=randread\n");
680 else if (!o->ios[0] && o->ios[1])
681 printf("rw=randwrite\n");
683 printf("rw=randtrim\n");
685 printf("rw=randrw\n");
686 total = ddir_rw_sum(o->ios);
687 perc = ((float) o->ios[0] * 100.0) / (float) total;
688 printf("rwmixread=%u\n", (int) floor(perc + 0.50));
691 printf("percentage_random=");
692 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
693 if (o->seq[i] && o->ios[i]) {
694 perc = ((float) o->seq[i] * 100.0) / (float) o->ios[i];
703 printf("%u", (int) floor(perc + 0.5));
708 for (i = 0; i < p->nr_files; i++) {
711 printf("%s", p->files[i].name);
715 if (o->start_delay / 1000000ULL)
716 printf("startdelay=%llus\n", o->start_delay / 1000000ULL);
718 time = o_longest_ttime(o);
719 time = (time + 1000000000ULL - 1) / 1000000000ULL;
720 printf("runtime=%llus\n", time);
723 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
725 if (i && o->nr_bs[i - 1] && o->nr_bs[i])
728 for (j = 0; j < o->nr_bs[i]; j++) {
729 struct bs *bs = &o->bs[i][j];
731 perc = (((float) bs->nr * 100.0) / (float) o->ios[i]);
736 if (j + 1 == o->nr_bs[i])
737 printf("%u/", bs->bs);
739 printf("%u/%u", bs->bs, (int) floor(perc + 0.5));
746 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
749 rate = o_to_kib_rate(o, i);
753 printf("%luk", rate);
759 for (i = 0; i < n_add_opts; i++)
760 printf("%s\n", add_opts[i]);
766 static int __output_p(struct btrace_pid *p, unsigned long *ios)
768 struct btrace_out *o = &p->o;
771 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
772 if (o->nr_bs[i] <= 1)
774 qsort(o->bs[i], o->nr_bs[i], sizeof(struct bs), bs_cmp);
778 p->files = malloc(sizeof(struct trace_file));
780 p->files[0].name = filename;
784 __output_p_ascii(p, ios);
786 ret = __output_p_fio(p, ios);
791 static void remove_ddir(struct btrace_out *o, int rw)
796 static int prune_entry(struct btrace_out *o)
802 if (ddir_rw_sum(o->ios) < ios_threshold)
805 time = o_longest_ttime(o) / 1000ULL;
806 if (time < rt_threshold)
810 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
811 unsigned long this_rate;
813 this_rate = o_to_kib_rate(o, i);
814 if (this_rate < rate_threshold) {
821 if (rate < rate_threshold)
827 static int entry_cmp(void *priv, struct flist_head *a, struct flist_head *b)
829 struct btrace_pid *pa = flist_entry(a, struct btrace_pid, pid_list);
830 struct btrace_pid *pb = flist_entry(b, struct btrace_pid, pid_list);
832 return ddir_rw_sum(pb->o.ios) - ddir_rw_sum(pa->o.ios);
835 static void free_p(struct btrace_pid *p)
837 struct btrace_out *o = &p->o;
840 for (i = 0; i < p->nr_files; i++) {
841 if (p->files[i].name && p->files[i].name != filename)
842 free(p->files[i].name);
845 for (i = 0; i < DDIR_RWDIR_CNT; i++)
849 flist_del(&p->pid_list);
850 flist_del(&p->hash_list);
854 static int entries_close(struct btrace_pid *pida, struct btrace_pid *pidb)
856 float perca, percb, fdiff;
859 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
860 if ((pida->o.ios[i] && !pidb->o.ios[i]) ||
861 (pidb->o.ios[i] && !pida->o.ios[i]))
863 if (pida->o.ios[i] && pidb->o.ios[i]) {
864 perca = ((float) pida->o.seq[i] * 100.0) / (float) pida->o.ios[i];
865 percb = ((float) pidb->o.seq[i] * 100.0) / (float) pidb->o.ios[i];
866 fdiff = perca - percb;
867 if (fabs(fdiff) > random_diff)
871 idiff = pida->o.depth - pidb->o.depth;
872 if (abs(idiff) > depth_diff)
879 static void merge_bs(struct bs **bsap, unsigned int *nr_bsap,
880 struct bs *bsb, unsigned int nr_bsb)
882 struct bs *bsa = *bsap;
883 unsigned int nr_bsa = *nr_bsap;
886 for (b = 0; b < nr_bsb; b++) {
889 for (a = 0; a < nr_bsa; a++) {
890 if (bsb[b].bs != bsa[a].bs)
893 bsa[a].nr += bsb[b].nr;
894 bsa[a].merges += bsb[b].merges;
903 bsa = realloc(bsa, (next + 1) * sizeof(struct bs));
904 bsa[next].bs = bsb[b].bs;
905 bsa[next].nr = bsb[b].nr;
911 static int merge_entries(struct btrace_pid *pida, struct btrace_pid *pidb)
915 if (!entries_close(pida, pidb))
918 pida->nr_merge_pids++;
919 pida->merge_pids = realloc(pida->merge_pids, pida->nr_merge_pids * sizeof(pid_t));
920 pida->merge_pids[pida->nr_merge_pids - 1] = pidb->pid;
922 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
923 struct btrace_out *oa = &pida->o;
924 struct btrace_out *ob = &pidb->o;
926 oa->ios[i] += ob->ios[i];
927 oa->merges[i] += ob->merges[i];
928 oa->seq[i] += ob->seq[i];
929 oa->kib[i] += ob->kib[i];
930 oa->first_ttime[i] = min(oa->first_ttime[i], ob->first_ttime[i]);
931 oa->last_ttime[i] = max(oa->last_ttime[i], ob->last_ttime[i]);
932 merge_bs(&oa->bs[i], &oa->nr_bs[i], ob->bs[i], ob->nr_bs[i]);
935 pida->o.start_delay = min(pida->o.start_delay, pidb->o.start_delay);
936 pida->o.depth = (pida->o.depth + pidb->o.depth) / 2;
940 static void check_merges(struct btrace_pid *p, struct flist_head *pidlist)
942 struct flist_head *e, *tmp;
947 flist_for_each_safe(e, tmp, pidlist) {
948 struct btrace_pid *pidb;
950 pidb = flist_entry(e, struct btrace_pid, pid_list);
954 if (merge_entries(p, pidb)) {
961 static int output_p(void)
963 unsigned long ios[DDIR_RWDIR_CNT];
964 struct flist_head *e, *tmp;
965 int depth_disabled = 0;
968 flist_for_each_safe(e, tmp, &pid_list) {
969 struct btrace_pid *p;
971 p = flist_entry(e, struct btrace_pid, pid_list);
972 if (prune_entry(&p->o)) {
976 p->o.start_delay = (o_first_ttime(&p->o) / 1000ULL) - first_ttime;
977 depth_disabled += p->o.depth_disabled;
980 if (collapse_entries) {
981 struct btrace_pid *p;
983 flist_for_each_safe(e, tmp, &pid_list) {
984 p = flist_entry(e, struct btrace_pid, pid_list);
985 check_merges(p, &pid_list);
988 flist_for_each_safe(e, tmp, &pid_list) {
989 p = flist_entry(e, struct btrace_pid, pid_list);
996 log_err("fio: missing completion traces, depths capped at %u\n", max_depth);
998 memset(ios, 0, sizeof(ios));
1000 flist_sort(NULL, &pid_list, entry_cmp);
1002 flist_for_each(e, &pid_list) {
1003 struct btrace_pid *p;
1005 p = flist_entry(e, struct btrace_pid, pid_list);
1006 ret |= __output_p(p, ios);
1007 if (ret && !output_ascii)
1012 printf("Total: reads=%lu, writes=%lu\n", ios[0], ios[1]);
1017 static int usage(char *argv[])
1019 log_err("%s: [options] <blktrace bin file>\n", argv[0]);
1020 log_err("\t-t\tUsec threshold to ignore task\n");
1021 log_err("\t-n\tNumber IOS threshold to ignore task\n");
1022 log_err("\t-f\tFio job file output\n");
1023 log_err("\t-d\tUse this file/device for replay\n");
1024 log_err("\t-r\tIgnore jobs with less than this KiB/sec rate\n");
1025 log_err("\t-R\tSet rate in fio job (def=%u)\n", set_rate);
1026 log_err("\t-D\tCap queue depth at this value (def=%u)\n", max_depth);
1027 log_err("\t-c\tCollapse \"identical\" jobs (def=%u)\n", collapse_entries);
1028 log_err("\t-u\tDepth difference for collapse (def=%u)\n", depth_diff);
1029 log_err("\t-x\tRandom difference for collapse (def=%u)\n", random_diff);
1030 log_err("\t-a\tAdditional fio option to add to job file\n");
1034 static int trace_needs_swap(const char *trace_file, int *swap)
1036 struct blk_io_trace t;
1041 fd = open(trace_file, O_RDONLY);
1047 ret = read(fd, &t, sizeof(t));
1052 } else if (ret != sizeof(t)) {
1054 log_err("fio: short read on trace file\n");
1060 if ((t.magic & 0xffffff00) == BLK_IO_TRACE_MAGIC)
1064 * Maybe it needs to be endian swapped...
1066 t.magic = fio_swap32(t.magic);
1067 if ((t.magic & 0xffffff00) == BLK_IO_TRACE_MAGIC)
1072 log_err("fio: blktrace appears corrupt\n");
1079 int main(int argc, char *argv[])
1081 int need_swap, i, c;
1086 while ((c = getopt(argc, argv, "t:n:fd:r:RD:c:u:x:a:")) != -1) {
1092 rate_threshold = atoi(optarg);
1095 rt_threshold = atoi(optarg);
1098 ios_threshold = atoi(optarg);
1104 filename = strdup(optarg);
1107 max_depth = atoi(optarg);
1110 collapse_entries = atoi(optarg);
1113 depth_diff = atoi(optarg);
1116 random_diff = atoi(optarg);
1119 add_opts = realloc(add_opts, (n_add_opts + 1) * sizeof(char *));
1120 add_opts[n_add_opts] = strdup(optarg);
1132 if (trace_needs_swap(argv[optind], &need_swap))
1135 for (i = 0; i < PID_HASH_SIZE; i++)
1136 INIT_FLIST_HEAD(&pid_hash[i]);
1137 for (i = 0; i < INFLIGHT_HASH_SIZE; i++)
1138 INIT_FLIST_HEAD(&inflight_hash[i]);
1140 load_blktrace(argv[optind], need_swap);
1141 first_ttime /= 1000ULL;