mbox series

[V2,0/1] null_blk: allow user to set QUEUE_FLAG_NOWAIT

Message ID 20230418042420.93629-1-kch@nvidia.com (mailing list archive)
Headers show
Series null_blk: allow user to set QUEUE_FLAG_NOWAIT | expand

Message

Chaitanya Kulkarni April 18, 2023, 4:24 a.m. UTC
QUEUE_FLAG_NOWAIT is set by default to mq drivers such null_blk when
it is used with NULL_Q_MQ mode as a part of QUEUE_FLAG_MQ_DEFAULT that
gets assigned in following code path see blk_mq_init_allocated_queue():-

null_add_dev()
if (dev->queue_mode == NULL_Q_MQ) {
        blk_mq_alloc_disk()
          __blk_mq_alloc_disk()
	    blk_mq_init_queue_data()
              blk_mq_init_allocated_queue()
                q->queue_flags |= QUEUE_FLAG_MQ_DEFAULT;
}

But it is not set when null_blk is loaded with NULL_Q_BIO mode in following
code path like other bio drivers do e.g. nvme-multipath :-

if (dev->queue_mode == NULL_Q_BIO) {
        nullb->disk = blk_alloc_disk(nullb->dev->home_node);
        	blk_alloc_disk()
        	  blk_alloc_queue()
        	  __alloc_disk_nodw()
}

Add a new module parameter nowait and respective configfs attr that will
set or clear the QUEUE_FLAG_NOWAIT based on a value set by user in
null_add_dev() when queue_mode is set to NULL_Q_BIO, by default keep it
disabled to retain the original behaviour for the NULL_Q_BIO mode.

Depending on nowait value, use GFP_NOWAIT or GFP_NOIO for the alloction
in the null_alloc_page() for alloc_pages() and in null_insert_page()
for radix_tree_preload() only when queue_mode is NULL_Q_BIO.

Observed performance difference with this patch for fio iouring with
configfs and non configfs null_blk with queue modes NULL_Q_BIO:-

* Configfs non-membacked mode:-

NULL_Q_BIO mode QUEUE_FLAG_NOWAIT disabled :-
---------------------------------------------
configfs-qmode-0-nowait-0-fio-1.log:  read: IOPS=1299k, BW=5076MiB/s
configfs-qmode-0-nowait-0-fio-2.log:  read: IOPS=1250k, BW=4884MiB/s
configfs-qmode-0-nowait-0-fio-3.log:  read: IOPS=1251k, BW=4888MiB/s


NULL_Q_BIO mode QUEUE_FLAG_NOWAIT enabled :-
---------------------------------------------
configfs-qmode-0-nowait-1-fio-1.log:  read: IOPS=5469k, BW=20.9GiB/s
configfs-qmode-0-nowait-1-fio-2.log:  read: IOPS=5525k, BW=21.1GiB/s
configfs-qmode-0-nowait-1-fio-3.log:  read: IOPS=5561k, BW=21.2GiB/s

* Non Configfs non-membacked mode:-

NULL_Q_BIO mode QUEUE_FLAG_NOWAIT disabled :-
---------------------------------------------
qmode-0-nowait-0-fio-1.log:  read: IOPS=1261k, BW=4924MiB/s
qmode-0-nowait-0-fio-2.log:  read: IOPS=1295k, BW=5060MiB/s
qmode-0-nowait-0-fio-3.log:  read: IOPS=1280k, BW=4999MiB/s

NULL_Q_BIO mode QUEUE_FLAG_NOWAIT enabled :-
---------------------------------------------
qmode-0-nowait-1-fio-1.log:  read: IOPS=5521k, BW=21.1GiB/s
qmode-0-nowait-1-fio-2.log:  read: IOPS=5524k, BW=21.1GiB/s
qmode-0-nowait-1-fio-3.log:  read: IOPS=5541k, BW=21.1GiB/s

Below is a performance test log for with and without configfs mambeacked
mode.

Please note that this patch is generated on the top of previously
posted patch for null_blk queue_mode Oops :-
https://marc.info/?l=linux-block&m=168168262517700&w=2

-ck

V2:-

Only allow setting QUEUE_FLAG_NOWAIT when qmode is set to NULL_Q_BIO.


Chaitanya Kulkarni (1):
  null_blk: allow user to set QUEUE_FLAG_NOWAIT

 drivers/block/null_blk/main.c     | 33 ++++++++++++++++++++++++++-----
 drivers/block/null_blk/null_blk.h |  1 +
 2 files changed, 29 insertions(+), 5 deletions(-)

linux-block (for-next) # sh test-null-blk-no-wait.sh
+ modprobe -r null_blk
+ ./compile_nullb.sh
+ umount /mnt/nullb0
umount: /mnt/nullb0: not mounted.
+ rmdir 'config/nullb/nullb*'
rmdir: failed to remove 'config/nullb/nullb*': No such file or directory
+ dmesg -c
+ modprobe -r null_blk
+ lsmod
+ grep null_blk
++ nproc
+ make -j 48 M=drivers/block/ clean
  CLEAN   drivers/block/Module.symvers
++ nproc
+ make -j 48 M=drivers/block modules
  CC [M]  drivers/block/floppy.o
  CC [M]  drivers/block/brd.o
  CC [M]  drivers/block/loop.o
  CC [M]  drivers/block/nbd.o
  CC [M]  drivers/block/virtio_blk.o
  CC [M]  drivers/block/xen-blkfront.o
  CC [M]  drivers/block/rbd.o
  CC [M]  drivers/block/mtip32xx/mtip32xx.o
  CC [M]  drivers/block/drbd/drbd_buildtag.o
  CC [M]  drivers/block/drbd/drbd_bitmap.o
  CC [M]  drivers/block/drbd/drbd_proc.o
  CC [M]  drivers/block/drbd/drbd_worker.o
  CC [M]  drivers/block/zram/zcomp.o
  CC [M]  drivers/block/null_blk/main.o
  CC [M]  drivers/block/drbd/drbd_receiver.o
  CC [M]  drivers/block/xen-blkback/blkback.o
  CC [M]  drivers/block/null_blk/trace.o
  CC [M]  drivers/block/zram/zram_drv.o
  CC [M]  drivers/block/null_blk/zoned.o
  CC [M]  drivers/block/drbd/drbd_req.o
  CC [M]  drivers/block/drbd/drbd_main.o
  CC [M]  drivers/block/drbd/drbd_actlog.o
  CC [M]  drivers/block/drbd/drbd_strings.o
  CC [M]  drivers/block/xen-blkback/xenbus.o
  CC [M]  drivers/block/drbd/drbd_nl.o
  CC [M]  drivers/block/drbd/drbd_interval.o
  CC [M]  drivers/block/drbd/drbd_state.o
  CC [M]  drivers/block/drbd/drbd_nla.o
  CC [M]  drivers/block/drbd/drbd_debugfs.o
  LD [M]  drivers/block/zram/zram.o
  LD [M]  drivers/block/xen-blkback/xen-blkback.o
  LD [M]  drivers/block/null_blk/null_blk.o
  LD [M]  drivers/block/drbd/drbd.o
  MODPOST drivers/block/Module.symvers
  CC [M]  drivers/block/floppy.mod.o
  CC [M]  drivers/block/brd.mod.o
  CC [M]  drivers/block/loop.mod.o
  CC [M]  drivers/block/nbd.mod.o
  CC [M]  drivers/block/virtio_blk.mod.o
  CC [M]  drivers/block/xen-blkfront.mod.o
  CC [M]  drivers/block/xen-blkback/xen-blkback.mod.o
  CC [M]  drivers/block/drbd/drbd.mod.o
  CC [M]  drivers/block/rbd.mod.o
  CC [M]  drivers/block/mtip32xx/mtip32xx.mod.o
  CC [M]  drivers/block/zram/zram.mod.o
  CC [M]  drivers/block/null_blk/null_blk.mod.o
  LD [M]  drivers/block/nbd.ko
  LD [M]  drivers/block/brd.ko
  LD [M]  drivers/block/null_blk/null_blk.ko
  LD [M]  drivers/block/loop.ko
  LD [M]  drivers/block/floppy.ko
  LD [M]  drivers/block/xen-blkfront.ko
  LD [M]  drivers/block/zram/zram.ko
  LD [M]  drivers/block/mtip32xx/mtip32xx.ko
  LD [M]  drivers/block/drbd/drbd.ko
  LD [M]  drivers/block/virtio_blk.ko
  LD [M]  drivers/block/rbd.ko
  LD [M]  drivers/block/xen-blkback/xen-blkback.ko
+ HOST=drivers/block/null_blk/
++ uname -r
+ HOST_DEST=/lib/modules/6.3.0-rc5lblk+/kernel/drivers/block/null_blk/
+ cp drivers/block/null_blk//null_blk.ko /lib/modules/6.3.0-rc5lblk+/kernel/drivers/block/null_blk//
+ ls -lrth /lib/modules/6.3.0-rc5lblk+/kernel/drivers/block/null_blk//null_blk.ko
-rw-r--r--. 1 root root 1.2M Apr 16 00:27 /lib/modules/6.3.0-rc5lblk+/kernel/drivers/block/null_blk//null_blk.ko
+ sleep 1
+ dmesg -c
+ test_non_configfs
+ modprobe null_blk nowait=0 queue_mode=0
+ dmesg -c
[ 2899.900308] null_blk: disk nullb0 created
[ 2899.900311] null_blk: module loaded
+ for i in 1 2 3
+ fio fio/randread.fio --filename=/dev/nullb0 --output=qmode-0-nowait-0-fio-1.log
+ for i in 1 2 3 [r(24)][100.0%][r=5060MiB/s][r=1295k IOPS][eta 00m:00s]
+ fio fio/randread.fio --filename=/dev/nullb0 --output=qmode-0-nowait-0-fio-2.log
+ for i in 1 2 3 [r(24)][100.0%][r=5420MiB/s][r=1387k IOPS][eta 00m:00s]
+ fio fio/randread.fio --filename=/dev/nullb0 --output=qmode-0-nowait-0-fio-3.log
+ modprobe -r null_blk)][100.0%][r=5198MiB/s][r=1331k IOPS][eta 00m:00s]
+ modprobe null_blk nowait=1 queue_mode=0
+ dmesg -c
[ 2960.569964] null_blk: disk nullb0 created
[ 2960.569975] null_blk: module loaded
+ for i in 1 2 3
+ fio fio/randread.fio --filename=/dev/nullb0 --output=qmode-0-nowait-1-fio-1.log
+ for i in 1 2 3 [r(24)][100.0%][r=21.3GiB/s][r=5572k IOPS][eta 00m:00s]
+ fio fio/randread.fio --filename=/dev/nullb0 --output=qmode-0-nowait-1-fio-2.log
+ for i in 1 2 3 [r(24)][100.0%][r=21.0GiB/s][r=5518k IOPS][eta 00m:00s]
+ fio fio/randread.fio --filename=/dev/nullb0 --output=qmode-0-nowait-1-fio-3.log
+ modprobe -r null_blk)][100.0%][r=20.8GiB/s][r=5459k IOPS][eta 00m:00s]
+ test_configfs 0 0
+ qmode=0
+ nowait=0
+ modprobe null_blk nr_devices=0
+ NULLB_DIR=config/nullb/nullb0
+ mkdir config/nullb/nullb0
+ echo 1
+ echo 4096
+ echo 20480
+ echo 0
+ echo 0
+ echo 1
+ '[' 0 -ne 0 ']'
+ sleep .50
+ for i in 1 2 3
+ fio fio/randread.fio --filename=/dev/nullb0 --output=configfs-qmode-0-nowait-0-fio-1.log
+ for i in 1 2 3 [r(24)][100.0%][r=5001MiB/s][r=1280k IOPS][eta 00m:00s]
+ fio fio/randread.fio --filename=/dev/nullb0 --output=configfs-qmode-0-nowait-0-fio-2.log
+ for i in 1 2 3 [r(24)][100.0%][r=4684MiB/s][r=1199k IOPS][eta 00m:00s]
+ fio fio/randread.fio --filename=/dev/nullb0 --output=configfs-qmode-0-nowait-0-fio-3.log
+ rmdir config/nullb/nullb00.0%][r=4829MiB/s][r=1236k IOPS][eta 00m:00s]
+ modprobe -r null_blk
+ test_configfs 0 1
+ qmode=0
+ nowait=1
+ modprobe null_blk nr_devices=0
+ NULLB_DIR=config/nullb/nullb0
+ mkdir config/nullb/nullb0
+ echo 1
+ echo 4096
+ echo 20480
+ echo 0
+ echo 1
+ echo 1
+ '[' 0 -ne 0 ']'
+ sleep .50
+ for i in 1 2 3
+ fio fio/randread.fio --filename=/dev/nullb0 --output=configfs-qmode-0-nowait-1-fio-1.log
+ for i in 1 2 3 [r(24)][100.0%][r=8289MiB/s][r=2122k IOPS][eta 00m:00s]
+ fio fio/randread.fio --filename=/dev/nullb0 --output=configfs-qmode-0-nowait-1-fio-2.log
+ for i in 1 2 3 [r(24)][100.0%][r=8278MiB/s][r=2119k IOPS][eta 00m:00s]
+ fio fio/randread.fio --filename=/dev/nullb0 --output=configfs-qmode-0-nowait-1-fio-3.log
+ rmdir config/nullb/nullb00.0%][r=7908MiB/s][r=2024k IOPS][eta 00m:00s]
+ modprobe -r null_blk
linux-block (for-next) # grep IOPS *fio*log
configfs-qmode-0-nowait-0-fio-1.log:  read: IOPS=1267k, BW=4950MiB/s (5190MB/s)(96.7GiB/20002msec)
configfs-qmode-0-nowait-0-fio-2.log:  read: IOPS=1225k, BW=4783MiB/s (5016MB/s)(93.4GiB/20001msec)
configfs-qmode-0-nowait-0-fio-3.log:  read: IOPS=1250k, BW=4884MiB/s (5121MB/s)(95.4GiB/20002msec)
configfs-qmode-0-nowait-1-fio-1.log:  read: IOPS=2096k, BW=8189MiB/s (8587MB/s)(160GiB/20001msec)
configfs-qmode-0-nowait-1-fio-2.log:  read: IOPS=2108k, BW=8233MiB/s (8633MB/s)(161GiB/20002msec)
configfs-qmode-0-nowait-1-fio-3.log:  read: IOPS=2061k, BW=8049MiB/s (8440MB/s)(157GiB/20002msec)
qmode-0-nowait-0-fio-1.log:  read: IOPS=1321k, BW=5158MiB/s (5409MB/s)(101GiB/20001msec)
qmode-0-nowait-0-fio-2.log:  read: IOPS=1266k, BW=4945MiB/s (5186MB/s)(96.6GiB/20001msec)
qmode-0-nowait-0-fio-3.log:  read: IOPS=1313k, BW=5129MiB/s (5378MB/s)(100GiB/20002msec)
qmode-0-nowait-1-fio-1.log:  read: IOPS=5511k, BW=21.0GiB/s (22.6GB/s)(421GiB/20002msec)
qmode-0-nowait-1-fio-2.log:  read: IOPS=5506k, BW=21.0GiB/s (22.6GB/s)(420GiB/20002msec)
qmode-0-nowait-1-fio-3.log:  read: IOPS=5508k, BW=21.0GiB/s (22.6GB/s)(420GiB/20002msec)
linux-block (for-next) #

Comments

Chaitanya Kulkarni April 18, 2023, 4:29 a.m. UTC | #1
On 4/17/23 21:24, Chaitanya Kulkarni wrote:
> QUEUE_FLAG_NOWAIT is set by default to mq drivers such null_blk when
> it is used with NULL_Q_MQ mode as a part of QUEUE_FLAG_MQ_DEFAULT that
> gets assigned in following code path see blk_mq_init_allocated_queue():-
>
>

Please ignore this, I forget to check for BLK_MQ_F_BLOCKING if it is
compatible or not with GFP_NOWAIT.

I'll send V3 soon with check added, sorry for the noise.

-ck