All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <kch@nvidia.com>
To: <io-uring@vger.kernel.org>
Cc: <axboe@kernel.dk>, <asml.silence@gmail.com>,
	Chaitanya Kulkarni <kch@nvidia.com>
Subject: [RFC PATCH 0/1] io_uring: honor I/O nowait flag for read/write
Date: Fri, 21 Apr 2023 10:28:21 -0700	[thread overview]
Message-ID: <20230421172822.8053-1-kch@nvidia.com> (raw)

Hi,

When IO_URING_F_NONBLOCK is set on io_kiocb req->flag in io_write() or
io_read() IOCB_NOWAIT is set for kiocb when passed it to the respective
rw_iter callback. This sets REQ_NOWAIT for underlaying I/O. The result
is low level driver always sees block layer request as REQ_NOWAIT even
if user has submitted request with nowait = 0 e.g. fio nowait=0.

That is not consistent behaviour with other fio ioengine such as
libaio as it will issue non REQ_NOWAIT request with REQ_NOWAIT:-

libaio nowait = 0:-
null_blk: fio:null_handle_rq 1288 *NOWAIT=FALSE* REQ_OP_WRITE

libaio nowait = 1:-
null_blk: fio:null_handle_rq 1288 *NOWAIT=TRUE* REQ_OP_WRITE

* Without this patch with fio ioengine io_uring :-
---------------------------------------------------

iouring nowait = 0:-
null_blk: fio:null_handle_rq 1288 *NOWAIT=TRUE* REQ_OP_WRITE

iouring nowait = 1:-
null_blk: fio:null_handle_rq 1288 *NOWAIT=TRUE* REQ_OP_WRITE

* With this patch with fio ioengine io_uring :-
---------------------------------------------------

iouring nowait = 0:-
null_blk: fio:null_handle_rq 1307 *REQ_NOWAIT=FALSE* WRITE

iouring nowait = 1:
null_blk: fio:null_handle_rq 1307 *REQ_NOWAIT=TRUE* WRITE

Instead of only relying on IO_URING_F_NONBLOCK blindly in io_read() and
io_write(), also make sure io_kiocb->io_rw->flags is set to RWF_NOWAIT
before we mark kiocb->ki_flags = IOCB_NOWAIT.

Below is the deatailed testing log.

-ck

Chaitanya Kulkarni (1):
  io_uring: honor I/O nowait flag for read/write

 io_uring/rw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

$ sh test-iouring-no-wait
* Without this patch :-
#######################
-------------------libaio nowait = 0--------------------------

++ grep -e ioengine -e rw -e nowait fio/randwrite-libaio-nowait-0.fio
ioengine=libaio
rw=randwrite
nowait=0   <-----------------------------
overwrite=0
++ fio fio/randwrite-libaio-nowait-0.fio --filename=/dev/nullb0
++ grep err
RANDWRITE: (groupid=0, jobs=1): err= 0: pid=40835: Thu Apr 20 21:31:09 2023
++ dmesg -c
[17978.613789] null_blk: disk nullb0 created
[17978.613814] null_blk: module loaded
__________________________________________________________________________
[17978.796560] null_blk: fio:null_handle_rq 1288 *NOWAIT=FALSE* REQ_OP_WRITE

-------------------libaio nowait = 1--------------------------

++ blkdiscard /dev/nullb0
++ grep -e ioengine -e rw -e nowait fio/randwrite-libaio-nowait-1.fio
ioengine=libaio
rw=randwrite
nowait=1   <-----------------------------
overwrite=0
++ fio fio/randwrite-libaio-nowait-1.fio --filename=/dev/nullb0
++ grep err
RANDWRITE: (groupid=0, jobs=1): err= 0: pid=40842: Thu Apr 20 21:31:09 2023
++ dmesg -c
__________________________________________________________________________
[17979.019595] null_blk: fio:null_handle_rq 1288 *NOWAIT=TRUE* REQ_OP_WRITE

-------------------iouring nowait = 0--------------------------

++ blkdiscard /dev/nullb0
++ grep -e ioengine -e rw -e nowait fio/randwrite-iouring-nowait-0.fio
ioengine=io_uring
rw=randwrite
nowait=0   <-----------------------------
overwrite=0
++ fio fio/randwrite-iouring-nowait-0.fio --filename=/dev/nullb0
++ grep err
RANDWRITE: (groupid=0, jobs=1): err= 0: pid=40849: Thu Apr 20 21:31:10 2023
++ dmesg -c
__________________________________________________________________________
[17979.242849] null_blk: fio:null_handle_rq 1288 *NOWAIT=TRUE* REQ_OP_WRITE

-------------------iouring nowait = 1--------------------------

++ blkdiscard /dev/nullb0
++ grep -e ioengine -e rw -e nowait fio/randwrite-iouring-nowait-1.fio
ioengine=io_uring
rw=randwrite
nowait=1   <-----------------------------
overwrite=0
++ fio fio/randwrite-iouring-nowait-1.fio --filename=/dev/nullb0
++ grep err
RANDWRITE: (groupid=0, jobs=1): err= 0: pid=40856: Thu Apr 20 21:31:10 2023
++ dmesg -c
__________________________________________________________________________
[17979.454102] null_blk: fio:null_handle_rq 1288 *NOWAIT=TRUE* REQ_OP_WRITE

* With this patch :-
####################
-------------------iouring nowait = 0--------------------------
+ blkdiscard /dev/nullb0
+ grep -e ioengine -e rw -e nowait fio/randwrite-iouring-nowait-0.fio
ioengine=io_uring
rw=randwrite
nowait=0   <-----------------------------
overwrite=0
+ fio fio/randwrite-iouring-nowait-0.fio --filename=/dev/nullb0
+ grep err
RANDWRITE: (groupid=0, jobs=1): err= 0: pid=2788: Thu Apr 20 23:35:40 2023
+ dmesg -c
__________________________________________________________________________
[  164.255136] null_blk: fio:null_handle_rq 1307 *REQ_NOWAIT=FALSE* WRITE
-------------------iouring nowait = 1--------------------------
+ blkdiscard /dev/nullb0
+ grep -e ioengine -e rw -e nowait fio/randwrite-iouring-nowait-1.fio
ioengine=io_uring
rw=randwrite
nowait=1   <-----------------------------
overwrite=0
+ fio fio/randwrite-iouring-nowait-1.fio --filename=/dev/nullb0
+ grep err
RANDWRITE: (groupid=0, jobs=1): err= 0: pid=2795: Thu Apr 20 23:35:41 2023
+ dmesg -c
__________________________________________________________________________
[  164.467420] null_blk: fio:null_handle_rq 1307 *REQ_NOWAIT=TRUE* WRITE


-- 
2.40.0


             reply	other threads:[~2023-04-21 17:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21 17:28 Chaitanya Kulkarni [this message]
2023-04-21 17:28 ` [RFC PATCH 1/1] io_uring: honor I/O nowait flag for read/write Chaitanya Kulkarni
2023-04-21 17:35   ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230421172822.8053-1-kch@nvidia.com \
    --to=kch@nvidia.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.