diff options
author | Jan Kara <jack@suse.cz> | 2013-04-04 06:18:25 -0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-09-24 12:02:08 -0700 |
commit | 6a079b020a3e57aec95766cd8b97f15962af4674 (patch) | |
tree | c9a4a4d22a0df2272d63fcb1fbce765fe0d7472f | |
parent | 7c883a9412d9dad32c23084c86272602bb7ffd5c (diff) | |
download | blktrace-6a079b020a3e57aec95766cd8b97f15962af4674.tar.gz |
iowatcher: Skip events beyond max_seconds
Skip events beyond max_seconds. This not only saves CPU time but also
prevents memory corruption because not all functions were checking that
given time is in the expected range. Also remove now unnecessary checks
in the called functions.
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r-- | iowatcher/blkparse.c | 16 | ||||
-rw-r--r-- | iowatcher/blkparse.h | 1 | ||||
-rw-r--r-- | iowatcher/main.c | 9 |
3 files changed, 11 insertions, 15 deletions
diff --git a/iowatcher/blkparse.c b/iowatcher/blkparse.c index d27b547..c70b1bd 100644 --- a/iowatcher/blkparse.c +++ b/iowatcher/blkparse.c @@ -188,6 +188,11 @@ struct pid_map { #define DOUBLE_TO_NANO_ULL(d) ((unsigned long long)((d) * 1000000000)) #define CHECK_MAGIC(t) (((t)->magic & 0xffffff00) == BLK_IO_TRACE_MAGIC) +u64 get_record_time(struct trace *trace) +{ + return trace->io->time; +} + void init_io_hash_table(void) { int i; @@ -960,9 +965,6 @@ void add_tput(struct trace *trace, struct graph_line_data *writes_gld, gld = writes_gld; seconds = SECONDS(io->time); - if (seconds > gld->max_seconds) - return; - gld->data[seconds].sum += io->bytes; gld->data[seconds].count = 1; @@ -1060,10 +1062,6 @@ void add_pending_io(struct trace *trace, struct graph_line_data *gld) if (action != __BLK_TA_ISSUE) return; - seconds = SECONDS(io->time); - if (seconds > gld->max_seconds) - return; - pio = hash_dispatched_io(trace->io); if (!pio) return; @@ -1075,6 +1073,7 @@ void add_pending_io(struct trace *trace, struct graph_line_data *gld) ios_in_flight++; + seconds = SECONDS(io->time); gld->data[seconds].sum += ios_in_flight; gld->data[seconds].count++; @@ -1138,9 +1137,6 @@ void add_iop(struct trace *trace, struct graph_line_data *gld) return; seconds = SECONDS(io->time); - if (seconds > gld->max_seconds) - return; - gld->data[seconds].sum += 1; gld->data[seconds].count = 1; if (gld->data[seconds].sum > gld->max) diff --git a/iowatcher/blkparse.h b/iowatcher/blkparse.h index 84bda4a..1c93a25 100644 --- a/iowatcher/blkparse.h +++ b/iowatcher/blkparse.h @@ -133,5 +133,6 @@ void add_tput(struct trace *trace, struct graph_line_data *writes_gld, struct graph_line_data *reads_gld); void add_pending_io(struct trace *trace, struct graph_line_data *gld); int next_record(struct trace *trace); +u64 get_record_time(struct trace *trace); void first_record(struct trace *trace); #endif diff --git a/iowatcher/main.c b/iowatcher/main.c index a419324..694304c 100644 --- a/iowatcher/main.c +++ b/iowatcher/main.c @@ -426,17 +426,16 @@ static void read_trace_events(void) trace = tf->trace; first_record(trace); - while (1) { + do { + if (SECONDS(get_record_time(trace)) > tf->max_seconds) + continue; check_record(trace); add_tput(trace, tf->tput_writes_gld, tf->tput_reads_gld); add_iop(trace, tf->iop_gld); add_io(trace, tf); add_pending_io(trace, tf->queue_depth_gld); add_completed_io(trace, tf->latency_gld); - ret = next_record(trace); - if (ret) - break; - } + } while (!(ret = next_record(trace))); } list_for_each_entry(tf, &all_traces, list) { trace = tf->trace; |