[openib-general] [PATCH] (repost) no qp lock on poll, separate sq/rq locks

Michael S. Tsirkin mst at mellanox.co.il
Fri Feb 25 04:31:35 PST 2005


Quoting r. Roland Dreier <roland at topspin.com>:
> Subject: Re: [openib-general] [PATCH] (repost) no qp lock on poll, separate sq/rq locks
> 
> Ugh, I think I missed something when I thought about this the first
> time around.  It seems the test for WQ overflow assumes that all WQs
> have a power-of-2 size, which we currently don't enforce for Tavor
> mode.  It seems there are two possible solutions:
> 
>   Round up WQ sizes for Tavor as well.  I don't like this because it
>   could potentially use a lot of extra memory.
> 
>   Or, add one more counter back into the WQ struct so we can keep
>   track of both the next index to use as well as the total number of
>   WQEs posted in Tavor mode (we still only need one counter in
>   mem-free mode).
> 
> I implemented the second option.  Does this patch look reasonable?
> 
>  - R.
> 

True, I forgot that qp size may not be a power of 2 for tavor.
Good catch.

But, it seems to me your patch does not handle unsignaled WQEs, since
tail is incremented by 1 on each completion.
I propose reverting, and applying the following simple patch.


diff -rup hw/mthca_old/mthca_qp.c hw/mthca/mthca_qp.c
--- hw/mthca_old/mthca_qp.c	2005-02-25 14:04:35.000000000 +0200
+++ hw/mthca/mthca_qp.c	2005-02-25 14:17:25.000000000 +0200
@@ -1403,13 +1403,15 @@ static inline int mthca_wq_overflow(stru
 	int cur;
 	struct mthca_cq* cq;
 
-	cur = (wq->next - wq->last_comp - 1) & (wq->max - 1);
+	cur = wq->next > wq->last_comp ? wq->next - wq->last_comp - 1 :
+		wq->next + wq->max - wq->last_comp - 1;
 	if (likely(cur + nreq < wq->max))
 		return 0;
 
 	cq = to_mcq(ib_cq);
 	spin_lock(&cq->lock);
-	cur = (wq->next - wq->last_comp - 1) & (wq->max - 1);
+	cur = wq->next > wq->last_comp ? wq->next - wq->last_comp - 1 :
+		wq->next + wq->max - wq->last_comp - 1;
 	spin_unlock(&cq->lock);
 
 	return cur + nreq >= wq->max;


-- 
MST - Michael S. Tsirkin



More information about the general mailing list