All of lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: linux-nvme@lists.infradead.org, sagi@grimberg.me, hch@lst.de
Cc: Keith Busch <kbusch@kernel.org>
Subject: [PATCHv2] nvme: only use power of two io boundaries
Date: Thu, 27 Aug 2020 08:28:24 -0700	[thread overview]
Message-ID: <20200827152824.2784396-1-kbusch@kernel.org> (raw)

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 and log a warning when initially observing a disk's
unreported io boundary.

Signed-off-by: Keith Busch <kbusch@kernel.org>
---
v1->v2:

  Warn for the namespace with unusable io boundary.

 drivers/nvme/host/core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 154942fc64eb..9bbbd600621f 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2097,8 +2097,12 @@ 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);
+	else if (iob && !(disk->flags & GENHD_FL_UP))
+		dev_warn(ctrl->device, "namespace:%u has unused io boundary:%u\n",
+			ns->head->ns_id, 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

             reply	other threads:[~2020-08-27 15:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-27 15:28 Keith Busch [this message]
2020-08-27 15:48 ` [PATCHv2] nvme: only use power of two io boundaries Martin K. Petersen
2020-08-27 15:53   ` Keith Busch
2020-08-27 16:06 ` Christoph Hellwig
2020-08-27 16:44   ` Keith Busch
2020-08-27 16:50     ` Christoph Hellwig
2020-08-28  1:03 ` Damien Le Moal
2020-08-28  4:16   ` Keith Busch
2020-08-28  4:30     ` Damien Le Moal
2020-08-28  4:44       ` Keith Busch
2020-08-28  4:56         ` Damien Le Moal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200827152824.2784396-1-kbusch@kernel.org \
    --to=kbusch@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.