Skip to contentSkip to conversation

brd: mark as nowait compatible

PATCH In review Jens Axboe 2 participants 5 messages Feb 15, 2023 – Feb 16, 2023

Subsystems (2)
lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH 1/1 brd: mark as nowait compatible

By default, non-mq drivers do not support nowait. This causes io_uring to use a slower path as the driver cannot be trust not to block. brd can safely set the nowait flag, as worst case all it does is a NOIO allocation.

For io_uring, this makes a substantial difference. Before:

submitter=0, tid=453, file=/dev/ram0, node=-1 polled=0, fixedbufs=1/0, register_files=1, buffered=0, QD=128 Engine=io_uring, sq_ring=128, cq_ring=128 IOPS=440.03K, BW=1718MiB/s, IOS/call=32/31 IOPS=428.96K, BW=1675MiB/s, IOS/call=32/32 IOPS=442.59K, BW=1728MiB/s, IOS/call=32/31 IOPS=419.65K, BW=1639MiB/s, IOS/call=32/32 IOPS=426.82K, BW=1667MiB/s, IOS/call=32/31

and after:

submitter=0, tid=354, file=/dev/ram0, node=-1 polled=0, fixedbufs=1/0, register_files=1, buffered=0, QD=128 Engine=io_uring, sq_ring=128, cq_ring=128 IOPS=3.37M, BW=13.15GiB/s, IOS/call=32/31 IOPS=3.45M, BW=13.46GiB/s, IOS/call=32/31 IOPS=3.43M, BW=13.42GiB/s, IOS/call=32/32 IOPS=3.43M, BW=13.39GiB/s, IOS/call=32/31 IOPS=3.43M, BW=13.38GiB/s, IOS/call=32/31

or about an 8x in difference.

---

drivers/block/brd.c +1 -0
index 20acc4a1fd6d..82419e345777 100644
@@ -412,6 +412,7 @@ static int brd_alloc(int i)
 	/* Tell the block layer that this is not a rotational device */
 	blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue);
 	blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, disk->queue);
+	blk_queue_flag_set(QUEUE_FLAG_NOWAIT, disk->queue);
 	err = add_disk(disk);
 	if (err)
 		goto out_cleanup_disk;
Signature · 1 line
Jens Axboe
#1 lore raw
Quoted 4 lines · Jens Axboe

By default, non-mq drivers do not support nowait. This causes io_uring to use a slower path as the driver cannot be trust not to block. brd can safely set the nowait flag, as worst case all it does is a NOIO allocation.

But a NOIO allocation can block. I think we need to do a GFP_NOWAIT allocation in brd_insert_page if the NOWAIT flag is set.

author maintainer
#2 lore raw
Quoted 8 lines · Christoph Hellwig
Quoted 4 lines · Jens Axboe

By default, non-mq drivers do not support nowait. This causes io_uring to use a slower path as the driver cannot be trust not to block. brd can safely set the nowait flag, as worst case all it does is a NOIO allocation.

But a NOIO allocation can block. I think we need to do a GFP_NOWAIT allocation in brd_insert_page if the NOWAIT flag is set.

I did consider that, but we do allocations almost everywhere and as long as we're not waiting on IO, it's mostly considered acceptable. But I can make that change, no reason not to.

Signature · 1 line
Jens Axboe
#3 lore raw
Quoted 1 line · Jens Axboe

I did consider that, but we do allocations almost everywhere and

Do we? All the code I've touched for nowait goes to great length to avoid blocking allocations.

author maintainer
#4 lore raw
Quoted 5 lines · Christoph Hellwig
Quoted 1 line · Jens Axboe

I did consider that, but we do allocations almost everywhere and

Do we? All the code I've touched for nowait goes to great length to avoid blocking allocations.

It is prudent, I'm not disagreeing. I've got a v2, will send it out shortly.

Signature · 1 line
Jens Axboe