From: Marta Rybczynska <mrybczyn@kalray.eu>
To: Sagi Grimberg <sagi@grimberg.me>
Cc: keith busch <keith.busch@intel.com>,
axboe@fb.com, hch@lst.de, linux-nvme@lists.infradead.org,
linux-kernel@vger.kernel.org,
Bart Van Assche <bart.vanassche@sandisk.com>,
Leon Romanovsky <leon@kernel.org>,
Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
Doug Ledford <dledford@redhat.com>
Subject: Re: [PATCH] nvme-rdma: remove race conditions from IB signalling
Date: Mon, 5 Jun 2017 13:39:40 +0200 (CEST) [thread overview]
Message-ID: <398638390.74484157.1496662780144.JavaMail.zimbra@kalray.eu> (raw)
In-Reply-To: <97a72992-3ac3-74d9-96dc-22c31bbb6694@grimberg.me>
>> -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.
The init part is a leftover from one of the previous versions and we do not need
the value anywhere else. As the sig_limit() function is quite short now it I can
also put the ilog part + comments in the same place too. Wouldn't it be easier
to read?
Marta
next prev parent reply other threads:[~2017-06-05 11:39 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 [this message]
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
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=398638390.74484157.1496662780144.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=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®