Skip to content

Commit

Permalink
Added a 'hack' to enable/disable PRIO based on the user preference on…
Browse files Browse the repository at this point in the history
… how many IOs (percentage) should be of higher priority.
  • Loading branch information
xahmad committed Mar 31, 2017
1 parent e88315b commit c45abda
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions engines/libaio.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ struct libaio_data {
struct libaio_options {
void *pad;
unsigned int userspace_reap;
unsigned int prio_percent;
unsigned int prio_io_count;
};

static struct fio_option options[] = {
Expand All @@ -53,6 +55,17 @@ static struct fio_option options[] = {
.category = FIO_OPT_C_ENGINE,
.group = FIO_OPT_G_LIBAIO,
},
{
.name = "prio_percent",
.lname = "prio percentage",
.type = FIO_OPT_INT,
.off1 = offsetof(struct libaio_options, prio_percent),
.minval = 1,
.maxval = 100,
.help = "Split the prioclass setting for IO",
.category = FIO_OPT_C_ENGINE,
.group = FIO_OPT_G_LIBAIO,
},
{
.name = NULL,
},
Expand Down Expand Up @@ -241,6 +254,8 @@ static int fio_libaio_commit(struct thread_data *td)
struct libaio_data *ld = td->io_ops_data;
struct iocb **iocbs;
struct io_u **io_us;
struct thread_options *o = &td->o;
struct libaio_options *eo = td->eo;
struct timeval tv;
int ret, wait_start = 0;

Expand All @@ -254,6 +269,22 @@ static int fio_libaio_commit(struct thread_data *td)
io_us = ld->io_us + ld->tail;
iocbs = ld->iocbs + ld->tail;

if (fio_option_is_set(o, ioprio) ||
fio_option_is_set(o, ioprio_class)) {

if (eo->prio_percent) {
if ((++eo->prio_io_count % 100/eo->prio_percent) == 0) {
dprint(FD_IO, "Enable PRIO \n");
ioprio_set(IOPRIO_WHO_PROCESS, 0, o->ioprio_class, o->ioprio);
}
else
{
dprint(FD_IO, "Disable PRIO \n");
ioprio_set(IOPRIO_WHO_PROCESS, 0, 0, 0);
}
}
}

ret = io_submit(ld->aio_ctx, nr, iocbs);
if (ret > 0) {
fio_libaio_queued(td, io_us, ret);
Expand Down Expand Up @@ -363,6 +394,8 @@ static int fio_libaio_init(struct thread_data *td)
ld->iocbs = calloc(ld->entries, sizeof(struct iocb *));
ld->io_us = calloc(ld->entries, sizeof(struct io_u *));

o->prio_io_count = 0;

td->io_ops_data = ld;
return 0;
}
Expand Down

0 comments on commit c45abda

Please sign in to comment.