On Tue, Jan 11, 2022 at 09:19:46AM +0000, yangx.jy@xxxxxxxxxxx wrote: > On 2022/1/11 14:11, Leon Romanovsky wrote: > > On Tue, Jan 11, 2022 at 10:24:04AM +0800, Xiao Yang wrote: > >> The expression "cons == ((qp->cur_index + 1) % q->index_mask)" mistakenly > >> assumes the queue is full when the number of entires is equal to "maximum - 1" > >> (maximum is correct). > >> > >> For example: > >> If cons and qp->cur_index are 0 and q->index_mask is 1, check_qp_queue_full() > >> reports ENOSPC. > >> > >> Fixes: 1a894ca10105 ("Providers/rxe: Implement ibv_create_qp_ex verb") > >> Signed-off-by: Xiao Yang<yangx.jy@xxxxxxxxxxx> > >> --- > >> providers/rxe/rxe_queue.h | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/providers/rxe/rxe_queue.h b/providers/rxe/rxe_queue.h > >> index 6de8140c..708e76ac 100644 > >> --- a/providers/rxe/rxe_queue.h > >> +++ b/providers/rxe/rxe_queue.h > >> @@ -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)) > > Please reuse queue_full(). > Hi Leon, > > qp->cur_index and qp->err are introduced for new ibv_wr_* APIs and I am > not sure if check_qp_queue_full() can be replaced with queue_full(). > > Bob, do you have any suggestion? diff --git a/providers/rxe/rxe_queue.h b/providers/rxe/rxe_queue.h index 6de8140c..83eb4a5f 100644 --- a/providers/rxe/rxe_queue.h +++ b/providers/rxe/rxe_queue.h @@ -198,14 +198,11 @@ static inline void advance_qp_cur_index(struct rxe_qp *qp) static inline int check_qp_queue_full(struct rxe_qp *qp) { struct rxe_queue_buf *q = qp->sq.queue; - uint32_t cons; - - cons = atomic_load_explicit(consumer(q), memory_order_acquire); if (qp->err) goto err; - if (cons == ((qp->cur_index + 1) % q->index_mask)) + if (queue_full(q)) qp->err = ENOSPC; err: return qp->err; (END) > > Best Regards, > Xiao Yang > > Thanks > > > >> qp->err = ENOSPC; > >> err: > >> return qp->err; > >> -- > >> 2.25.1 > >> > >> > >>