* [PATCH] nvme: only use power of two io boundaries
@ 2020-08-25 16:35 Keith Busch
2020-08-25 17:35 ` Sagi Grimberg
2020-08-27 7:46 ` Christoph Hellwig
0 siblings, 2 replies; 4+ messages in thread
From: Keith Busch @ 2020-08-25 16:35 UTC (permalink / raw)
To: linux-nvme, sagi, hch; +Cc: 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.
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
drivers/nvme/host/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 154942fc64eb..2a398de624a0 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -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) {
--
2.24.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme: only use power of two io boundaries
2020-08-25 16:35 [PATCH] nvme: only use power of two io boundaries Keith Busch
@ 2020-08-25 17:35 ` Sagi Grimberg
2020-08-27 7:46 ` Christoph Hellwig
1 sibling, 0 replies; 4+ messages in thread
From: Sagi Grimberg @ 2020-08-25 17:35 UTC (permalink / raw)
To: Keith Busch, linux-nvme, hch
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme: only use power of two io boundaries
2020-08-25 16:35 [PATCH] nvme: only use power of two io boundaries Keith Busch
2020-08-25 17:35 ` Sagi Grimberg
@ 2020-08-27 7:46 ` Christoph Hellwig
2020-08-27 15:04 ` Keith Busch
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2020-08-27 7:46 UTC (permalink / raw)
To: Keith Busch; +Cc: sagi, linux-nvme, hch
On Tue, Aug 25, 2020 at 09:35:16AM -0700, Keith Busch wrote:
> 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
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] nvme: only use power of two io boundaries
2020-08-27 7:46 ` Christoph Hellwig
@ 2020-08-27 15:04 ` Keith Busch
0 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2020-08-27 15:04 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: sagi, linux-nvme
On Thu, Aug 27, 2020 at 09:46:12AM +0200, Christoph Hellwig wrote:
> On Tue, Aug 25, 2020 at 09:35:16AM -0700, Keith Busch wrote:
> > 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?
Sure, this would provide an explanation for unexpectedly lower
performance. That's worthy of a warning, so sending a v2.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-27 15:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-25 16:35 [PATCH] nvme: only use power of two io boundaries Keith Busch
2020-08-25 17:35 ` Sagi Grimberg
2020-08-27 7:46 ` Christoph Hellwig
2020-08-27 15:04 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox