Skip to content

Commit 26fb225

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
svcrdma: Estimate Send Queue depth properly
The rdma_rw API adjusts max_send_wr upwards during the rdma_create_qp() call. If the ULP actually wants to take advantage of these extra resources, it must increase the size of its send completion queue (created before rdma_create_qp is called) and increase its send queue accounting limit. Use the new rdma_rw_mr_factor API to figure out the correct value to use for the Send Queue and Send Completion Queue depths. And, ensure that the chosen Send Queue depth for a newly created transport does not overrun the QP WR limit of the underlying device. Lastly, there's no longer a need to carry the Send Queue depth in struct svcxprt_rdma, since the value is used only in the svc_rdma_accept() path. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 0062818 commit 26fb225

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

net/sunrpc/xprtrdma/svc_rdma_transport.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <linux/workqueue.h>
5252
#include <rdma/ib_verbs.h>
5353
#include <rdma/rdma_cm.h>
54+
#include <rdma/rw.h>
5455
#include <linux/sunrpc/svc_rdma.h>
5556
#include <linux/export.h>
5657
#include "xprt_rdma.h"
@@ -713,7 +714,7 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
713714
struct ib_qp_init_attr qp_attr;
714715
struct ib_device *dev;
715716
struct sockaddr *sap;
716-
unsigned int i;
717+
unsigned int i, ctxts;
717718
int ret = 0;
718719

719720
listen_rdma = container_of(xprt, struct svcxprt_rdma, sc_xprt);
@@ -754,7 +755,14 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
754755
newxprt->sc_max_bc_requests = 2;
755756
}
756757
newxprt->sc_fc_credits = cpu_to_be32(newxprt->sc_max_requests);
757-
newxprt->sc_sq_depth = newxprt->sc_rq_depth;
758+
ctxts = rdma_rw_mr_factor(dev, newxprt->sc_port_num, RPCSVC_MAXPAGES);
759+
ctxts *= newxprt->sc_max_requests;
760+
newxprt->sc_sq_depth = newxprt->sc_rq_depth + ctxts;
761+
if (newxprt->sc_sq_depth > dev->attrs.max_qp_wr) {
762+
pr_warn("svcrdma: reducing send depth to %d\n",
763+
dev->attrs.max_qp_wr);
764+
newxprt->sc_sq_depth = dev->attrs.max_qp_wr;
765+
}
758766
atomic_set(&newxprt->sc_sq_avail, newxprt->sc_sq_depth);
759767

760768
if (!svc_rdma_prealloc_ctxts(newxprt))
@@ -789,8 +797,8 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
789797
qp_attr.event_handler = qp_event_handler;
790798
qp_attr.qp_context = &newxprt->sc_xprt;
791799
qp_attr.port_num = newxprt->sc_port_num;
792-
qp_attr.cap.max_rdma_ctxs = newxprt->sc_max_requests;
793-
qp_attr.cap.max_send_wr = newxprt->sc_sq_depth;
800+
qp_attr.cap.max_rdma_ctxs = ctxts;
801+
qp_attr.cap.max_send_wr = newxprt->sc_sq_depth - ctxts;
794802
qp_attr.cap.max_recv_wr = newxprt->sc_rq_depth;
795803
qp_attr.cap.max_send_sge = newxprt->sc_max_sge;
796804
qp_attr.cap.max_recv_sge = newxprt->sc_max_sge;
@@ -858,6 +866,7 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
858866
dprintk(" remote address : %pIS:%u\n", sap, rpc_get_port(sap));
859867
dprintk(" max_sge : %d\n", newxprt->sc_max_sge);
860868
dprintk(" sq_depth : %d\n", newxprt->sc_sq_depth);
869+
dprintk(" rdma_rw_ctxs : %d\n", ctxts);
861870
dprintk(" max_requests : %d\n", newxprt->sc_max_requests);
862871
dprintk(" ord : %d\n", newxprt->sc_ord);
863872

0 commit comments

Comments
 (0)