]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
xprtrdma: Pre-allocate Work Requests for backchannel
authorChuck Lever <chuck.lever@oracle.com>
Mon, 20 Apr 2015 22:06:11 +0000 (18:06 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 31 Aug 2015 20:46:02 +0000 (14:46 -0600)
[ Proposed for v4.4 ]

Pre-allocate extra send and receive Work Requests needed to handle
backchannel receives and sends.

The transport doesn't know how many extra WRs to pre-allocate until
the xprt_setup_backchannel() call, but that's long after the WRs are
allocated during forechannel setup.

So, use a fixed value for now.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
net/sunrpc/xprtrdma/backchannel.c
net/sunrpc/xprtrdma/verbs.c
net/sunrpc/xprtrdma/xprt_rdma.h

index f787d9c01063e09720bc09967059ec8ef0bd9d27..2fe495761886371fc987bb2d16bd1cde8c41e54f 100644 (file)
@@ -123,6 +123,9 @@ int xprt_rdma_bc_setup(struct rpc_xprt *xprt, unsigned int reqs)
         * Twice as many rpc_rqsts are prepared to ensure there is
         * always an rpc_rqst available as soon as a reply is sent.
         */
+       if (reqs > RPCRDMA_BACKWARD_WRS >> 1)
+               goto out_err;
+
        for (i = 0; i < (reqs << 1); i++) {
                rqst = kzalloc(sizeof(*rqst), GFP_KERNEL);
                if (!rqst) {
@@ -159,6 +162,7 @@ int xprt_rdma_bc_setup(struct rpc_xprt *xprt, unsigned int reqs)
 out_free:
        xprt_rdma_bc_destroy(xprt, reqs);
 
+out_err:
        pr_err("RPC:       %s: setup backchannel transport failed\n", __func__);
        return -ENOMEM;
 }
index 3447f44ae31b7181377be97d0db1ad916a58d75d..f9f748b8d98bdb20c93cfaa4db886cfd9a8462db 100644 (file)
@@ -769,19 +769,21 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
                return -ENOMEM;
        }
 
-       max_qp_wr = devattr->max_qp_wr - 1;
+       max_qp_wr = devattr->max_qp_wr - RPCRDMA_BACKWARD_WRS - 1;
        /* check provider's send/recv wr limits */
-       if (cdata->max_requests > devattr->max_qp_wr)
+       if (cdata->max_requests > max_qp_wr)
                cdata->max_requests = devattr->max_qp_wr;
 
        ep->rep_attr.event_handler = rpcrdma_qp_async_error_upcall;
        ep->rep_attr.qp_context = ep;
        ep->rep_attr.srq = NULL;
-       ep->rep_attr.cap.max_send_wr = cdata->max_requests + 1;
+       ep->rep_attr.cap.max_send_wr = cdata->max_requests +
+                                       RPCRDMA_BACKWARD_WRS + 1;
        rc = ia->ri_ops->ro_open(ia, ep, cdata);
        if (rc)
                return rc;
-       ep->rep_attr.cap.max_recv_wr = cdata->max_requests + 1;
+       ep->rep_attr.cap.max_recv_wr = cdata->max_requests +
+                                       RPCRDMA_BACKWARD_WRS + 1;
        ep->rep_attr.cap.max_send_sge = RPCRDMA_MAX_IOVS;
        ep->rep_attr.cap.max_recv_sge = 1;
        ep->rep_attr.cap.max_inline_data = 0;
index d1cc174101620d48f75f38f5e6378130d00ca267..45cb01282043594f1332dcfd6b127516d1484bb3 100644 (file)
@@ -108,6 +108,16 @@ struct rpcrdma_ep {
  */
 #define RPCRDMA_LAST_COMPLETION                (1ULL)
 
+/* Pre-allocate extra Work Requests for handling backward receives
+ * and sends. This is a fixed value because the Work Queues are
+ * allocated when the forward channel is set up.
+ */
+#if defined(CONFIG_SUNRPC_BACKCHANNEL)
+#define RPCRDMA_BACKWARD_WRS           (8)
+#else
+#define RPCRDMA_BACKWARD_WRS           (0)
+#endif
+
 /* Registered buffer -- registered kmalloc'd memory for RDMA SEND/RECV
  *
  * The below structure appears at the front of a large region of kmalloc'd