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
28 #define pdu_start(t) (((void *) (t) + sizeof(struct blk_io_trace)))
30 #define BIT_TIME(t) ((double)SECONDS(t) + ((double)NANO_SECONDS(t) / 1.0e9))
32 #define BIT_START(iop) ((iop)->t.sector)
33 #define BIT_END(iop) ((iop)->t.sector + ((iop)->t.bytes >> 9))
34 #define IOP_READ(iop) ((iop)->t.action & BLK_TC_ACT(BLK_TC_READ))
37 #define ASSERT(truth) do { \
44 #define DBG_PING() dbg_ping()
46 #define LIST_DEL(hp) list_del(hp)
52 #define LIST_DEL(hp) do { \
53 if (((hp)->next != NULL) && \
54 ((hp)->next != LIST_POISON1)) \
59 #define IO_ZALLOC() my_zmalloc(&free_ios, sizeof(struct io))
60 #define IO_FREE(iop) my_free(&free_ios, iop)
72 #define N_IOP_TYPES (IOP_Y + 1)
80 struct list_head head;
86 __u64 min, max, total;
94 struct avg_info q2a; /* Q to (A or X) */
95 struct avg_info q2i; /* Q to (I or M) */
96 struct avg_info i2d; /* (I or M) to D */
99 struct avg_info blks; /* Blocks transferred */
103 struct list_head head; /* on: qranges OR cranges */
108 struct list_head qranges;
109 struct list_head cranges;
110 struct range_info *qr_cur, *cr_cur;
115 struct list_head head;
121 struct list_head head;
122 struct region_info regions;
123 struct avgs_info avgs;
132 unsigned int host, bus, target, lun;
133 char node[32], pci[32];
134 unsigned int irq, cpu;
139 struct list_head head, hash_head;
140 struct list_head iop_heads[N_IOP_TYPES];
141 struct region_info regions;
142 struct avgs_info avgs;
151 struct list_head all_head, dev_head;
156 struct blk_io_trace t;
158 int users, traversed;
173 struct { struct io *x_q; } x;
174 struct { struct io *a_q; } a;
175 struct { struct io *m_q; } m;
176 struct { struct list_head i_qs_head; } i;
177 struct { struct list_head d_im_head; } d;
178 struct { struct io *c_d; } c;
179 struct { struct io *y_c1, *y_c2; } y;
183 extern char bt_timeline_version[], *devices, *exes, *input_name, *output_name;
184 extern char *seek_name;
185 extern double range_delta;
186 extern FILE *ranges_ofp, *avgs_ofp;
187 extern int is_lvm, verbose, ifd;
188 extern unsigned int n_devs;
189 extern unsigned long n_traces, n_io_allocs, n_io_frees;
190 extern struct list_head all_devs, all_ios, all_procs;
191 extern struct avgs_info all_avgs;
193 extern struct region_info all_regions;
194 extern struct my_mem *free_ios, *free_bits;
195 extern char iop_map[];
196 extern unsigned int pending_xs;
198 void add_trace(struct io *iop);
199 int in_devices(struct blk_io_trace *t);
200 int output_avgs(FILE *ofp);
201 int output_ranges(FILE *ofp);
202 unsigned int do_read(int ifd, void *buf, int len);
203 void add_process(__u32 pid, char *name);
204 struct p_info *find_process(__u32 pid, char *name);
205 void pip_update_q(struct io *iop);
206 void handle_args(int argc, char *argv[]);
207 struct devmap *dev_map_find(__u32 device);
208 int dev_map_read(char *fname);
209 void add_cy(struct io *iop);
210 void rem_c(struct io *iop);
212 void cy_shutdown(void);
213 struct d_info *__dip_find(__u32 device);
214 struct d_info *dip_add(__u32 device, struct io *iop);
215 void traverse(struct io *iop);
216 void io_free_resources(struct io *iop);
217 void *seeki_init(__u32 device);
218 void seeki_add(void *handle, struct io *iop);
219 double seeki_mean(void *handle);
220 long long seeki_nseeks(void *handle);
221 long long seeki_median(void *handle);
222 int seeki_mode(void *handle, long long **modes_p, int *nseeks_p);