iowatcher: Make seconds unsigned
[blktrace.git] / iowatcher / blkparse.h
CommitLineData
9e066e23
CM
1/*
2 * Copyright (C) 2012 Fusion-io
3 *
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.
7 *
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.
12 *
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
660b0411 15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
9e066e23
CM
16 *
17 * Parts of this file were imported from Jens Axboe's blktrace sources (also GPL)
18 */
19#ifndef __IOWATCH_BLKPARSE__
20#define __IOWATCH_BLKPARSE__
21#define MINORBITS 20
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)
27
2203e914
CM
28struct dev_info {
29 u32 device;
30 u64 min;
31 u64 max;
32 u64 map;
33};
34
35#define MAX_DEVICES_PER_TRACE 64
36
9e066e23
CM
37struct trace {
38 int fd;
39 u64 len;
40 char *start;
41 char *cur;
42 struct blk_io_trace *io;
43 u64 start_timestamp;
44 struct timespec abs_start_time;
45
46 /*
47 * flags for the things we find in the stream
48 * we prefer different events for different things
49 */
50 int found_issue;
51 int found_completion;
52 int found_queue;
e199d546
CM
53
54 char *mpstat_start;
55 char *mpstat_cur;
56 u64 mpstat_len;
57 int mpstat_fd;
58 int mpstat_seconds;
59 int mpstat_num_cpus;
24e48e03
CM
60
61 char *fio_start;
62 char *fio_cur;
63 u64 fio_len;
64 int fio_fd;
65 int fio_seconds;
2203e914
CM
66 int num_devices;
67 struct dev_info devices[MAX_DEVICES_PER_TRACE];
9e066e23
CM
68};
69
0a43b43f
JK
70struct trace_file {
71 struct list_head list;
72 char *filename;
73 char *label;
74 struct trace *trace;
22dd439a
JK
75 unsigned int stop_seconds; /* Time when trace stops */
76 unsigned int min_seconds; /* Beginning of the interval we should plot */
77 unsigned int max_seconds; /* End of the interval we should plot */
0a43b43f
JK
78 u64 min_offset;
79 u64 max_offset;
80
2203e914
CM
81 char *reads_color;
82 char *writes_color;
0a43b43f
JK
83 char *line_color;
84
2203e914
CM
85 struct graph_line_data *tput_writes_gld;
86 struct graph_line_data *tput_reads_gld;
0a43b43f
JK
87 struct graph_line_data *iop_gld;
88 struct graph_line_data *latency_gld;
89 struct graph_line_data *queue_depth_gld;
24e48e03
CM
90
91 int fio_trace;
92 struct graph_line_data *fio_gld;
93
0a43b43f
JK
94 /* Number of entries in gdd_writes / gdd_reads */
95 int io_plots;
24e48e03 96
0a43b43f
JK
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;
101
22dd439a
JK
102 unsigned int mpstat_min_seconds;
103 unsigned int mpstat_max_seconds;
104 unsigned int mpstat_stop_seconds;
0a43b43f
JK
105 struct graph_line_data **mpstat_gld;
106};
107
9e066e23
CM
108static inline unsigned int MAJOR(unsigned int dev)
109{
110 return dev >> MINORBITS;
111}
112
113static inline unsigned int MINOR(unsigned int dev)
114{
115 return dev & MINORMASK;
116}
117
118void init_io_hash_table(void);
0a43b43f 119void init_process_hash_table(void);
9e066e23
CM
120struct trace *open_trace(char *filename);
121u64 find_last_time(struct trace *trace);
9b9fa04b
JK
122void find_extreme_offsets(struct trace *trace, u64 *min_ret, u64 *max_ret,
123 u64 *max_bank_ret, u64 *max_offset_ret);
124int filter_outliers(struct trace *trace, u64 min_offset, u64 max_offset,
9e066e23 125 u64 *yzoom_min, u64 *yzoom_max);
f2e40ddd 126int action_char_to_num(char action);
9e066e23
CM
127void add_iop(struct trace *trace, struct graph_line_data *gld);
128void check_record(struct trace *trace);
129void add_completed_io(struct trace *trace,
130 struct graph_line_data *latency_gld);
0a43b43f 131void add_io(struct trace *trace, struct trace_file *tf);
2203e914
CM
132void add_tput(struct trace *trace, struct graph_line_data *writes_gld,
133 struct graph_line_data *reads_gld);
9e066e23
CM
134void add_pending_io(struct trace *trace, struct graph_line_data *gld);
135int next_record(struct trace *trace);
6a079b02 136u64 get_record_time(struct trace *trace);
9e066e23
CM
137void first_record(struct trace *trace);
138#endif