Skip to content

Commit 5a25bfd

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
svcrdma: Limit RQ depth
Ensure that the chosen Receive Queue depth for a newly created transport does not overrun the QP WR limit of the underlying device. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 193bcb7 commit 5a25bfd

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

net/sunrpc/xprtrdma/svc_rdma_transport.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ static bool svc_rdma_prealloc_ctxts(struct svcxprt_rdma *xprt)
167167
{
168168
unsigned int i;
169169

170-
/* Each RPC/RDMA credit can consume a number of send
171-
* and receive WQEs. One ctxt is allocated for each.
170+
/* Each RPC/RDMA credit can consume one Receive and
171+
* one Send WQE at the same time.
172172
*/
173173
i = xprt->sc_sq_depth + xprt->sc_rq_depth;
174174

@@ -742,13 +742,18 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
742742
newxprt->sc_max_sge = min((size_t)dev->attrs.max_sge,
743743
(size_t)RPCSVC_MAXPAGES);
744744
newxprt->sc_max_req_size = svcrdma_max_req_size;
745-
newxprt->sc_max_requests = min_t(u32, dev->attrs.max_qp_wr,
746-
svcrdma_max_requests);
747-
newxprt->sc_fc_credits = cpu_to_be32(newxprt->sc_max_requests);
748-
newxprt->sc_max_bc_requests = min_t(u32, dev->attrs.max_qp_wr,
749-
svcrdma_max_bc_requests);
745+
newxprt->sc_max_requests = svcrdma_max_requests;
746+
newxprt->sc_max_bc_requests = svcrdma_max_bc_requests;
750747
newxprt->sc_rq_depth = newxprt->sc_max_requests +
751748
newxprt->sc_max_bc_requests;
749+
if (newxprt->sc_rq_depth > dev->attrs.max_qp_wr) {
750+
pr_warn("svcrdma: reducing receive depth to %d\n",
751+
dev->attrs.max_qp_wr);
752+
newxprt->sc_rq_depth = dev->attrs.max_qp_wr;
753+
newxprt->sc_max_requests = newxprt->sc_rq_depth - 2;
754+
newxprt->sc_max_bc_requests = 2;
755+
}
756+
newxprt->sc_fc_credits = cpu_to_be32(newxprt->sc_max_requests);
752757
newxprt->sc_sq_depth = newxprt->sc_rq_depth;
753758
atomic_set(&newxprt->sc_sq_avail, newxprt->sc_sq_depth);
754759

0 commit comments

Comments
 (0)