Skip to content

Commit bce7dd2

Browse files
committed
Teach posixaio about iodepth_batch_complete_max.
The posixaio engine prevously ignored iodepth_batch_complete_max and polled the whole set of in flight IOs. To enable apples-for-apples comparisons with other engines (such as posixaio_waitcomplete), provide a new option --posixaio_respect_iodepth_batch_complete_max. Not enabled by default, so as not to change any results unexpectedly. Signed-off-by: Thomas Munro <[email protected]>
1 parent 7a7897a commit bce7dd2

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

HOWTO

+9
Original file line numberDiff line numberDiff line change
@@ -1944,6 +1944,7 @@ I/O engine
19441944
**posixaio**
19451945
POSIX asynchronous I/O using :manpage:`aio_read(3)` and
19461946
:manpage:`aio_write(3)`.
1947+
This engine defines engine specific options.
19471948

19481949
**posixaio_waitcomplete**
19491950
POSIX asynchronous I/O, using FreeBSD's
@@ -2609,6 +2610,14 @@ with the caveat that when used on the command line, they must come after the
26092610

26102611
If set, stdout and stderr streams are redirected to files named from the job name. Default is true.
26112612

2613+
.. options:: posixaio_respect_iodepth_batch_complete_max=bool : [posixaio]
2614+
2615+
If set, limit batch completions according to
2616+
:option:`iodepth_batch_complete_max`, as other engines do. Default is
2617+
false, effectively behaving as though
2618+
:option:`iodepth_batch_complete_max` has the same value as
2619+
:option:`iodepth`.
2620+
26122621
I/O depth
26132622
~~~~~~~~~
26142623

engines/posixaio.c

+28
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,34 @@
1111
#include <fcntl.h>
1212

1313
#include "../fio.h"
14+
#include "../optgroup.h"
1415

1516
struct posixaio_data {
1617
struct io_u **aio_events;
1718
unsigned int queued;
1819
};
1920

21+
struct posixaio_options {
22+
void *pad;
23+
unsigned int respect_iodepth_batch_complete_max;
24+
};
25+
26+
static struct fio_option options[] = {
27+
{
28+
.name = "posixaio_respect_iodepth_batch_complete_max",
29+
.lname = "Respect iodepth_batch_complete_max",
30+
.type = FIO_OPT_BOOL,
31+
.off1 = offsetof(struct posixaio_options, respect_iodepth_batch_complete_max),
32+
.help = "Whether to cap batch completion",
33+
.def = "0",
34+
.category = FIO_OPT_C_ENGINE,
35+
.group = FIO_OPT_G_POSIXAIO,
36+
},
37+
{
38+
.name = NULL,
39+
},
40+
};
41+
2042
static unsigned long long ts_utime_since_now(const struct timespec *start)
2143
{
2244
struct timespec now;
@@ -114,6 +136,7 @@ static int fio_posixaio_getevents(struct thread_data *td, unsigned int min,
114136
unsigned int max, const struct timespec *t)
115137
{
116138
struct posixaio_data *pd = td->io_ops_data;
139+
struct posixaio_options *o = td->eo;
117140
os_aiocb_t *suspend_list[SUSPEND_ENTRIES];
118141
struct timespec start;
119142
int have_timeout = 0;
@@ -158,6 +181,9 @@ static int fio_posixaio_getevents(struct thread_data *td, unsigned int min,
158181
io_u->resid = io_u->xfer_buflen - retval;
159182
} else
160183
io_u->error = err;
184+
185+
if (o->respect_iodepth_batch_complete_max && r >= max)
186+
break;
161187
}
162188

163189
if (r >= min)
@@ -274,6 +300,8 @@ static struct ioengine_ops ioengine = {
274300
.open_file = generic_open_file,
275301
.close_file = generic_close_file,
276302
.get_file_size = generic_get_file_size,
303+
.options = options,
304+
.option_struct_size = sizeof(struct posixaio_options),
277305
};
278306

279307
#ifdef CONFIG_HAVE_AIO_WAITCOMPLETE

fio.1

+7
Original file line numberDiff line numberDiff line change
@@ -2372,6 +2372,13 @@ Defines the time between the SIGTERM and SIGKILL signals. Default is 1 second.
23722372
.TP
23732373
.BI (exec)std_redirect\fR=\fbool
23742374
If set, stdout and stderr streams are redirected to files named from the job name. Default is true.
2375+
.TP
2376+
.BI (posixaio)posixaio_respect_iodepth_batch_complete_max\fR=\fbool
2377+
If set, limit batch completions according to
2378+
\fBiodepth_batch_complete_max\fR, as other engines do. Default is
2379+
false, effectively setting
2380+
\fBiodepth_batch_complete_max\fR to the same value as
2381+
\fBiodepth\fR.
23752382
.SS "I/O depth"
23762383
.TP
23772384
.BI iodepth \fR=\fPint

optgroup.h

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ enum opt_category_group {
7171
__FIO_OPT_G_LIBCUFILE,
7272
__FIO_OPT_G_DFS,
7373
__FIO_OPT_G_NFS,
74+
__FIO_OPT_G_POSIXAIO,
7475

7576
FIO_OPT_G_RATE = (1ULL << __FIO_OPT_G_RATE),
7677
FIO_OPT_G_ZONE = (1ULL << __FIO_OPT_G_ZONE),
@@ -116,6 +117,7 @@ enum opt_category_group {
116117
FIO_OPT_G_FILESTAT = (1ULL << __FIO_OPT_G_FILESTAT),
117118
FIO_OPT_G_LIBCUFILE = (1ULL << __FIO_OPT_G_LIBCUFILE),
118119
FIO_OPT_G_DFS = (1ULL << __FIO_OPT_G_DFS),
120+
FIO_OPT_G_POSIXAIO = (1ULL << __FIO_OPT_G_POSIXAIO),
119121
};
120122

121123
extern const struct opt_group *opt_group_from_mask(uint64_t *mask);

0 commit comments

Comments
 (0)