mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marta Rybczynska <mrybczyn@kalray.eu>
To: Max Gurtovoy <maxg@mellanox.com>
Cc: keith busch <keith.busch@intel.com>,
	axboe@fb.com, hch@lst.de, sagi@grimberg.me,
	linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
	Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
	Bart Van Assche <bart.vanassche@sandisk.com>,
	Doug Ledford <dledford@redhat.com>,
	Leon Romanovsky <leon@kernel.org>
Subject: Re: [PATCH] nvme-rdma: remove race conditions from IB signalling
Date: Mon, 5 Jun 2017 16:25:56 +0200 (CEST)	[thread overview]
Message-ID: <73128754.75195919.1496672756008.JavaMail.zimbra@kalray.eu> (raw)
In-Reply-To: <f732eb30-4582-1daa-21e2-c7c03b9af9e0@mellanox.com>

> On 6/5/2017 12:45 PM, 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);
> 
> Maybe I'm missing something, but why we need to calc limit each time in
> data path (not a big deal but we can avoid that)?
> Can you add queue->sig_limit that will be calculated once at queue
> allocation ?

We've said last time that ilog() is cheap enough so that we do not
need to add this variable. It maps to fls() or a specific instruction
of a platform.

Marta

      reply	other threads:[~2017-06-05 14:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-05  9:45 Marta Rybczynska
2017-06-05 11:16 ` Sagi Grimberg
2017-06-05 11:39   ` Marta Rybczynska
2017-06-05 14:02     ` Marta Rybczynska
2017-06-05 17:21       ` Sagi Grimberg
2017-06-05 14:08 ` Max Gurtovoy
2017-06-05 14:25   ` Marta Rybczynska [this message]

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=73128754.75195919.1496672756008.JavaMail.zimbra@kalray.eu \
    --to=mrybczyn@kalray.eu \
    --cc=axboe@fb.com \
    --cc=bart.vanassche@sandisk.com \
    --cc=dledford@redhat.com \
    --cc=hch@lst.de \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=keith.busch@intel.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=maxg@mellanox.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®