Skip to contentSkip to conversation

svcrdma: delete double assignment

PATCH In review Himangi Saraogi 3 participants 3 messages Jul 28, 2014 – Jul 30, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 svcrdma: delete double assignment

Delete successive assignments to the same location.

A simplified version of Coccinelle semantic match that finds this problem is as follows:

// <smpl>
@@
expression i;
@@

*i = ...;
i = ...;
// </smpl>

---
Should the assignment be the maximum of the 2 values?

 net/sunrpc/xprtrdma/svc_rdma_transport.c | 1 -
 1 file changed, 1 deletion(-)
net/sunrpc/xprtrdma/svc_rdma_transport.c +0 -1
index 06a5d92..8976529 100644
@@ -956,7 +956,6 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
 			dprintk("svcrdma: failed to create QP, ret=%d\n", ret);
 			goto errout;
 		}
-		newxprt->sc_max_sge = qp_attr.cap.max_send_sge;
 		newxprt->sc_max_sge = qp_attr.cap.max_recv_sge;
 		newxprt->sc_sq_depth = qp_attr.cap.max_send_wr;
 		newxprt->sc_max_requests = qp_attr.cap.max_recv_wr;
Signature · 1 line
1.9.1
maintainer
#1 lore raw

From: Himangi Saraogi <[email protected]>
Date: Mon, 28 Jul 2014 20:59:38 +0530

Quoted 10 lines

Delete successive assignments to the same location.

A simplified version of Coccinelle semantic match that finds this problem is as follows:

// <smpl>
@@
expression i;
@@

Quoted 5 lines

*i = ...;
i = ...;
// </smpl>

I am not so sure about this change either.

net/sunrpc/xprtrdma/svc_rdma_transport.c static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) · line 961

Quoted 8 lines
net/sunrpc/xprtrdma/svc_rdma_transport.c +0 -1
@@ -956,7 +956,6 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
 			dprintk("svcrdma: failed to create QP, ret=%d\n", ret);
 			goto errout;
 		}
-		newxprt->sc_max_sge = qp_attr.cap.max_send_sge;
 		newxprt->sc_max_sge = qp_attr.cap.max_recv_sge;
 		newxprt->sc_sq_depth = qp_attr.cap.max_send_wr;
 		newxprt->sc_max_requests = qp_attr.cap.max_recv_wr;

->sc_max_sge is used to limit the number of segments used during sends, currently in this code. Grep for where it is used.

Therefore, if anything, the correct thing to do would be to retain the first line rather than the second line.

Someone who actually works on this code and understands it should really take a close look at this before anyone even thinks about applying this patch.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 31 lines · David Miller

From: Himangi Saraogi <[email protected]>
Date: Mon, 28 Jul 2014 20:59:38 +0530

Quoted 10 lines

Delete successive assignments to the same location.

A simplified version of Coccinelle semantic match that finds this problem is as follows:

// <smpl>
@@
expression i;
@@

Quoted 5 lines

*i = ...;
i = ...;
// </smpl>

I am not so sure about this change either.

Review static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) · line 961

Quoted 8 lines
(quoted diff) +0 -1
@@ -956,7 +956,6 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
  			dprintk("svcrdma: failed to create QP, ret=%d\n", ret);
  			goto errout;
  		}
-		newxprt->sc_max_sge = qp_attr.cap.max_send_sge;
  		newxprt->sc_max_sge = qp_attr.cap.max_recv_sge;
  		newxprt->sc_sq_depth = qp_attr.cap.max_send_wr;
  		newxprt->sc_max_requests = qp_attr.cap.max_recv_wr;

->sc_max_sge is used to limit the number of segments used during sends, currently in this code. Grep for where it is used.

Quoted 6 lines

Therefore, if anything, the correct thing to do would be to retain the first line rather than the second line.

Someone who actually works on this code and understands it should really take a close look at this before anyone even thinks about applying this patch.

We should remove that whole block that tries to recover from a rdma_create_qp() failure. I don't believe we would ever hit it. The value initially stored in sc_max_sge is from the device attribute max_sge returned from ib_query_device() just above the code we're talking about. If rdma_create_qp() fails, it would not be because the max_send_sge and max_recv_sge values passed in exceed the device's max...

Like this:

net/sunrpc/xprtrdma/svc_rdma_transport.c +2 -17
index e7323fb..282a43b 100644
@@ -942,23 +942,8 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
 
        ret = rdma_create_qp(newxprt->sc_cm_id, newxprt->sc_pd, &qp_attr);
        if (ret) {
-               /*
-                * XXX: This is a hack. We need a xx_request_qp interface
-                * that will adjust the qp_attr's with a best-effort
-                * number
-                */
-               qp_attr.cap.max_send_sge -= 2;
-               qp_attr.cap.max_recv_sge -= 2;
-               ret = rdma_create_qp(newxprt->sc_cm_id, newxprt->sc_pd,
-                                    &qp_attr);
-               if (ret) {
-                       dprintk("svcrdma: failed to create QP, ret=%d\n", ret);
-                       goto errout;
-               }
-               newxprt->sc_max_sge = qp_attr.cap.max_send_sge;
-               newxprt->sc_max_sge = qp_attr.cap.max_recv_sge;
-               newxprt->sc_sq_depth = qp_attr.cap.max_send_wr;
-               newxprt->sc_max_requests = qp_attr.cap.max_recv_wr;
+               dprintk("svcrdma: failed to create QP, ret=%d\n", ret);
+               goto errout;
        }
        newxprt->sc_qp = newxprt->sc_cm_id->qp;
 

Steve.