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
27 char bt_timeline_version[] = "0.99";
31 char *input_name = NULL;
32 char *output_name = NULL;
33 char *seek_name = NULL;
34 double range_delta = 0.1;
35 FILE *ranges_ofp, *avgs_ofp;
39 unsigned long n_traces, n_io_allocs, n_io_frees;
40 struct avgs_info all_avgs;
41 __u64 last_q = (__u64)-1;
42 unsigned int pending_xs;
48 struct my_mem *free_ios = NULL;
49 struct my_mem *free_bits = NULL;
51 struct region_info all_regions = {
52 .qranges = LIST_HEAD_INIT(all_regions.qranges),
53 .cranges = LIST_HEAD_INIT(all_regions.cranges),
58 char iop_map[] = { 'Q', 'X', 'A', 'M', 'I', 'D', 'C', 'Y' };
60 struct blk_io_trace *convert_to_cpu(struct blk_io_trace *t);
63 int main(int argc, char *argv[])
65 handle_args(argc, argv);
69 if (process() || output_avgs(avgs_ofp) || output_ranges(ranges_ofp))
78 struct blk_io_trace *t;
79 struct io *iop = IO_ZALLOC();
81 while (!do_read(ifd, &iop->t, sizeof(iop->t))) {
82 t = convert_to_cpu(&iop->t);
84 iop->pdu = malloc(t->pdu_len);
85 if (do_read(ifd, iop->pdu, t->pdu_len)) {
97 fprintf(iostat_ofp, "\n");
98 iostat_dump_stats(iostat_last_stamp, 1);
102 printf("\n%10lu traces, %10lu mallocs %1lu frees\n",
103 n_traces, n_io_allocs, n_io_frees);