2 * Copyright (C) 2012 Fusion-io
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * Parts of this file were imported from Jens Axboe's blktrace sources (also GPL)
19 #ifndef __IOWATCH_BLKPARSE__
20 #define __IOWATCH_BLKPARSE__
22 #define MINORMASK ((1 << MINORBITS) - 1)
23 #define SECONDS(x) ((unsigned long long)(x) / 1000000000)
24 #define NANO_SECONDS(x) ((unsigned long long)(x) % 1000000000)
25 #define DOUBLE_TO_NANO_ULL(d) ((unsigned long long)((d) * 1000000000))
26 #define CHECK_MAGIC(t) (((t)->magic & 0xffffff00) == BLK_IO_TRACE_MAGIC)
35 #define MAX_DEVICES_PER_TRACE 64
42 struct blk_io_trace *io;
44 struct timespec abs_start_time;
47 * flags for the things we find in the stream
48 * we prefer different events for different things
67 struct dev_info devices[MAX_DEVICES_PER_TRACE];
71 struct list_head list;
75 int stop_seconds; /* Time when trace stops */
76 int min_seconds; /* Beginning of the interval we should plot */
77 int max_seconds; /* End of the interval we should plot */
85 struct graph_line_data *tput_writes_gld;
86 struct graph_line_data *tput_reads_gld;
87 struct graph_line_data *iop_gld;
88 struct graph_line_data *latency_gld;
89 struct graph_line_data *queue_depth_gld;
92 struct graph_line_data *fio_gld;
94 /* Number of entries in gdd_writes / gdd_reads */
97 /* Allocated array size for gdd_writes / gdd_reads */
98 int io_plots_allocated;
99 struct graph_dot_data **gdd_writes;
100 struct graph_dot_data **gdd_reads;
102 int mpstat_min_seconds;
103 int mpstat_max_seconds;
104 int mpstat_stop_seconds;
105 struct graph_line_data **mpstat_gld;
108 static inline unsigned int MAJOR(unsigned int dev)
110 return dev >> MINORBITS;
113 static inline unsigned int MINOR(unsigned int dev)
115 return dev & MINORMASK;
118 void init_io_hash_table(void);
119 void init_process_hash_table(void);
120 struct trace *open_trace(char *filename);
121 u64 find_last_time(struct trace *trace);
122 void find_extreme_offsets(struct trace *trace, u64 *min_ret, u64 *max_ret,
123 u64 *max_bank_ret, u64 *max_offset_ret);
124 int filter_outliers(struct trace *trace, u64 min_offset, u64 max_offset,
125 u64 *yzoom_min, u64 *yzoom_max);
126 int action_char_to_num(char action);
127 void add_iop(struct trace *trace, struct graph_line_data *gld);
128 void check_record(struct trace *trace);
129 void add_completed_io(struct trace *trace,
130 struct graph_line_data *latency_gld);
131 void add_io(struct trace *trace, struct trace_file *tf);
132 void add_tput(struct trace *trace, struct graph_line_data *writes_gld,
133 struct graph_line_data *reads_gld);
134 void add_pending_io(struct trace *trace, struct graph_line_data *gld);
135 int next_record(struct trace *trace);
136 void first_record(struct trace *trace);