Skip to contentSkip to conversation

providers/rxe: Replace '%' with '&' in check_qp_queue_full()

PATCH Applied Xiao Yang 3 participants 3 messages Jan 21, 2022 – Jan 23, 2022 InfiniBand

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

PATCH v2 1/1 providers/rxe: Replace '%' with '&' in check_qp_queue_full()

The expression "cons == ((qp->cur_index + 1) % q->index_mask)" doesn't check the state of queue (full or empty) correctly. For example:
If cons and qp->cur_index are 0 and q->index_mask is 1, the queue is actually empty but check_qp_queue_full() reports full (ENOSPC).

Fixes 1a894ca10105 ("Providers/rxe: Implement ibv_create_qp_ex verb")
---
 providers/rxe/rxe_queue.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
providers/rxe/rxe_queue.h +1 -1
index 6de8140c..708e76ac 100644
@@ -205,7 +205,7 @@ static inline int check_qp_queue_full(struct rxe_qp *qp)
 	if (qp->err)
 		goto err;
 
-	if (cons == ((qp->cur_index + 1) % q->index_mask))
+	if (cons == ((qp->cur_index + 1) & q->index_mask))
 		qp->err = ENOSPC;
 err:
 	return qp->err;
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 17 lines · Xiao Yang

The expression "cons == ((qp->cur_index + 1) % q->index_mask)" doesn't check the state of queue (full or empty) correctly. For example:
If cons and qp->cur_index are 0 and q->index_mask is 1, the queue is actually empty but check_qp_queue_full() reports full (ENOSPC).

Fixes 1a894ca10105 ("Providers/rxe: Implement ibv_create_qp_ex verb")
---
 providers/rxe/rxe_queue.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
providers/rxe/rxe_queue.h +0 -0
index 6de8140c..708e76ac 100644

providers/rxe/rxe_queue.h static inline int check_qp_queue_full(struct rxe_qp *qp) · line 211

Quoted 8 lines
providers/rxe/rxe_queue.h +1 -1
@@ -205,7 +205,7 @@ static inline int check_qp_queue_full(struct rxe_qp *qp)
 	if (qp->err)
 		goto err;
 
-	if (cons == ((qp->cur_index + 1) % q->index_mask))
+	if (cons == ((qp->cur_index + 1) & q->index_mask))
 		qp->err = ENOSPC;
 err:
 	return qp->err;

This is fine.

#2 lore raw
In reply to Xiao Yang
Quoted 11 lines · Xiao Yang

The expression "cons == ((qp->cur_index + 1) % q->index_mask)" doesn't check the state of queue (full or empty) correctly. For example:
If cons and qp->cur_index are 0 and q->index_mask is 1, the queue is actually empty but check_qp_queue_full() reports full (ENOSPC).

Fixes 1a894ca10105 ("Providers/rxe: Implement ibv_create_qp_ex verb")
---
 providers/rxe/rxe_queue.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, applied.