All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-03 10:05 ` Marta Rybczynska
  0 siblings, 0 replies; 34+ messages in thread
From: Marta Rybczynska @ 2017-05-03 10:05 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Sagi Grimberg,
	Leon Romanovsky, axboe-b10kYP2dOMg, Max Gurtovoy,
	Jason Gunthorpe, Christoph Hellwig, Keith Busch, Doug Ledford,
	Bart Van Assche, samuel jones

In the case of small NVMe-oF queue size (<32) we may enter
a deadlock caused by the fact that the IB completions aren't sent
waiting for 32 and the send queue will fill up.

The error is seen as (using mlx5):
[ 2048.693355] mlx5_0:mlx5_ib_post_send:3765:(pid 7273):
[ 2048.693360] nvme nvme1: nvme_rdma_post_send failed with error code -12

This patch changes the way the signalling is done so
that it depends on the queue depth now. The magic define has
been removed completely. It also reworks the signalling
code to use atomic operations.

Signed-off-by: Marta Rybczynska <marta.rybczynska-FNhOzJFKnXGHXe+LvDLADg@public.gmane.org>
Signed-off-by: Samuel Jones <sjones-FNhOzJFKnXGHXe+LvDLADg@public.gmane.org>
[v1]

---

Changes in v4:
* use atomic operations as suggested by Sagi

Changes in v3:
* avoid division in the fast path
* reverse sig_count logic to simplify the code: it now counts down
  from the queue depth/2 to 0
* change sig_count to int to avoid overflows for big queues

Changes in v2:
* signal by queue size/2, remove hardcoded 32
* support queue depth of 1
---
 drivers/nvme/host/rdma.c | 40 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 35 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 16f84eb..234b010 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;
@@ -257,6 +257,15 @@ static int nvme_rdma_wait_for_cm(struct nvme_rdma_queue *queue)
        return queue->cm_error;
 }
 
+static inline int nvme_rdma_init_sig_count(int queue_size)
+{
+       /* We signal completion every queue depth/2 and also
+        * handle the case of possible device with queue_depth=1,
+        * where we would need to signal every message.
+        */
+       return max(queue_size / 2, 1);
+}
+
 static int nvme_rdma_create_qp(struct nvme_rdma_queue *queue, const int factor)
 {
        struct nvme_rdma_device *dev = queue->device;
@@ -561,6 +570,8 @@ static int nvme_rdma_init_queue(struct nvme_rdma_ctrl *ctrl,
 
        queue->queue_size = queue_size;
 
+       atomic_set(&queue->sig_count, nvme_rdma_init_sig_count(queue_size));
+
        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)) {
@@ -1029,6 +1040,28 @@ static void nvme_rdma_send_done(struct ib_cq *cq, struct ib_wc *wc)
                nvme_rdma_wr_error(cq, wc, "SEND");
 }
 
+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;
+       }
+}
+
 static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
                struct nvme_rdma_qe *qe, struct ib_sge *sge, u32 num_sge,
                struct ib_send_wr *first, bool flush)
@@ -1056,9 +1089,6 @@ static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
         * Would have been way to obvious to handle this in hardware or
         * at least the RDMA stack..
         *
-        * This messy and racy code sniplet is copy and pasted from the iSER
-        * initiator, and the magic '32' comes from there as well.
-        *
         * Always signal the flushes. The magic request used for the flush
         * sequencer is not allocated in our driver's tagset and it's
         * triggered to be freed by blk_cleanup_queue(). So we need to
@@ -1066,7 +1096,7 @@ static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
         * embedded in request's payload, is not freed when __ib_process_cq()
         * calls wr_cqe->done().
         */
-       if ((++queue->sig_count % 32) == 0 || flush)
+       if (nvme_rdma_queue_sig_limit(queue) || flush)
                wr.send_flags |= IB_SEND_SIGNALED;
 
        if (first)
-- 
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-03 10:05 ` Marta Rybczynska
  0 siblings, 0 replies; 34+ messages in thread
From: Marta Rybczynska @ 2017-05-03 10:05 UTC (permalink / raw)


In the case of small NVMe-oF queue size (<32) we may enter
a deadlock caused by the fact that the IB completions aren't sent
waiting for 32 and the send queue will fill up.

The error is seen as (using mlx5):
[ 2048.693355] mlx5_0:mlx5_ib_post_send:3765:(pid 7273):
[ 2048.693360] nvme nvme1: nvme_rdma_post_send failed with error code -12

This patch changes the way the signalling is done so
that it depends on the queue depth now. The magic define has
been removed completely. It also reworks the signalling
code to use atomic operations.

Signed-off-by: Marta Rybczynska <marta.rybczynska at kalray.eu>
Signed-off-by: Samuel Jones <sjones at kalray.eu>
[v1]

---

Changes in v4:
* use atomic operations as suggested by Sagi

Changes in v3:
* avoid division in the fast path
* reverse sig_count logic to simplify the code: it now counts down
  from the queue depth/2 to 0
* change sig_count to int to avoid overflows for big queues

Changes in v2:
* signal by queue size/2, remove hardcoded 32
* support queue depth of 1
---
 drivers/nvme/host/rdma.c | 40 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 35 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 16f84eb..234b010 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;
@@ -257,6 +257,15 @@ static int nvme_rdma_wait_for_cm(struct nvme_rdma_queue *queue)
        return queue->cm_error;
 }
 
+static inline int nvme_rdma_init_sig_count(int queue_size)
+{
+       /* We signal completion every queue depth/2 and also
+        * handle the case of possible device with queue_depth=1,
+        * where we would need to signal every message.
+        */
+       return max(queue_size / 2, 1);
+}
+
 static int nvme_rdma_create_qp(struct nvme_rdma_queue *queue, const int factor)
 {
        struct nvme_rdma_device *dev = queue->device;
@@ -561,6 +570,8 @@ static int nvme_rdma_init_queue(struct nvme_rdma_ctrl *ctrl,
 
        queue->queue_size = queue_size;
 
+       atomic_set(&queue->sig_count, nvme_rdma_init_sig_count(queue_size));
+
        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)) {
@@ -1029,6 +1040,28 @@ static void nvme_rdma_send_done(struct ib_cq *cq, struct ib_wc *wc)
                nvme_rdma_wr_error(cq, wc, "SEND");
 }
 
+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;
+       }
+}
+
 static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
                struct nvme_rdma_qe *qe, struct ib_sge *sge, u32 num_sge,
                struct ib_send_wr *first, bool flush)
@@ -1056,9 +1089,6 @@ static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
         * Would have been way to obvious to handle this in hardware or
         * at least the RDMA stack..
         *
-        * This messy and racy code sniplet is copy and pasted from the iSER
-        * initiator, and the magic '32' comes from there as well.
-        *
         * Always signal the flushes. The magic request used for the flush
         * sequencer is not allocated in our driver's tagset and it's
         * triggered to be freed by blk_cleanup_queue(). So we need to
@@ -1066,7 +1096,7 @@ static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
         * embedded in request's payload, is not freed when __ib_process_cq()
         * calls wr_cqe->done().
         */
-       if ((++queue->sig_count % 32) == 0 || flush)
+       if (nvme_rdma_queue_sig_limit(queue) || flush)
                wr.send_flags |= IB_SEND_SIGNALED;
 
        if (first)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-03 10:05 ` Marta Rybczynska
@ 2017-05-03 11:17     ` Leon Romanovsky
  -1 siblings, 0 replies; 34+ messages in thread
From: Leon Romanovsky @ 2017-05-03 11:17 UTC (permalink / raw)
  To: Marta Rybczynska
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Sagi Grimberg,
	axboe-b10kYP2dOMg, Max Gurtovoy, Jason Gunthorpe,
	Christoph Hellwig, Keith Busch, Doug Ledford, Bart Van Assche,
	samuel jones

[-- Attachment #1: Type: text/plain, Size: 5208 bytes --]

On Wed, May 03, 2017 at 12:05:15PM +0200, Marta Rybczynska wrote:
> In the case of small NVMe-oF queue size (<32) we may enter
> a deadlock caused by the fact that the IB completions aren't sent
> waiting for 32 and the send queue will fill up.
>
> The error is seen as (using mlx5):
> [ 2048.693355] mlx5_0:mlx5_ib_post_send:3765:(pid 7273):
> [ 2048.693360] nvme nvme1: nvme_rdma_post_send failed with error code -12
>
> This patch changes the way the signalling is done so
> that it depends on the queue depth now. The magic define has
> been removed completely. It also reworks the signalling
> code to use atomic operations.
>
> Signed-off-by: Marta Rybczynska <marta.rybczynska-FNhOzJFKnXGHXe+LvDLADg@public.gmane.org>
> Signed-off-by: Samuel Jones <sjones-FNhOzJFKnXGHXe+LvDLADg@public.gmane.org>
> [v1]

^^^^ This part of commit message is not needed.
Thanks

>
> ---
>
> Changes in v4:
> * use atomic operations as suggested by Sagi
>
> Changes in v3:
> * avoid division in the fast path
> * reverse sig_count logic to simplify the code: it now counts down
>   from the queue depth/2 to 0
> * change sig_count to int to avoid overflows for big queues
>
> Changes in v2:
> * signal by queue size/2, remove hardcoded 32
> * support queue depth of 1
> ---
>  drivers/nvme/host/rdma.c | 40 +++++++++++++++++++++++++++++++++++-----
>  1 file changed, 35 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
> index 16f84eb..234b010 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;
> @@ -257,6 +257,15 @@ static int nvme_rdma_wait_for_cm(struct nvme_rdma_queue *queue)
>         return queue->cm_error;
>  }
>
> +static inline int nvme_rdma_init_sig_count(int queue_size)
> +{
> +       /* We signal completion every queue depth/2 and also
> +        * handle the case of possible device with queue_depth=1,
> +        * where we would need to signal every message.
> +        */
> +       return max(queue_size / 2, 1);
> +}
> +
>  static int nvme_rdma_create_qp(struct nvme_rdma_queue *queue, const int factor)
>  {
>         struct nvme_rdma_device *dev = queue->device;
> @@ -561,6 +570,8 @@ static int nvme_rdma_init_queue(struct nvme_rdma_ctrl *ctrl,
>
>         queue->queue_size = queue_size;
>
> +       atomic_set(&queue->sig_count, nvme_rdma_init_sig_count(queue_size));
> +
>         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)) {
> @@ -1029,6 +1040,28 @@ static void nvme_rdma_send_done(struct ib_cq *cq, struct ib_wc *wc)
>                 nvme_rdma_wr_error(cq, wc, "SEND");
>  }
>
> +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;
> +       }
> +}
> +
>  static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
>                 struct nvme_rdma_qe *qe, struct ib_sge *sge, u32 num_sge,
>                 struct ib_send_wr *first, bool flush)
> @@ -1056,9 +1089,6 @@ static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
>          * Would have been way to obvious to handle this in hardware or
>          * at least the RDMA stack..
>          *
> -        * This messy and racy code sniplet is copy and pasted from the iSER
> -        * initiator, and the magic '32' comes from there as well.
> -        *
>          * Always signal the flushes. The magic request used for the flush
>          * sequencer is not allocated in our driver's tagset and it's
>          * triggered to be freed by blk_cleanup_queue(). So we need to
> @@ -1066,7 +1096,7 @@ static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
>          * embedded in request's payload, is not freed when __ib_process_cq()
>          * calls wr_cqe->done().
>          */
> -       if ((++queue->sig_count % 32) == 0 || flush)
> +       if (nvme_rdma_queue_sig_limit(queue) || flush)
>                 wr.send_flags |= IB_SEND_SIGNALED;
>
>         if (first)
> --
> 1.8.3.1
>
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-03 11:17     ` Leon Romanovsky
  0 siblings, 0 replies; 34+ messages in thread
From: Leon Romanovsky @ 2017-05-03 11:17 UTC (permalink / raw)


On Wed, May 03, 2017@12:05:15PM +0200, Marta Rybczynska wrote:
> In the case of small NVMe-oF queue size (<32) we may enter
> a deadlock caused by the fact that the IB completions aren't sent
> waiting for 32 and the send queue will fill up.
>
> The error is seen as (using mlx5):
> [ 2048.693355] mlx5_0:mlx5_ib_post_send:3765:(pid 7273):
> [ 2048.693360] nvme nvme1: nvme_rdma_post_send failed with error code -12
>
> This patch changes the way the signalling is done so
> that it depends on the queue depth now. The magic define has
> been removed completely. It also reworks the signalling
> code to use atomic operations.
>
> Signed-off-by: Marta Rybczynska <marta.rybczynska at kalray.eu>
> Signed-off-by: Samuel Jones <sjones at kalray.eu>
> [v1]

^^^^ This part of commit message is not needed.
Thanks

>
> ---
>
> Changes in v4:
> * use atomic operations as suggested by Sagi
>
> Changes in v3:
> * avoid division in the fast path
> * reverse sig_count logic to simplify the code: it now counts down
>   from the queue depth/2 to 0
> * change sig_count to int to avoid overflows for big queues
>
> Changes in v2:
> * signal by queue size/2, remove hardcoded 32
> * support queue depth of 1
> ---
>  drivers/nvme/host/rdma.c | 40 +++++++++++++++++++++++++++++++++++-----
>  1 file changed, 35 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
> index 16f84eb..234b010 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;
> @@ -257,6 +257,15 @@ static int nvme_rdma_wait_for_cm(struct nvme_rdma_queue *queue)
>         return queue->cm_error;
>  }
>
> +static inline int nvme_rdma_init_sig_count(int queue_size)
> +{
> +       /* We signal completion every queue depth/2 and also
> +        * handle the case of possible device with queue_depth=1,
> +        * where we would need to signal every message.
> +        */
> +       return max(queue_size / 2, 1);
> +}
> +
>  static int nvme_rdma_create_qp(struct nvme_rdma_queue *queue, const int factor)
>  {
>         struct nvme_rdma_device *dev = queue->device;
> @@ -561,6 +570,8 @@ static int nvme_rdma_init_queue(struct nvme_rdma_ctrl *ctrl,
>
>         queue->queue_size = queue_size;
>
> +       atomic_set(&queue->sig_count, nvme_rdma_init_sig_count(queue_size));
> +
>         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)) {
> @@ -1029,6 +1040,28 @@ static void nvme_rdma_send_done(struct ib_cq *cq, struct ib_wc *wc)
>                 nvme_rdma_wr_error(cq, wc, "SEND");
>  }
>
> +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;
> +       }
> +}
> +
>  static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
>                 struct nvme_rdma_qe *qe, struct ib_sge *sge, u32 num_sge,
>                 struct ib_send_wr *first, bool flush)
> @@ -1056,9 +1089,6 @@ static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
>          * Would have been way to obvious to handle this in hardware or
>          * at least the RDMA stack..
>          *
> -        * This messy and racy code sniplet is copy and pasted from the iSER
> -        * initiator, and the magic '32' comes from there as well.
> -        *
>          * Always signal the flushes. The magic request used for the flush
>          * sequencer is not allocated in our driver's tagset and it's
>          * triggered to be freed by blk_cleanup_queue(). So we need to
> @@ -1066,7 +1096,7 @@ static int nvme_rdma_post_send(struct nvme_rdma_queue *queue,
>          * embedded in request's payload, is not freed when __ib_process_cq()
>          * calls wr_cqe->done().
>          */
> -       if ((++queue->sig_count % 32) == 0 || flush)
> +       if (nvme_rdma_queue_sig_limit(queue) || flush)
>                 wr.send_flags |= IB_SEND_SIGNALED;
>
>         if (first)
> --
> 1.8.3.1
>
> _______________________________________________
> Linux-nvme mailing list
> Linux-nvme at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-nvme/attachments/20170503/2d93fdcb/attachment.sig>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-03 10:05 ` Marta Rybczynska
@ 2017-05-03 15:08     ` Sagi Grimberg
  -1 siblings, 0 replies; 34+ messages in thread
From: Sagi Grimberg @ 2017-05-03 15:08 UTC (permalink / raw)
  To: Marta Rybczynska, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Leon Romanovsky,
	axboe-b10kYP2dOMg, Max Gurtovoy, Jason Gunthorpe,
	Christoph Hellwig, Keith Busch, Doug Ledford, Bart Van Assche,
	samuel jones


> +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);
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-03 15:08     ` Sagi Grimberg
  0 siblings, 0 replies; 34+ messages in thread
From: Sagi Grimberg @ 2017-05-03 15:08 UTC (permalink / raw)



> +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);

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-03 15:08     ` Sagi Grimberg
@ 2017-05-03 15:19         ` Marta Rybczynska
  -1 siblings, 0 replies; 34+ messages in thread
From: Marta Rybczynska @ 2017-05-03 15:19 UTC (permalink / raw)
  To: Sagi Grimberg
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Leon Romanovsky,
	axboe-b10kYP2dOMg, Max Gurtovoy, Jason Gunthorpe,
	Christoph Hellwig, Keith Busch, Doug Ledford, Bart Van Assche,
	samuel jones

>> +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
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-03 15:19         ` Marta Rybczynska
  0 siblings, 0 replies; 34+ messages in thread
From: Marta Rybczynska @ 2017-05-03 15:19 UTC (permalink / raw)


>> +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

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-03 15:19         ` Marta Rybczynska
@ 2017-05-03 15:45             ` Bart Van Assche
  -1 siblings, 0 replies; 34+ messages in thread
From: Bart Van Assche @ 2017-05-03 15:45 UTC (permalink / raw)
  To: mrybczyn-FNhOzJFKnXGHXe+LvDLADg, sagi-NQWnxTmZq1alnMjI0IkVqw
  Cc: leonro-VPRAkNaXOzVWk0Htik3J/w, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	hch-jcswGhMUV9g, axboe-b10kYP2dOMg,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	maxg-VPRAkNaXOzVWk0Htik3J/w, samuel.jones-FNhOzJFKnXGHXe+LvDLADg,
	jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/,
	keith.busch-ral2JQCrhuEAvxtiuMwx3w,
	dledford-H+wXaHxf7aLQT0dZR+AlfA

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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-03 15:45             ` Bart Van Assche
  0 siblings, 0 replies; 34+ messages in thread
From: Bart Van Assche @ 2017-05-03 15:45 UTC (permalink / raw)


On Wed, 2017-05-03@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.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-03 15:19         ` Marta Rybczynska
@ 2017-05-03 15:53             ` Jason Gunthorpe
  -1 siblings, 0 replies; 34+ messages in thread
From: Jason Gunthorpe @ 2017-05-03 15:53 UTC (permalink / raw)
  To: Marta Rybczynska
  Cc: Sagi Grimberg, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Leon Romanovsky,
	axboe-b10kYP2dOMg, Max Gurtovoy, Christoph Hellwig, Keith Busch,
	Doug Ledford, Bart Van Assche, samuel jones

On Wed, May 03, 2017 at 05:19:27PM +0200, Marta Rybczynska wrote:

> > 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.

The compiler switches divide/multiply by powers of two into fast bit shifts.

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

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-03 15:53             ` Jason Gunthorpe
  0 siblings, 0 replies; 34+ messages in thread
From: Jason Gunthorpe @ 2017-05-03 15:53 UTC (permalink / raw)


On Wed, May 03, 2017@05:19:27PM +0200, Marta Rybczynska wrote:

> > 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.

The compiler switches divide/multiply by powers of two into fast bit shifts.

Jason

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-03 15:53             ` Jason Gunthorpe
@ 2017-05-03 15:58                 ` Bart Van Assche
  -1 siblings, 0 replies; 34+ messages in thread
From: Bart Van Assche @ 2017-05-03 15:58 UTC (permalink / raw)
  To: jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/,
	mrybczyn-FNhOzJFKnXGHXe+LvDLADg
  Cc: leonro-VPRAkNaXOzVWk0Htik3J/w, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	sagi-NQWnxTmZq1alnMjI0IkVqw, hch-jcswGhMUV9g, axboe-b10kYP2dOMg,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	maxg-VPRAkNaXOzVWk0Htik3J/w, samuel.jones-FNhOzJFKnXGHXe+LvDLADg,
	keith.busch-ral2JQCrhuEAvxtiuMwx3w,
	dledford-H+wXaHxf7aLQT0dZR+AlfA

On Wed, 2017-05-03 at 09:53 -0600, Jason Gunthorpe wrote:
> On Wed, May 03, 2017 at 05:19:27PM +0200, Marta Rybczynska wrote:
> 
> > > 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.
> 
> The compiler switches divide/multiply by powers of two into fast bit shifts.

Hello Jason,

As far as I know the compiler only does that for compile-time constants. In
this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.

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

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-03 15:58                 ` Bart Van Assche
  0 siblings, 0 replies; 34+ messages in thread
From: Bart Van Assche @ 2017-05-03 15:58 UTC (permalink / raw)


On Wed, 2017-05-03@09:53 -0600, Jason Gunthorpe wrote:
> On Wed, May 03, 2017@05:19:27PM +0200, Marta Rybczynska wrote:
> 
> > > 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.
> 
> The compiler switches divide/multiply by powers of two into fast bit shifts.

Hello Jason,

As far as I know the compiler only does that for compile-time constants. In
this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.

Bart.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-03 15:58                 ` Bart Van Assche
@ 2017-05-03 16:01                     ` Sagi Grimberg
  -1 siblings, 0 replies; 34+ messages in thread
From: Sagi Grimberg @ 2017-05-03 16:01 UTC (permalink / raw)
  To: Bart Van Assche, jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/,
	mrybczyn-FNhOzJFKnXGHXe+LvDLADg
  Cc: leonro-VPRAkNaXOzVWk0Htik3J/w, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	hch-jcswGhMUV9g, axboe-b10kYP2dOMg,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	maxg-VPRAkNaXOzVWk0Htik3J/w, samuel.jones-FNhOzJFKnXGHXe+LvDLADg,
	keith.busch-ral2JQCrhuEAvxtiuMwx3w,
	dledford-H+wXaHxf7aLQT0dZR+AlfA


> Hello Jason,
>
> As far as I know the compiler only does that for compile-time constants. In
> this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.

We could theoretically do a (sig_count & max(queue_size / 2, 1)) but
that would only do well with power of 2 sized queues...
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-03 16:01                     ` Sagi Grimberg
  0 siblings, 0 replies; 34+ messages in thread
From: Sagi Grimberg @ 2017-05-03 16:01 UTC (permalink / raw)



> Hello Jason,
>
> As far as I know the compiler only does that for compile-time constants. In
> this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.

We could theoretically do a (sig_count & max(queue_size / 2, 1)) but
that would only do well with power of 2 sized queues...

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-03 15:58                 ` Bart Van Assche
@ 2017-05-03 16:17                     ` Doug Ledford
  -1 siblings, 0 replies; 34+ messages in thread
From: Doug Ledford @ 2017-05-03 16:17 UTC (permalink / raw)
  To: Bart Van Assche, jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/,
	mrybczyn-FNhOzJFKnXGHXe+LvDLADg
  Cc: leonro-VPRAkNaXOzVWk0Htik3J/w, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	sagi-NQWnxTmZq1alnMjI0IkVqw, hch-jcswGhMUV9g, axboe-b10kYP2dOMg,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	maxg-VPRAkNaXOzVWk0Htik3J/w, samuel.jones-FNhOzJFKnXGHXe+LvDLADg,
	keith.busch-ral2JQCrhuEAvxtiuMwx3w


[-- Attachment #1.1: Type: text/plain, Size: 1255 bytes --]

On 5/3/2017 11:58 AM, Bart Van Assche wrote:
> On Wed, 2017-05-03 at 09:53 -0600, Jason Gunthorpe wrote:
>> On Wed, May 03, 2017 at 05:19:27PM +0200, Marta Rybczynska wrote:
>>
>>>> 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.
>>
>> The compiler switches divide/multiply by powers of two into fast bit shifts.
> 
> Hello Jason,
> 
> As far as I know the compiler only does that for compile-time constants. In
> this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.

Sure it is.  The only thing that needs to be constant for the compiler
to do the right thing is the '/ 2' part.  queue_size need not be
constant, and the max is performed after the division.  I would fully
expect the compiler to get this right and convert it internally to the
equivalent bit shift, but if it didn't you could always just write it
that way in the first place:

queue->sig_limit = max(queue->queue_size >> 1, 1);


-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
    GPG Key ID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-03 16:17                     ` Doug Ledford
  0 siblings, 0 replies; 34+ messages in thread
From: Doug Ledford @ 2017-05-03 16:17 UTC (permalink / raw)


On 5/3/2017 11:58 AM, Bart Van Assche wrote:
> On Wed, 2017-05-03@09:53 -0600, Jason Gunthorpe wrote:
>> On Wed, May 03, 2017@05:19:27PM +0200, Marta Rybczynska wrote:
>>
>>>> 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.
>>
>> The compiler switches divide/multiply by powers of two into fast bit shifts.
> 
> Hello Jason,
> 
> As far as I know the compiler only does that for compile-time constants. In
> this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.

Sure it is.  The only thing that needs to be constant for the compiler
to do the right thing is the '/ 2' part.  queue_size need not be
constant, and the max is performed after the division.  I would fully
expect the compiler to get this right and convert it internally to the
equivalent bit shift, but if it didn't you could always just write it
that way in the first place:

queue->sig_limit = max(queue->queue_size >> 1, 1);


-- 
Doug Ledford <dledford at redhat.com>
    GPG Key ID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 884 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-nvme/attachments/20170503/c13ad3ac/attachment-0001.sig>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-03 16:17                     ` Doug Ledford
@ 2017-05-03 16:24                         ` Bart Van Assche
  -1 siblings, 0 replies; 34+ messages in thread
From: Bart Van Assche @ 2017-05-03 16:24 UTC (permalink / raw)
  To: jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/,
	mrybczyn-FNhOzJFKnXGHXe+LvDLADg, dledford-H+wXaHxf7aLQT0dZR+AlfA
  Cc: leonro-VPRAkNaXOzVWk0Htik3J/w, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	sagi-NQWnxTmZq1alnMjI0IkVqw, hch-jcswGhMUV9g, axboe-b10kYP2dOMg,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	maxg-VPRAkNaXOzVWk0Htik3J/w, samuel.jones-FNhOzJFKnXGHXe+LvDLADg,
	keith.busch-ral2JQCrhuEAvxtiuMwx3w

On Wed, 2017-05-03 at 12:17 -0400, Doug Ledford wrote:
> On 5/3/2017 11:58 AM, Bart Van Assche wrote:
> > On Wed, 2017-05-03 at 09:53 -0600, Jason Gunthorpe wrote:
> > > On Wed, May 03, 2017 at 05:19:27PM +0200, Marta Rybczynska wrote:
> > > 
> > > > > 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.
> > > 
> > > The compiler switches divide/multiply by powers of two into fast bit shifts.
> > 
> > Hello Jason,
> > 
> > As far as I know the compiler only does that for compile-time constants. In
> > this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.
> 
> Sure it is.  The only thing that needs to be constant for the compiler
> to do the right thing is the '/ 2' part.  queue_size need not be
> constant, and the max is performed after the division.  I would fully
> expect the compiler to get this right and convert it internally to the
> equivalent bit shift, but if it didn't you could always just write it
> that way in the first place:
> 
> queue->sig_limit = max(queue->queue_size >> 1, 1);

Hello Doug,

In my comment I was referring to "% max(queue_size / 2, 1)" and not to
"queue_size / 2".

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

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-03 16:24                         ` Bart Van Assche
  0 siblings, 0 replies; 34+ messages in thread
From: Bart Van Assche @ 2017-05-03 16:24 UTC (permalink / raw)


On Wed, 2017-05-03@12:17 -0400, Doug Ledford wrote:
> On 5/3/2017 11:58 AM, Bart Van Assche wrote:
> > On Wed, 2017-05-03@09:53 -0600, Jason Gunthorpe wrote:
> > > On Wed, May 03, 2017@05:19:27PM +0200, Marta Rybczynska wrote:
> > > 
> > > > > 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.
> > > 
> > > The compiler switches divide/multiply by powers of two into fast bit shifts.
> > 
> > Hello Jason,
> > 
> > As far as I know the compiler only does that for compile-time constants. In
> > this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.
> 
> Sure it is.  The only thing that needs to be constant for the compiler
> to do the right thing is the '/ 2' part.  queue_size need not be
> constant, and the max is performed after the division.  I would fully
> expect the compiler to get this right and convert it internally to the
> equivalent bit shift, but if it didn't you could always just write it
> that way in the first place:
> 
> queue->sig_limit = max(queue->queue_size >> 1, 1);

Hello Doug,

In my comment I was referring to "% max(queue_size / 2, 1)" and not to
"queue_size / 2".

Bart.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-03 16:01                     ` Sagi Grimberg
@ 2017-05-03 16:27                         ` Leon Romanovsky
  -1 siblings, 0 replies; 34+ messages in thread
From: Leon Romanovsky @ 2017-05-03 16:27 UTC (permalink / raw)
  To: Sagi Grimberg
  Cc: Bart Van Assche, jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/,
	mrybczyn-FNhOzJFKnXGHXe+LvDLADg,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, hch-jcswGhMUV9g,
	axboe-b10kYP2dOMg, linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	maxg-VPRAkNaXOzVWk0Htik3J/w, samuel.jones-FNhOzJFKnXGHXe+LvDLADg,
	keith.busch-ral2JQCrhuEAvxtiuMwx3w,
	dledford-H+wXaHxf7aLQT0dZR+AlfA

[-- Attachment #1: Type: text/plain, Size: 648 bytes --]

On Wed, May 03, 2017 at 07:01:14PM +0300, Sagi Grimberg wrote:
>
> > Hello Jason,
> >
> > As far as I know the compiler only does that for compile-time constants. In
> > this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.
>
> We could theoretically do a (sig_count & max(queue_size / 2, 1)) but
> that would only do well with power of 2 sized queues...

IMHO, It is not-so-big-deal limitation.

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-03 16:27                         ` Leon Romanovsky
  0 siblings, 0 replies; 34+ messages in thread
From: Leon Romanovsky @ 2017-05-03 16:27 UTC (permalink / raw)


On Wed, May 03, 2017@07:01:14PM +0300, Sagi Grimberg wrote:
>
> > Hello Jason,
> >
> > As far as I know the compiler only does that for compile-time constants. In
> > this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.
>
> We could theoretically do a (sig_count & max(queue_size / 2, 1)) but
> that would only do well with power of 2 sized queues...

IMHO, It is not-so-big-deal limitation.

> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-nvme/attachments/20170503/bb3a3888/attachment.sig>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-03 16:27                         ` Leon Romanovsky
@ 2017-05-03 16:37                             ` Bart Van Assche
  -1 siblings, 0 replies; 34+ messages in thread
From: Bart Van Assche @ 2017-05-03 16:37 UTC (permalink / raw)
  To: leonro-VPRAkNaXOzVWk0Htik3J/w, sagi-NQWnxTmZq1alnMjI0IkVqw
  Cc: mrybczyn-FNhOzJFKnXGHXe+LvDLADg,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, hch-jcswGhMUV9g,
	axboe-b10kYP2dOMg, linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	maxg-VPRAkNaXOzVWk0Htik3J/w, samuel.jones-FNhOzJFKnXGHXe+LvDLADg,
	jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/,
	keith.busch-ral2JQCrhuEAvxtiuMwx3w,
	dledford-H+wXaHxf7aLQT0dZR+AlfA

On Wed, 2017-05-03 at 19:27 +0300, Leon Romanovsky wrote:
> On Wed, May 03, 2017 at 07:01:14PM +0300, Sagi Grimberg wrote:
> > > As far as I know the compiler only does that for compile-time constants. In
> > > this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.
> > 
> > We could theoretically do a (sig_count & max(queue_size / 2, 1)) but
> > that would only do well with power of 2 sized queues...
> 
> IMHO, It is not-so-big-deal limitation.

Hello Marta, Sagi and Leon,

How about changing nvme_rdma_init_sig_count() such that it always returns
a power of two? The "+ 1" in the code below makes sure that the argument of
ilog2() is larger than zero even if queue_size == 1. I'm not sure whether
the time needed to compute ilog2() would make it necessary to cache the
nvme_rdma_init_sig_count() return value.

static inline int nvme_rdma_init_sig_count(int queue_size)
{
        /* Return the largest power of two that is not above half of (queue size + 1) */
        return 1 << ilog2((queue_size + 1) / 2);
}

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

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-03 16:37                             ` Bart Van Assche
  0 siblings, 0 replies; 34+ messages in thread
From: Bart Van Assche @ 2017-05-03 16:37 UTC (permalink / raw)


On Wed, 2017-05-03@19:27 +0300, Leon Romanovsky wrote:
> On Wed, May 03, 2017@07:01:14PM +0300, Sagi Grimberg wrote:
> > > As far as I know the compiler only does that for compile-time constants. In
> > > this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.
> > 
> > We could theoretically do a (sig_count & max(queue_size / 2, 1)) but
> > that would only do well with power of 2 sized queues...
> 
> IMHO, It is not-so-big-deal limitation.

Hello Marta, Sagi and Leon,

How about changing nvme_rdma_init_sig_count() such that it always returns
a power of two? The "+ 1" in the code below makes sure that the argument of
ilog2() is larger than zero even if queue_size == 1. I'm not sure whether
the time needed to compute ilog2() would make it necessary to cache the
nvme_rdma_init_sig_count() return value.

static inline int nvme_rdma_init_sig_count(int queue_size)
{
        /* Return the largest power of two that is not above half of (queue size + 1) */
 ???????return 1 << ilog2((queue_size + 1) / 2);
}

Bart.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-03 16:37                             ` Bart Van Assche
@ 2017-05-03 16:49                                 ` Sagi Grimberg
  -1 siblings, 0 replies; 34+ messages in thread
From: Sagi Grimberg @ 2017-05-03 16:49 UTC (permalink / raw)
  To: Bart Van Assche, leonro-VPRAkNaXOzVWk0Htik3J/w
  Cc: mrybczyn-FNhOzJFKnXGHXe+LvDLADg,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, hch-jcswGhMUV9g,
	axboe-b10kYP2dOMg, linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	maxg-VPRAkNaXOzVWk0Htik3J/w, samuel.jones-FNhOzJFKnXGHXe+LvDLADg,
	jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/,
	keith.busch-ral2JQCrhuEAvxtiuMwx3w,
	dledford-H+wXaHxf7aLQT0dZR+AlfA


> Hello Marta, Sagi and Leon,
>
> How about changing nvme_rdma_init_sig_count() such that it always returns
> a power of two? The "+ 1" in the code below makes sure that the argument of
> ilog2() is larger than zero even if queue_size == 1. I'm not sure whether
> the time needed to compute ilog2() would make it necessary to cache the
> nvme_rdma_init_sig_count() return value.

ilog2 is pretty fast.

> static inline int nvme_rdma_init_sig_count(int queue_size)
> {
>         /* Return the largest power of two that is not above half of (queue size + 1) */
>         return 1 << ilog2((queue_size + 1) / 2);
> }

That'd work too I think...
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-03 16:49                                 ` Sagi Grimberg
  0 siblings, 0 replies; 34+ messages in thread
From: Sagi Grimberg @ 2017-05-03 16:49 UTC (permalink / raw)



> Hello Marta, Sagi and Leon,
>
> How about changing nvme_rdma_init_sig_count() such that it always returns
> a power of two? The "+ 1" in the code below makes sure that the argument of
> ilog2() is larger than zero even if queue_size == 1. I'm not sure whether
> the time needed to compute ilog2() would make it necessary to cache the
> nvme_rdma_init_sig_count() return value.

ilog2 is pretty fast.

> static inline int nvme_rdma_init_sig_count(int queue_size)
> {
>         /* Return the largest power of two that is not above half of (queue size + 1) */
>         return 1 << ilog2((queue_size + 1) / 2);
> }

That'd work too I think...

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-03 16:24                         ` Bart Van Assche
@ 2017-05-03 19:07                             ` Doug Ledford
  -1 siblings, 0 replies; 34+ messages in thread
From: Doug Ledford @ 2017-05-03 19:07 UTC (permalink / raw)
  To: Bart Van Assche, jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/,
	mrybczyn-FNhOzJFKnXGHXe+LvDLADg
  Cc: leonro-VPRAkNaXOzVWk0Htik3J/w, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	sagi-NQWnxTmZq1alnMjI0IkVqw, hch-jcswGhMUV9g, axboe-b10kYP2dOMg,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	maxg-VPRAkNaXOzVWk0Htik3J/w, samuel.jones-FNhOzJFKnXGHXe+LvDLADg,
	keith.busch-ral2JQCrhuEAvxtiuMwx3w


[-- Attachment #1.1: Type: text/plain, Size: 1594 bytes --]

On 5/3/2017 12:24 PM, Bart Van Assche wrote:
> On Wed, 2017-05-03 at 12:17 -0400, Doug Ledford wrote:
>> On 5/3/2017 11:58 AM, Bart Van Assche wrote:
>>> On Wed, 2017-05-03 at 09:53 -0600, Jason Gunthorpe wrote:
>>>> On Wed, May 03, 2017 at 05:19:27PM +0200, Marta Rybczynska wrote:
>>>>
>>>>>> 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.
>>>>
>>>> The compiler switches divide/multiply by powers of two into fast bit shifts.
>>>
>>> Hello Jason,
>>>
>>> As far as I know the compiler only does that for compile-time constants. In
>>> this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.
>>
>> Sure it is.  The only thing that needs to be constant for the compiler
>> to do the right thing is the '/ 2' part.  queue_size need not be
>> constant, and the max is performed after the division.  I would fully
>> expect the compiler to get this right and convert it internally to the
>> equivalent bit shift, but if it didn't you could always just write it
>> that way in the first place:
>>
>> queue->sig_limit = max(queue->queue_size >> 1, 1);
> 
> Hello Doug,
> 
> In my comment I was referring to "% max(queue_size / 2, 1)" and not to
> "queue_size / 2".

Sorry, too much context was cut for that to come through.


-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
    GPG Key ID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-03 19:07                             ` Doug Ledford
  0 siblings, 0 replies; 34+ messages in thread
From: Doug Ledford @ 2017-05-03 19:07 UTC (permalink / raw)


On 5/3/2017 12:24 PM, Bart Van Assche wrote:
> On Wed, 2017-05-03@12:17 -0400, Doug Ledford wrote:
>> On 5/3/2017 11:58 AM, Bart Van Assche wrote:
>>> On Wed, 2017-05-03@09:53 -0600, Jason Gunthorpe wrote:
>>>> On Wed, May 03, 2017@05:19:27PM +0200, Marta Rybczynska wrote:
>>>>
>>>>>> 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.
>>>>
>>>> The compiler switches divide/multiply by powers of two into fast bit shifts.
>>>
>>> Hello Jason,
>>>
>>> As far as I know the compiler only does that for compile-time constants. In
>>> this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.
>>
>> Sure it is.  The only thing that needs to be constant for the compiler
>> to do the right thing is the '/ 2' part.  queue_size need not be
>> constant, and the max is performed after the division.  I would fully
>> expect the compiler to get this right and convert it internally to the
>> equivalent bit shift, but if it didn't you could always just write it
>> that way in the first place:
>>
>> queue->sig_limit = max(queue->queue_size >> 1, 1);
> 
> Hello Doug,
> 
> In my comment I was referring to "% max(queue_size / 2, 1)" and not to
> "queue_size / 2".

Sorry, too much context was cut for that to come through.


-- 
Doug Ledford <dledford at redhat.com>
    GPG Key ID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 884 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-nvme/attachments/20170503/d21eb6b0/attachment.sig>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-03 16:37                             ` Bart Van Assche
@ 2017-05-04 12:50                                 ` Marta Rybczynska
  -1 siblings, 0 replies; 34+ messages in thread
From: Marta Rybczynska @ 2017-05-04 12:50 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: leonro-VPRAkNaXOzVWk0Htik3J/w, sagi-NQWnxTmZq1alnMjI0IkVqw,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA, hch-jcswGhMUV9g,
	axboe-b10kYP2dOMg, linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	maxg-VPRAkNaXOzVWk0Htik3J/w, samuel jones,
	jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/,
	keith busch, dledford-H+wXaHxf7aLQT0dZR+AlfA

> On Wed, 2017-05-03 at 19:27 +0300, Leon Romanovsky wrote:
>> On Wed, May 03, 2017 at 07:01:14PM +0300, Sagi Grimberg wrote:
>> > > As far as I know the compiler only does that for compile-time constants. In
>> > > this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.
>> > 
>> > We could theoretically do a (sig_count & max(queue_size / 2, 1)) but
>> > that would only do well with power of 2 sized queues...
>> 
>> IMHO, It is not-so-big-deal limitation.
> 
> Hello Marta, Sagi and Leon,
> 
> How about changing nvme_rdma_init_sig_count() such that it always returns
> a power of two? The "+ 1" in the code below makes sure that the argument of
> ilog2() is larger than zero even if queue_size == 1. I'm not sure whether
> the time needed to compute ilog2() would make it necessary to cache the
> nvme_rdma_init_sig_count() return value.
> 
> static inline int nvme_rdma_init_sig_count(int queue_size)
> {
>        /* Return the largest power of two that is not above half of (queue size + 1) */
>        return 1 << ilog2((queue_size + 1) / 2);
> }
> 
> Bart.

This looks like a good idea to me. Then the division can change into
an AND. I'll come back with another version soon.

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

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-04 12:50                                 ` Marta Rybczynska
  0 siblings, 0 replies; 34+ messages in thread
From: Marta Rybczynska @ 2017-05-04 12:50 UTC (permalink / raw)


> On Wed, 2017-05-03@19:27 +0300, Leon Romanovsky wrote:
>> On Wed, May 03, 2017@07:01:14PM +0300, Sagi Grimberg wrote:
>> > > As far as I know the compiler only does that for compile-time constants. In
>> > > this case the divisor (max(queue_size / 2, 1)) is not a compile-time constant.
>> > 
>> > We could theoretically do a (sig_count & max(queue_size / 2, 1)) but
>> > that would only do well with power of 2 sized queues...
>> 
>> IMHO, It is not-so-big-deal limitation.
> 
> Hello Marta, Sagi and Leon,
> 
> How about changing nvme_rdma_init_sig_count() such that it always returns
> a power of two? The "+ 1" in the code below makes sure that the argument of
> ilog2() is larger than zero even if queue_size == 1. I'm not sure whether
> the time needed to compute ilog2() would make it necessary to cache the
> nvme_rdma_init_sig_count() return value.
> 
> static inline int nvme_rdma_init_sig_count(int queue_size)
> {
>        /* Return the largest power of two that is not above half of (queue size + 1) */
> ???????return 1 << ilog2((queue_size + 1) / 2);
> }
> 
> Bart.

This looks like a good idea to me. Then the division can change into
an AND. I'll come back with another version soon.

Marta

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-04 12:50                                 ` Marta Rybczynska
@ 2017-05-17  9:02                                     ` Christoph Hellwig
  -1 siblings, 0 replies; 34+ messages in thread
From: Christoph Hellwig @ 2017-05-17  9:02 UTC (permalink / raw)
  To: Marta Rybczynska
  Cc: Bart Van Assche, jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/,
	sagi-NQWnxTmZq1alnMjI0IkVqw, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, axboe-b10kYP2dOMg,
	leonro-VPRAkNaXOzVWk0Htik3J/w, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	samuel jones, maxg-VPRAkNaXOzVWk0Htik3J/w, keith busch,
	hch-jcswGhMUV9g

> This looks like a good idea to me. Then the division can change into
> an AND. I'll come back with another version soon.

Did you get a chance to look at this?  I'm tempted to just merge v2
with the division in it and leave any fixing up for the time we move this
guestimate into the rdma core..
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-17  9:02                                     ` Christoph Hellwig
  0 siblings, 0 replies; 34+ messages in thread
From: Christoph Hellwig @ 2017-05-17  9:02 UTC (permalink / raw)


> This looks like a good idea to me. Then the division can change into
> an AND. I'll come back with another version soon.

Did you get a chance to look at this?  I'm tempted to just merge v2
with the division in it and leave any fixing up for the time we move this
guestimate into the rdma core..

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
  2017-05-17  9:02                                     ` Christoph Hellwig
@ 2017-05-17 12:50                                         ` Marta Rybczynska
  -1 siblings, 0 replies; 34+ messages in thread
From: Marta Rybczynska @ 2017-05-17 12:50 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Bart Van Assche, jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/,
	sagi-NQWnxTmZq1alnMjI0IkVqw, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, axboe-b10kYP2dOMg,
	leonro-VPRAkNaXOzVWk0Htik3J/w, dledford-H+wXaHxf7aLQT0dZR+AlfA,
	samuel jones, maxg-VPRAkNaXOzVWk0Htik3J/w, keith busch,
	hch-jcswGhMUV9g


>> This looks like a good idea to me. Then the division can change into
>> an AND. I'll come back with another version soon.
> 
> Did you get a chance to look at this?  I'm tempted to just merge v2
> with the division in it and leave any fixing up for the time we move this
> guestimate into the rdma core..

Yes, I've done another iteration but it needs testing. I'd prefer one of
the later versions finally. It seems that we're also seeing the
effect of the race condition on the signalling variable. 

However, we can also go incremental: do a like-v2 fix first, then fix the
races in nvme and then add a more general fix for all rdma.

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

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32
@ 2017-05-17 12:50                                         ` Marta Rybczynska
  0 siblings, 0 replies; 34+ messages in thread
From: Marta Rybczynska @ 2017-05-17 12:50 UTC (permalink / raw)



>> This looks like a good idea to me. Then the division can change into
>> an AND. I'll come back with another version soon.
> 
> Did you get a chance to look at this?  I'm tempted to just merge v2
> with the division in it and leave any fixing up for the time we move this
> guestimate into the rdma core..

Yes, I've done another iteration but it needs testing. I'd prefer one of
the later versions finally. It seems that we're also seeing the
effect of the race condition on the signalling variable. 

However, we can also go incremental: do a like-v2 fix first, then fix the
races in nvme and then add a more general fix for all rdma.

Marta

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2017-05-17 12:50 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-03 10:05 [PATCH v4, under testing] nvme-rdma: support devices with queue size < 32 Marta Rybczynska
2017-05-03 10:05 ` Marta Rybczynska
     [not found] ` <79901165.5342369.1493805915415.JavaMail.zimbra-FNhOzJFKnXGHXe+LvDLADg@public.gmane.org>
2017-05-03 11:17   ` Leon Romanovsky
2017-05-03 11:17     ` Leon Romanovsky
2017-05-03 15:08   ` Sagi Grimberg
2017-05-03 15:08     ` Sagi Grimberg
     [not found]     ` <823aa3f0-685f-4569-11d6-238cc4f0b126-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-05-03 15:19       ` Marta Rybczynska
2017-05-03 15:19         ` Marta Rybczynska
     [not found]         ` <780938034.8003164.1493824767084.JavaMail.zimbra-FNhOzJFKnXGHXe+LvDLADg@public.gmane.org>
2017-05-03 15:45           ` Bart Van Assche
2017-05-03 15:45             ` Bart Van Assche
2017-05-03 15:53           ` Jason Gunthorpe
2017-05-03 15:53             ` Jason Gunthorpe
     [not found]             ` <20170503155316.GA14334-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-05-03 15:58               ` Bart Van Assche
2017-05-03 15:58                 ` Bart Van Assche
     [not found]                 ` <1493827096.3901.4.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-05-03 16:01                   ` Sagi Grimberg
2017-05-03 16:01                     ` Sagi Grimberg
     [not found]                     ` <77ada146-67eb-9dce-d252-6ac630c9a1e8-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2017-05-03 16:27                       ` Leon Romanovsky
2017-05-03 16:27                         ` Leon Romanovsky
     [not found]                         ` <20170503162708.GO22833-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-05-03 16:37                           ` Bart Van Assche
2017-05-03 16:37                             ` Bart Van Assche
     [not found]                             ` <1493829456.3901.13.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-05-03 16:49                               ` Sagi Grimberg
2017-05-03 16:49                                 ` Sagi Grimberg
2017-05-04 12:50                               ` Marta Rybczynska
2017-05-04 12:50                                 ` Marta Rybczynska
     [not found]                                 ` <310709514.10440651.1493902200194.JavaMail.zimbra-FNhOzJFKnXGHXe+LvDLADg@public.gmane.org>
2017-05-17  9:02                                   ` Christoph Hellwig
2017-05-17  9:02                                     ` Christoph Hellwig
     [not found]                                     ` <20170517090202.GA23880-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2017-05-17 12:50                                       ` Marta Rybczynska
2017-05-17 12:50                                         ` Marta Rybczynska
2017-05-03 16:17                   ` Doug Ledford
2017-05-03 16:17                     ` Doug Ledford
     [not found]                     ` <92010426-c898-0a56-e615-bbf6eb1c5e7e-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2017-05-03 16:24                       ` Bart Van Assche
2017-05-03 16:24                         ` Bart Van Assche
     [not found]                         ` <1493828639.3901.11.camel-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2017-05-03 19:07                           ` Doug Ledford
2017-05-03 19:07                             ` Doug Ledford

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.