All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] NVMe: Set queue max segments
@ 2015-08-12 22:17 Keith Busch
  2015-08-13  6:38 ` Christoph Hellwig
  2015-08-17 21:51 ` Jens Axboe
  0 siblings, 2 replies; 5+ messages in thread
From: Keith Busch @ 2015-08-12 22:17 UTC (permalink / raw)


This sets the queue's max segment size to match the device's
capabilities. The default of 128 is usable until a device's transfer
capability exceeds 512k, assuming a device page size of 4k. Many nvme
devices exceed that transfer limit, so this lets the block layer know what
kind of commands it to allow to form rather than unnecessarily split them.

One additional segment is added to account for a transfer that may start
in the middle of a page.

Signed-off-by: Keith Busch <keith.busch at intel.com>
---
 drivers/block/nvme-core.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index 613c1bc..abe93a5 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -2098,8 +2098,11 @@ static void nvme_alloc_ns(struct nvme_dev *dev, unsigned nsid)
 	list_add_tail(&ns->list, &dev->namespaces);
 
 	blk_queue_logical_block_size(ns->queue, 1 << ns->lba_shift);
-	if (dev->max_hw_sectors)
+	if (dev->max_hw_sectors) {
 		blk_queue_max_hw_sectors(ns->queue, dev->max_hw_sectors);
+		blk_queue_max_segments(ns->queue,
+			((dev->max_hw_sectors << 9) / dev->page_size) + 1);
+	}
 	if (dev->stripe_size)
 		blk_queue_chunk_sectors(ns->queue, dev->stripe_size >> 9);
 	if (dev->vwc & NVME_CTRL_VWC_PRESENT)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] NVMe: Set queue max segments
  2015-08-12 22:17 [PATCH] NVMe: Set queue max segments Keith Busch
@ 2015-08-13  6:38 ` Christoph Hellwig
  2015-08-13 13:52   ` Keith Busch
  2015-08-17 21:51 ` Jens Axboe
  1 sibling, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2015-08-13  6:38 UTC (permalink / raw)


On Wed, Aug 12, 2015@04:17:54PM -0600, Keith Busch wrote:
> This sets the queue's max segment size to match the device's
> capabilities. The default of 128 is usable until a device's transfer
> capability exceeds 512k, assuming a device page size of 4k. Many nvme
> devices exceed that transfer limit, so this lets the block layer know what
> kind of commands it to allow to form rather than unnecessarily split them.
> 
> One additional segment is added to account for a transfer that may start
> in the middle of a page.

But it might not start in the middle of the page, too - in which case
you're overcounting here, aren't you?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] NVMe: Set queue max segments
  2015-08-13  6:38 ` Christoph Hellwig
@ 2015-08-13 13:52   ` Keith Busch
  2015-08-17 19:12     ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Keith Busch @ 2015-08-13 13:52 UTC (permalink / raw)


On Wed, 12 Aug 2015, Christoph Hellwig wrote:
> On Wed, Aug 12, 2015@04:17:54PM -0600, Keith Busch wrote:
>> This sets the queue's max segment size to match the device's
>> capabilities. The default of 128 is usable until a device's transfer
>> capability exceeds 512k, assuming a device page size of 4k. Many nvme
>> devices exceed that transfer limit, so this lets the block layer know what
>> kind of commands it to allow to form rather than unnecessarily split them.
>>
>> One additional segment is added to account for a transfer that may start
>> in the middle of a page.
>
> But it might not start in the middle of the page, too - in which case
> you're overcounting here, aren't you?

queue_max_sectors() would exceed before the next segment is considered,
similar to what happens with very large segments.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] NVMe: Set queue max segments
  2015-08-13 13:52   ` Keith Busch
@ 2015-08-17 19:12     ` Christoph Hellwig
  0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2015-08-17 19:12 UTC (permalink / raw)


Ok, looks fine:

Reviewed-by: Christoph Hellwig <hch at lst.de>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] NVMe: Set queue max segments
  2015-08-12 22:17 [PATCH] NVMe: Set queue max segments Keith Busch
  2015-08-13  6:38 ` Christoph Hellwig
@ 2015-08-17 21:51 ` Jens Axboe
  1 sibling, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2015-08-17 21:51 UTC (permalink / raw)


On 08/12/2015 04:17 PM, Keith Busch wrote:
> This sets the queue's max segment size to match the device's
> capabilities. The default of 128 is usable until a device's transfer
> capability exceeds 512k, assuming a device page size of 4k. Many nvme
> devices exceed that transfer limit, so this lets the block layer know what
> kind of commands it to allow to form rather than unnecessarily split them.
>
> One additional segment is added to account for a transfer that may start
> in the middle of a page.

Applied for 4.3.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-17 21:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-12 22:17 [PATCH] NVMe: Set queue max segments Keith Busch
2015-08-13  6:38 ` Christoph Hellwig
2015-08-13 13:52   ` Keith Busch
2015-08-17 19:12     ` Christoph Hellwig
2015-08-17 21:51 ` Jens Axboe

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.