All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme-pci: fix single segment optimization
@ 2019-05-17 22:50 Ming Lei
  2019-05-20 11:16 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Ming Lei @ 2019-05-17 22:50 UTC (permalink / raw)


Commit dff824b2aadb ("nvme-pci: optimize mapping of small single segment
requests") supposes that single request request only includes single
bvec.

However, this assumption is wrong, since the single segment may cross
multiple bios, then there may be multiple bvecs involved in the segment.

Fixes this issue by checking if it is single bio request, if yes, the
request includes only one bvec, given we don't merge bvecs to one
segment if they belong to same bio.

Cc: Sagi Grimberg <sagi at grimberg.me>
Fixes: dff824b2aadb ("nvme-pci: optimize mapping of small single segment requests")
Signed-off-by: Ming Lei <ming.lei at redhat.com>
---

Hi Christoph,

This patch is candidate on your patch of 'block: don't decrement
nr_phys_segments for physically contigous segments', and I suggest to
take this one because this patch is simpler, and more suitable to serve
as v5.2 fix. 

And your patchset can aim at 5.3 as cleanup after careful
test/evaluation on performance effect.

 drivers/nvme/host/pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 2a8708c9ac18..6a38a760a295 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -824,7 +824,8 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req,
 	blk_status_t ret = BLK_STS_RESOURCE;
 	int nr_mapped;
 
-	if (blk_rq_nr_phys_segments(req) == 1) {
+	/* Avoid the optimization if the single segment crosses two bios */
+	if (blk_rq_nr_phys_segments(req) == 1 && req->bio == req->biotail) {
 		struct bio_vec bv = req_bvec(req);
 
 		if (!is_pci_p2pdma_page(bv.bv_page)) {
-- 
2.20.1

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

* [PATCH] nvme-pci: fix single segment optimization
  2019-05-17 22:50 [PATCH] nvme-pci: fix single segment optimization Ming Lei
@ 2019-05-20 11:16 ` Christoph Hellwig
  2019-05-21  1:08   ` Ming Lei
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2019-05-20 11:16 UTC (permalink / raw)


Given that the code only showed up in 5.2 I'd rather try to fix the
block layer issue, lets see what Jens says.  But if not I defintively
want the comment from my earlier patch, and to me the
!req->bio->bi_next && req->bio->bi_vcnt == 1 check also seems slighly
easier to parse.

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

* [PATCH] nvme-pci: fix single segment optimization
  2019-05-20 11:16 ` Christoph Hellwig
@ 2019-05-21  1:08   ` Ming Lei
  0 siblings, 0 replies; 3+ messages in thread
From: Ming Lei @ 2019-05-21  1:08 UTC (permalink / raw)


On Mon, May 20, 2019@01:16:01PM +0200, Christoph Hellwig wrote:
> Given that the code only showed up in 5.2 I'd rather try to fix the
> block layer issue, lets see what Jens says.  But if not I defintively
> want the comment from my earlier patch, and to me the
> !req->bio->bi_next && req->bio->bi_vcnt == 1 check also seems slighly

The check on 'req->bio->bi_vcnt == 1' should really be avoided, and it
isn't needed too.

thanks,
Ming

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

end of thread, other threads:[~2019-05-21  1:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17 22:50 [PATCH] nvme-pci: fix single segment optimization Ming Lei
2019-05-20 11:16 ` Christoph Hellwig
2019-05-21  1:08   ` Ming Lei

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.