Add max_latency option
authorJens Axboe <axboe@kernel.dk>
Wed, 24 Oct 2012 14:37:45 +0000 (16:37 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 24 Oct 2012 14:37:45 +0000 (16:37 +0200)
If set, fio will exit if it sees a total IO latency that exceeds
this value.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
HOWTO
fio.1
fio.h
io_u.c
options.c

diff --git a/HOWTO b/HOWTO
index 8eda99d00bd057a8199107e5508a5fa7d3ebd415..a7bd1fb07da4a9ad872e054958ee39514fadc0dc 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -780,6 +780,9 @@ rate_iops_min=int If fio doesn't meet this rate of IO, it will cause
                the job to exit. The same format as rate is used for read vs
                write seperation.
 
                the job to exit. The same format as rate is used for read vs
                write seperation.
 
+max_latency=int        If set, fio will exit the job if it exceeds this maximum
+               latency. It will exit with an ETIME error.
+
 ratecycle=int  Average bandwidth for 'rate' and 'ratemin' over this number
                of milliseconds.
 
 ratecycle=int  Average bandwidth for 'rate' and 'ratemin' over this number
                of milliseconds.
 
diff --git a/fio.1 b/fio.1
index bf65551811a91b931ba66ebddda7392dc41e2133..08d6c0f4ba3da66191ba855de21f60a4ed0b838c 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -639,6 +639,10 @@ is used for read vs write seperation.
 Average bandwidth for \fBrate\fR and \fBratemin\fR over this number of
 milliseconds.  Default: 1000ms.
 .TP
 Average bandwidth for \fBrate\fR and \fBratemin\fR over this number of
 milliseconds.  Default: 1000ms.
 .TP
+.BI max_latency \fR=\fPint
+If set, fio will exit the job if it exceeds this maximum latency. It will exit
+with an ETIME error.
+.TP
 .BI cpumask \fR=\fPint
 Set CPU affinity for this job. \fIint\fR is a bitmask of allowed CPUs the job
 may run on.  See \fBsched_setaffinity\fR\|(2).
 .BI cpumask \fR=\fPint
 Set CPU affinity for this job. \fIint\fR is a bitmask of allowed CPUs the job
 may run on.  See \fBsched_setaffinity\fR\|(2).
diff --git a/fio.h b/fio.h
index 03e4da1427d251fa5059900cfda102aba411f444..139b9383f9fbd3ebaf1598b77ecbce244926465a 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -198,6 +198,8 @@ struct thread_options {
        enum fio_memtype mem_type;
        unsigned int mem_align;
 
        enum fio_memtype mem_type;
        unsigned int mem_align;
 
+       unsigned int max_latency;
+
        unsigned int stonewall;
        unsigned int new_group;
        unsigned int numjobs;
        unsigned int stonewall;
        unsigned int new_group;
        unsigned int numjobs;
diff --git a/io_u.c b/io_u.c
index e047677e1b507d0923dfe781f5c354f63248a62c..b049b61853fdfbd305ad01d857046be88dc68671 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -1325,6 +1325,13 @@ static void account_io_completion(struct thread_data *td, struct io_u *io_u,
 
                tusec = utime_since(&io_u->start_time, &icd->time);
                add_lat_sample(td, idx, tusec, bytes);
 
                tusec = utime_since(&io_u->start_time, &icd->time);
                add_lat_sample(td, idx, tusec, bytes);
+
+               if (td->o.max_latency && tusec > td->o.max_latency) {
+                       if (!td->error)
+                               log_err("fio: latency of %lu usec exceeds specified max (%u usec)\n", tusec, td->o.max_latency);
+                       td_verror(td, ETIME, "max latency exceeded");
+                       icd->error = ETIME;
+               }
        }
 
        if (!td->o.disable_clat) {
        }
 
        if (!td->o.disable_clat) {
index e0b7fec2e4970bcd383451c74a6da53dd803984b..380df36afd29f527d33d3949930ebe5f33d676a9 100644 (file)
--- a/options.c
+++ b/options.c
@@ -2098,6 +2098,12 @@ static struct fio_option options[FIO_MAX_OPTS] = {
                .def    = "1000",
                .parent = "rate",
        },
                .def    = "1000",
                .parent = "rate",
        },
+       {
+               .name   = "max_latency",
+               .type   = FIO_OPT_INT,
+               .off1   = td_var_offset(max_latency),
+               .help   = "Maximum tolerated IO latency (usec)",
+       },
        {
                .name   = "invalidate",
                .type   = FIO_OPT_BOOL,
        {
                .name   = "invalidate",
                .type   = FIO_OPT_BOOL,