Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1657521
| Path | csiph.com!news.mixmin.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Sagi Grimberg <sagi@grimberg.me> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] nvme-rdma: remove race conditions from IB signalling |
| Date | Mon, 05 Jun 2017 13:20:02 +0200 |
| Message-ID | <tOYdc-2bU-29@gated-at.bofh.it> (permalink) |
| References | <tOWXM-1fC-17@gated-at.bofh.it> |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=mfsocWCJeAhVq5RFgwOWYVmDASYiL+nmZzp3/neAqg0=; b=h1HQz5ERMnbe1pyM5bAe7qh1CX9cyn9h+rZCupeASsQ5fq+wQWAl5o/iJjeOkGyPAd cQWI/zGtCQzdYTY//+ImvzWYHn3d2Uh1Vao2Nl5ANf11ALSexccq0cdcSl5D4JDFgNDo etekLMGmnoazhKZ1nHFHR2d09iy2ZxMRY9ctgQ8ZqlN2XlZMUOe0DlaCTnvbGrVjUzGC amrdxrJwkJF3TqGUdz+qdyP6Qj4hmECDZyfV26UHOX/bPlCwt9qsOna921WVfbZIlWPh 08nm3CH26GCSVNyybbTbEQqLzcstWYS0CROvPDFtbVcZ+I3F46DgT740Emh44ur6nUlL 5qqQ== |
| X-Gm-Message-State | AODbwcAZrXiIwdslyuY0WQyuEJ2+K1H4NAgGWG1ZJ8MFy51nPCi6LKIs SAD75WmoUERCrw== |
| X-Received | by 10.28.218.142 with SMTP id r136mr7350279wmg.46.1496661377974; Mon, 05 Jun 2017 04:16:17 -0700 (PDT) |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Language | en-US |
| Content-Transfer-Encoding | 7bit |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 83 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Bart Van Assche <bart.vanassche@sandisk.com>, Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgunthorpe@obsidianresearch.com>, Doug Ledford <dledford@redhat.com> |
| X-Original-Date | Mon, 5 Jun 2017 14:16:15 +0300 |
| X-Original-Message-ID | <97a72992-3ac3-74d9-96dc-22c31bbb6694@grimberg.me> |
| X-Original-References | <1785464880.73761005.1496655938570.JavaMail.zimbra@kalray.eu> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1657521 |
Show key headers only | View raw
On 05/06/17 12:45, Marta Rybczynska wrote:
> This patch improves the way the RDMA IB signalling is done
> by using atomic operations for the signalling variable. This
> avoids race conditions on sig_count.
>
> The signalling interval changes slightly and is now the
> largest power of two not larger than queue depth / 2.
>
> ilog() usage idea by Bart Van Assche.
>
> Signed-off-by: Marta Rybczynska <marta.rybczynska@kalray.eu>
> ---
> drivers/nvme/host/rdma.c | 31 +++++++++++++++++++++----------
> 1 file changed, 21 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
> index 28bd255..80682f7 100644
> --- a/drivers/nvme/host/rdma.c
> +++ b/drivers/nvme/host/rdma.c
> @@ -88,7 +88,7 @@ enum nvme_rdma_queue_flags {
>
> struct nvme_rdma_queue {
> struct nvme_rdma_qe *rsp_ring;
> - u8 sig_count;
> + atomic_t sig_count;
> int queue_size;
> size_t cmnd_capsule_len;
> struct nvme_rdma_ctrl *ctrl;
> @@ -554,6 +554,8 @@ static int nvme_rdma_init_queue(struct nvme_rdma_ctrl *ctrl,
>
> queue->queue_size = queue_size;
>
> + atomic_set(&queue->sig_count, 0);
> +
> queue->cm_id = rdma_create_id(&init_net, nvme_rdma_cm_handler, queue,
> RDMA_PS_TCP, IB_QPT_RC);
> if (IS_ERR(queue->cm_id)) {
> @@ -1038,17 +1040,26 @@ static void nvme_rdma_send_done(struct ib_cq *cq, struct ib_wc *wc)
> nvme_rdma_wr_error(cq, wc, "SEND");
> }
>
> -static inline int nvme_rdma_queue_sig_limit(struct nvme_rdma_queue *queue)
> +static inline int nvme_rdma_init_sig_count(int queue_size)
> {
> - int sig_limit;
> -
> - /*
> - * We signal completion every queue depth/2 and also handle the
> - * degenerated case of a device with queue_depth=1, where we
> - * would need to signal every message.
> + /* We want to signal completion at least every queue depth/2.
> + * This returns the largest power of two that is not above half
> + * of (queue size + 1) to optimize (avoid divisions).
> */
> - sig_limit = max(queue->queue_size / 2, 1);
> - return (++queue->sig_count % sig_limit) == 0;
> + return 1 << ilog2((queue_size + 1) / 2);
> +}
> +
> +static inline bool nvme_rdma_queue_sig_limit(struct nvme_rdma_queue *queue)
> +{
> + int count, limit;
> +
> + limit = nvme_rdma_init_sig_count(queue->queue_size);
Why calling it init? you're not initializing anything...
I'd just call it nvme_rdma_sig_limit()
> + count = atomic_inc_return(&queue->sig_count);
> +
> + /* Signal if count is a multiple of limit */
> + if ((count & (limit - 1)) == 0)
> + return true;
> + return false;
> }
You can replace it with:
return (atomic_inc_return(&queue->sig_count) & (limit - 1)) == 0;
And lose the local count variable.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] nvme-rdma: remove race conditions from IB signalling Marta Rybczynska <mrybczyn@kalray.eu> - 2017-06-05 12:00 +0200
Re: [PATCH] nvme-rdma: remove race conditions from IB signalling Sagi Grimberg <sagi@grimberg.me> - 2017-06-05 13:20 +0200
Re: [PATCH] nvme-rdma: remove race conditions from IB signalling Marta Rybczynska <mrybczyn@kalray.eu> - 2017-06-05 13:50 +0200
Re: [PATCH] nvme-rdma: remove race conditions from IB signalling Marta Rybczynska <mrybczyn@kalray.eu> - 2017-06-05 16:10 +0200
Re: [PATCH] nvme-rdma: remove race conditions from IB signalling Sagi Grimberg <sagi@grimberg.me> - 2017-06-05 19:30 +0200
Re: [PATCH] nvme-rdma: remove race conditions from IB signalling Marta Rybczynska <mrybczyn@kalray.eu> - 2017-06-05 16:30 +0200
csiph-web