Change IO latency histogram to be in power-of-10
[fio.git] / io_u.c
diff --git a/io_u.c b/io_u.c
index 645cba40b4f012096bafff178b697ecff0ec46aa..23a64b046861bcf13e68bf316fd5111593468ca4 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -289,23 +289,23 @@ static void io_u_mark_latency(struct thread_data *td, unsigned long msec)
        switch (msec) {
        default:
                index++;
-       case 1024 ... 2047:
+       case 1000 ... 1999:
                index++;
-       case 512 ... 1023:
+       case 750 ... 999:
                index++;
-       case 256 ... 511:
+       case 500 ... 749:
                index++;
-       case 128 ... 255:
+       case 250 ... 499:
                index++;
-       case 64 ... 127:
+       case 100 ... 249:
                index++;
-       case 32 ... 63:
+       case 50 ... 99:
                index++;
-       case 16 ... 31:
+       case 20 ... 49:
                index++;
-       case 8 ... 15:
+       case 10 ... 19:
                index++;
-       case 4 ... 7:
+       case 4 ... 9:
                index++;
        case 2 ... 3:
                index++;
@@ -379,7 +379,7 @@ struct io_u *get_io_u(struct thread_data *td)
         * from a requeue, io_u already setup
         */
        if (io_u->file)
-               return io_u;
+               goto out;
 
        f = get_next_file(td);
        if (!f) {
@@ -423,6 +423,7 @@ struct io_u *get_io_u(struct thread_data *td)
        /*
         * Set io data pointers.
         */
+out:
        io_u->xfer_buf = io_u->buf;
        io_u->xfer_buflen = io_u->buflen;
 
@@ -505,6 +506,9 @@ static void ios_completed(struct thread_data *td,
        }
 }
 
+/*
+ * Complete a single io_u for the sync engines.
+ */
 long io_u_sync_complete(struct thread_data *td, struct io_u *io_u,
                        endio_handler *handler)
 {
@@ -520,25 +524,30 @@ long io_u_sync_complete(struct thread_data *td, struct io_u *io_u,
        return -1;
 }
 
+/*
+ * Called to complete min_events number of io for the async engines.
+ */
 long io_u_queued_complete(struct thread_data *td, int min_events,
                          endio_handler *handler)
 
 {
-       struct timespec ts = { .tv_sec = 0, .tv_nsec = 0, };
-       struct timespec *tsp = NULL;
        struct io_completion_data icd;
+       struct timespec *tvp = NULL;
        int ret;
 
        if (min_events > 0) {
-               tsp = &ts;
                ret = td_io_commit(td);
                if (ret < 0) {
                        td_verror(td, -ret);
                        return ret;
                }
+       } else {
+               struct timespec ts = { .tv_sec = 0, .tv_nsec = 0, };
+
+               tvp = &ts;
        }
 
-       ret = td_io_getevents(td, min_events, td->cur_depth, tsp);
+       ret = td_io_getevents(td, min_events, td->cur_depth, tvp);
        if (ret < 0) {
                td_verror(td, -ret);
                return ret;
@@ -552,3 +561,14 @@ long io_u_queued_complete(struct thread_data *td, int min_events,
 
        return -1;
 }
+
+/*
+ * Call when io_u is really queued, to update the submission latency.
+ */
+void io_u_queued(struct thread_data *td, struct io_u *io_u)
+{
+       unsigned long slat_time;
+
+       slat_time = mtime_since(&io_u->start_time, &io_u->issue_time);
+       add_slat_sample(td, io_u->ddir, slat_time);
+}