aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2013-04-04 06:18:25 -0400
committerChris Mason <chris.mason@fusionio.com>2013-09-24 15:30:52 -0400
commited4edfef9d547df0222b7c491678b507695f92a9 (patch)
tree4a69aa01323a5f78155b0a662fb861e2dcf8e958
parentf57ca6aa2bbfbd0c9412010a6cadbd39926ff347 (diff)
downloadiowatcher-ed4edfef9d547df0222b7c491678b507695f92a9.tar.gz
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--blkparse.c16
-rw-r--r--blkparse.h1
-rw-r--r--main.c9
3 files changed, 11 insertions, 15 deletions
diff --git a/blkparse.c b/blkparse.c
index d27b547..c70b1bd 100644
--- a/blkparse.c
+++ b/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/blkparse.h b/blkparse.h
index 84bda4a..1c93a25 100644
--- a/blkparse.h
+++ b/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/main.c b/main.c
index 0d485f3..b05c693 100644
--- a/main.c
+++ b/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;