From: Jens Axboe Date: Mon, 19 Nov 2018 23:11:56 +0000 (-0700) Subject: engines/libaio: update to new io_setup2() system call X-Git-Tag: fio-3.13~110 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=ebec344dd336784fe8c15fa042649a5e768af63d engines/libaio: update to new io_setup2() system call We need that to enable polling. Signed-off-by: Jens Axboe --- diff --git a/arch/arch-x86_64.h b/arch/arch-x86_64.h index 484ea0c5..6361d52f 100644 --- a/arch/arch-x86_64.h +++ b/arch/arch-x86_64.h @@ -1,6 +1,10 @@ #ifndef ARCH_X86_64_H #define ARCH_X86_64_H +#ifndef __NR_sys_iosetup2 +#define __NR_sys_iosetup2 335 +#endif + static inline void do_cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) { diff --git a/engines/libaio.c b/engines/libaio.c index dc664627..da7f0c3e 100644 --- a/engines/libaio.c +++ b/engines/libaio.c @@ -16,6 +16,9 @@ #ifndef IOCB_FLAG_HIPRI #define IOCB_FLAG_HIPRI (1 << 2) #endif +#ifndef IOCTX_FLAG_IOPOLL +#define IOCTX_FLAG_IOPOLL (1 << 0) +#endif static int fio_libaio_commit(struct thread_data *td); @@ -354,6 +357,25 @@ static void fio_libaio_cleanup(struct thread_data *td) } } +static int fio_libaio_queue_init(struct libaio_data *ld, unsigned int depth, + bool hipri) +{ +#ifdef __NR_sys_io_setup2 + int err, flags = 0; + + if (hipri) + flags = IOCTX_FLAG_IOPOLL; + + return syscall(__NR_sys_io_setup2, depth, flags, &ld->aio_ctx); +#else + if (hipri) { + log_err("fio: polled aio not available on your platform\n"); + return 1; + } + return io_queue_init(depth, &ld->aio_ctx); +#endif +} + static int fio_libaio_init(struct thread_data *td) { struct libaio_options *o = td->eo; @@ -368,9 +390,9 @@ static int fio_libaio_init(struct thread_data *td) * and we need the right depth. */ if (!o->userspace_reap) - err = io_queue_init(INT_MAX, &ld->aio_ctx); + err = fio_libaio_queue_init(ld, INT_MAX, o->hipri); if (o->userspace_reap || err == -EINVAL) - err = io_queue_init(td->o.iodepth, &ld->aio_ctx); + err = fio_libaio_queue_init(ld, td->o.iodepth, o->hipri); if (err) { td_verror(td, -err, "io_queue_init"); log_err("fio: check /proc/sys/fs/aio-max-nr\n");