Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2017-05-03 at 17:19 +0200, Marta Rybczynska wrote:
> > > +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.

Hello Marta,

The approach I proposed works well if sig_count is modified by a single thread
at a time. Seeing your code made me realize that it is nontrivial to implement
that approach if multiple threads can change sig_count concurrently. Since
atomic_cmpxchg() is relatively expensive, what Sagi proposed may be a better
alternative. Sorry that I sent you in the wrong direction.

Bart.--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux