linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
To: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
Cc: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Max Gurtuvoy <maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH v2 2/3] nvme-rdma: don't complete requests before a send work request has completed
Date: Mon, 20 Nov 2017 11:49:21 +0100	[thread overview]
Message-ID: <20171120104921.GA31309@lst.de> (raw)
In-Reply-To: <58bdc9c0-f98e-9d9f-f81e-fbed572f922e-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>

Btw, I think we can avoid 2 atomic ops for the remote invalidation
path with a simple update like the one below:


diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 5627d81735d2..2032cd8ad431 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1141,7 +1141,6 @@ static int nvme_rdma_map_sg_fr(struct nvme_rdma_queue *queue,
 			     IB_ACCESS_REMOTE_WRITE;
 
 	req->mr->need_inval = true;
-	atomic_inc(&req->ref);
 
 	sg->addr = cpu_to_le64(req->mr->iova);
 	put_unaligned_le24(req->mr->length, sg->length);
@@ -1328,10 +1327,9 @@ static int nvme_rdma_process_nvme_rsp(struct nvme_rdma_queue *queue,
 	req->cqe.status = cqe->status;
 	req->cqe.result = cqe->result;
 
-	if ((wc->wc_flags & IB_WC_WITH_INVALIDATE) &&
-	    wc->ex.invalidate_rkey == req->mr->rkey) {
-		atomic_dec(&req->ref);
-	} else if (req->mr->need_inval) {
+	if (req->mr->need_inval &&
+	    (!(wc->wc_flags & IB_WC_WITH_INVALIDATE) ||
+	     wc->ex.invalidate_rkey != req->mr->rkey)) {
 		ret = nvme_rdma_inv_rkey(queue, req);
 		if (unlikely(ret < 0)) {
 			dev_err(queue->ctrl->ctrl.device,
@@ -1339,12 +1337,12 @@ static int nvme_rdma_process_nvme_rsp(struct nvme_rdma_queue *queue,
 				req->mr->rkey, ret);
 			nvme_rdma_error_recovery(queue->ctrl);
 		}
-	}
-
-	if (atomic_dec_and_test(&req->ref)) {
-		if (rq->tag == tag)
-			ret = 1;
-		nvme_end_request(rq, req->cqe.status, req->cqe.result);
+	} else {
+		if (atomic_dec_and_test(&req->ref)) {
+			if (rq->tag == tag)
+				ret = 1;
+			nvme_end_request(rq, req->cqe.status, req->cqe.result);
+		}
 	}
 
 	return ret;
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-11-20 10:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08 10:06 [PATCH v2 0/3] Fix request completion holes Sagi Grimberg
     [not found] ` <20171108100616.26605-1-sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-11-08 10:06   ` [PATCH v2 1/3] nvme-rdma: don't suppress send completions Sagi Grimberg
     [not found]     ` <20171108100616.26605-2-sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-11-09  9:18       ` Christoph Hellwig
     [not found]         ` <20171109091858.GA16966-jcswGhMUV9g@public.gmane.org>
2017-11-09 11:08           ` Sagi Grimberg
     [not found]             ` <921c4331-9456-3783-423a-9c5c5e405131-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-11-20  8:18               ` Christoph Hellwig
     [not found]                 ` <20171120081809.GB27552-jcswGhMUV9g@public.gmane.org>
2017-11-20  8:33                   ` Sagi Grimberg
     [not found]                     ` <4ac0bc2e-498b-0fc1-4e30-7ff76bd036f1-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-11-20  9:32                       ` Christoph Hellwig
2017-11-08 10:06   ` [PATCH v2 2/3] nvme-rdma: don't complete requests before a send work request has completed Sagi Grimberg
     [not found]     ` <20171108100616.26605-3-sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-11-09  9:21       ` Christoph Hellwig
     [not found]         ` <20171109092110.GB16966-jcswGhMUV9g@public.gmane.org>
2017-11-09 11:14           ` Sagi Grimberg
     [not found]             ` <0f368bc9-2e9f-4008-316c-46b85661a274-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-11-20  8:31               ` Christoph Hellwig
     [not found]                 ` <20171120083130.GC27552-jcswGhMUV9g@public.gmane.org>
2017-11-20  8:37                   ` Sagi Grimberg
     [not found]                     ` <384d8a51-aa2f-5954-c9fd-a0c88d7e5364-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-11-20  8:41                       ` Christoph Hellwig
     [not found]                         ` <20171120084102.GA28456-jcswGhMUV9g@public.gmane.org>
2017-11-20  9:04                           ` Sagi Grimberg
2017-11-20  9:28                           ` Sagi Grimberg
     [not found]                             ` <58bdc9c0-f98e-9d9f-f81e-fbed572f922e-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-11-20 10:49                               ` Christoph Hellwig [this message]
     [not found]                                 ` <20171120104921.GA31309-jcswGhMUV9g@public.gmane.org>
2017-11-20 11:12                                   ` Sagi Grimberg
     [not found]                                     ` <df9c9545-7c00-328b-9f98-535d8e889715-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-11-20 11:16                                       ` Christoph Hellwig
2017-11-08 10:06   ` [PATCH v2 3/3] nvme-rdma: wait for local invalidation before completing a request Sagi Grimberg
     [not found]     ` <20171108100616.26605-4-sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-11-09  9:39       ` Christoph Hellwig
2017-11-13 22:10   ` [PATCH v2 0/3] Fix request completion holes Doug Ledford
     [not found]     ` <1510611044.3735.49.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-11-16 15:39       ` Sagi Grimberg
     [not found]         ` <e89f72c6-12ce-c149-c81e-f3adb43a8e9e-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-11-16 15:58           ` Doug Ledford
2017-11-20  7:37           ` Christoph Hellwig
     [not found]             ` <20171120073755.GA2236-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2017-11-20  8:33               ` Sagi Grimberg

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=20171120104921.GA31309@lst.de \
    --to=hch-jcswghmuv9g@public.gmane.org \
    --cc=linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).