From cb5ab5121ac4fa62e0ca2612b359f19bfdd30f29 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 26 Feb 2007 12:57:09 +0100 Subject: [PATCH] Add iodepth_batch setting This allows controlling how much IO we submit in one go independent of the iodepth set. Signed-off-by: Jens Axboe --- HOWTO | 4 ++++ fio.c | 2 ++ fio.h | 2 ++ init.c | 12 ++++++++++++ ioengines.c | 5 +++++ 5 files changed, 25 insertions(+) diff --git a/HOWTO b/HOWTO index 237b3ad2..de4b0a99 100644 --- a/HOWTO +++ b/HOWTO @@ -294,6 +294,10 @@ iodepth=int This defines how many io units to keep in flight against job, can be overridden with a larger value for higher concurrency. +iodepth_batch=int This defines how many pieces of IO to submit at once. + It defaults to the same as iodepth, but can be set lower + if one so desires. + iodepth_low=int The low water mark indicating when to start filling the queue again. Defaults to the same as iodepth, meaning that fio will attempt to keep the queue full at all times. diff --git a/fio.c b/fio.c index b095527e..c5b85aeb 100644 --- a/fio.c +++ b/fio.c @@ -433,6 +433,8 @@ requeue: */ if (td->io_ops->commit == NULL) io_u_queued(td, io_u); + else if (td->io_u_queued >= td->iodepth_batch) + ret = td_io_commit(td); break; case FIO_Q_BUSY: requeue_io_u(td, &io_u); diff --git a/fio.h b/fio.h index 57d1b6b9..6d0c9e31 100644 --- a/fio.h +++ b/fio.h @@ -351,6 +351,7 @@ struct thread_data { unsigned int numjobs; unsigned int iodepth; unsigned int iodepth_low; + unsigned int iodepth_batch; os_cpu_mask_t cpumask; unsigned int iolog; unsigned int read_iolog; @@ -389,6 +390,7 @@ struct thread_data { struct list_head io_u_freelist; struct list_head io_u_busylist; struct list_head io_u_requeues; + unsigned int io_u_queued; /* * Rate state diff --git a/init.c b/init.c index 8efb24ab..636e9576 100644 --- a/init.c +++ b/init.c @@ -112,6 +112,12 @@ static struct fio_option options[] = { .help = "Amount of IO buffers to keep in flight", .def = "1", }, + { + .name = "iodepth_batch", + .type = FIO_OPT_INT, + .off1 = td_var_offset(iodepth_batch), + .help = "Number of IO to submit in one go", + }, { .name = "iodepth_low", .type = FIO_OPT_INT, @@ -704,6 +710,12 @@ static void fixup_options(struct thread_data *td) */ if (td->iodepth_low > td->iodepth || !td->iodepth_low) td->iodepth_low = td->iodepth; + + /* + * If batch number isn't set, default to the same as iodepth + */ + if (td->iodepth_batch > td->iodepth || !td->iodepth_batch) + td->iodepth_batch = td->iodepth; } /* diff --git a/ioengines.c b/ioengines.c index 727981f1..2cc32888 100644 --- a/ioengines.c +++ b/ioengines.c @@ -216,6 +216,9 @@ int td_io_queue(struct thread_data *td, struct io_u *io_u) ret = td->io_ops->queue(td, io_u); + if (ret == FIO_Q_QUEUED) + td->io_u_queued++; + if ((td->io_ops->flags & FIO_SYNCIO) == 0) { fio_gettime(&io_u->issue_time, NULL); @@ -242,6 +245,8 @@ int td_io_commit(struct thread_data *td) { if (!td->cur_depth) return 0; + + td->io_u_queued = 0; if (td->io_ops->commit) return td->io_ops->commit(td); -- 2.25.1