Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: mrybczyn@kalray.eu (Marta Rybczynska)
Subject: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
Date: Wed, 3 May 2017 17:19:27 +0200 (CEST)	[thread overview]
Message-ID: <780938034.8003164.1493824767084.JavaMail.zimbra@kalray.eu> (raw)
In-Reply-To: <823aa3f0-685f-4569-11d6-238cc4f0b126@grimberg.me>

>> +static inline bool nvme_rdma_queue_sig_limit(struct nvme_rdma_queue *queue)
>> +{
>> +       int v, old;
>> +
>> +       v = atomic_read(&queue->sig_count);
>> +       while (1) {
>> +               if (v > 1) {
>> +                       old = atomic_cmpxchg(&queue->sig_count, v, v - 1);
>> +                       if (old == v)
>> +                               return false;
>> +               } else {
>> +                       int new_count;
>> +
>> +                       new_count = nvme_rdma_init_sig_count(queue->queue_size);
>> +                       old = atomic_cmpxchg(&queue->sig_count, v, new_count);
>> +                       if (old == v)
>> +                               return true;
>> +               }
>> +               v = old;
>> +       }
>> +}
>> +
> 
> Ugh, no...
> 
> How about just do:
> 
>	if (atomic_inc_return(queue->sig_count) % queue->sig_limit)
>		return true;
>	return false;
> 
> where
>	queue->sig_limit = max(queue->queue_size / 2, 1);

I tried to avoid that because this adds a division in the fast path Bart
was unhappy about in v2.

Unfortunately we do not have an atomic with on overflow operation like
the one needed here.

Marta

  reply	other threads:[~2017-05-03 15:19 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-03 10:05 [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32 Marta Rybczynska
2017-05-03 11:17 ` Leon Romanovsky
2017-05-03 15:08 ` Sagi Grimberg
2017-05-03 15:19   ` Marta Rybczynska [this message]
2017-05-03 15:45     ` Bart Van Assche
2017-05-03 15:53     ` Jason Gunthorpe
2017-05-03 15:58       ` Bart Van Assche
2017-05-03 16:01         ` Sagi Grimberg
2017-05-03 16:27           ` Leon Romanovsky
2017-05-03 16:37             ` Bart Van Assche
2017-05-03 16:49               ` Sagi Grimberg
2017-05-04 12:50               ` Marta Rybczynska
2017-05-17  9:02                 ` Christoph Hellwig
2017-05-17 12:50                   ` Marta Rybczynska
2017-05-03 16:17         ` Doug Ledford
2017-05-03 16:24           ` Bart Van Assche
2017-05-03 19:07             ` Doug Ledford

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=780938034.8003164.1493824767084.JavaMail.zimbra@kalray.eu \
    --to=mrybczyn@kalray.eu \
    /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