Skip to contentSkip to conversation

nvme: only use power of two io boundaries

PATCH Superseded Keith Busch 3 participants 4 messages Aug 25, 2020 – Aug 27, 2020 NVMe

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Keith Busch

author maintainer
#0 lore raw

PATCH 1/1 nvme: only use power of two io boundaries

The kernel requires a power of two for boundaries because that's the only way it can efficiently split commands that cross them. A controller, however, may report a non-power of two boundary.

The driver had been rounding the controller's value to one the kernel can use, but splitting on the wrong boundary provides no benefit on the device side, and actually incurs additional submission overhead from non-optimal splits. Don't provide any boundary hint if the controller's value can't be used.

---
 drivers/nvme/host/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +2 -2
index 154942fc64eb..2a398de624a0 100644
@@ -2097,8 +2097,8 @@ static int __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
 		}
 	}
 
-	if (iob && !blk_queue_is_zoned(ns->queue))
-		blk_queue_chunk_sectors(ns->queue, rounddown_pow_of_two(iob));
+	if (is_power_of_2(iob) && !blk_queue_is_zoned(ns->queue))
+		blk_queue_chunk_sectors(ns->queue, iob);
 	nvme_update_disk_info(disk, ns, id);
 #ifdef CONFIG_NVME_MULTIPATH
 	if (ns->head->disk) {
Signature · 7 lines
2.24.1


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
#2 lore raw
In reply to Keith Busch
Quoted 9 lines · Keith Busch

The kernel requires a power of two for boundaries because that's the only way it can efficiently split commands that cross them. A controller, however, may report a non-power of two boundary.

The driver had been rounding the controller's value to one the kernel can use, but splitting on the wrong boundary provides no benefit on the device side, and actually incurs additional submission overhead from non-optimal splits. Don't provide any boundary hint if the controller's value can't be used.

Shouldn't we log a warning about non-power of two sizes?

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

author maintainer
#3 lore raw
Quoted 5 lines · Christoph Hellwig
Quoted 4 lines · Keith Busch

The kernel requires a power of two for boundaries because that's the only way it can efficiently split commands that cross them. A controller, however, may report a non-power of two boundary.

Quoted 7 lines
Quoted 5 lines

The driver had been rounding the controller's value to one the kernel can use, but splitting on the wrong boundary provides no benefit on the device side, and actually incurs additional submission overhead from non-optimal splits. Don't provide any boundary hint if the controller's value can't be used.

Shouldn't we log a warning about non-power of two sizes?

Sure, this would provide an explanation for unexpectedly lower performance. That's worthy of a warning, so sending a v2.

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme