[openib-general] [PATCH]code optimization in ib_register_mad_agent()

Shirley Ma xma at us.ibm.com
Fri Oct 29 17:21:50 PDT 2004


> Can you post patches in the body of your email or at least with a mime
type like text/plain or text/x-patch so I don't have to save the patch
to look at it?

Ok, let's see whether this works? My email has some problem for inline 
patch.


diff -urN access/mad.c access.patch/mad.c
--- access/mad.c        2004-10-29 14:17:18.000000000 -0700
+++ access.patch/mad.c  2004-10-29 16:24:28.337157928 -0700
@@ -221,7 +221,21 @@
                }
                /* Make a copy of the MAD registration request */
                memcpy(reg_req, mad_reg_req, sizeof *reg_req);
-       } 
+       }
+ 
+       /* Now, fill in the various structures */
+       memset(mad_agent_priv, 0, sizeof *mad_agent_priv);
+       mad_agent_priv->port_priv = port_priv;
+       mad_agent_priv->reg_req = reg_req;
+       mad_agent_priv->rmpp_version = rmpp_version;
+       mad_agent_priv->agent.device = device;
+       mad_agent_priv->agent.recv_handler = recv_handler;
+       mad_agent_priv->agent.send_handler = send_handler;
+       mad_agent_priv->agent.context = context;
+       mad_agent_priv->agent.qp = port_priv->qp[qp_type];
+       mad_agent_priv->agent.hi_tid = ++ib_mad_client_id;
+       mad_agent_priv->agent.port_num = port_num;
+
 
        spin_lock_irqsave(&port_priv->reg_lock, flags);
 
@@ -237,31 +251,14 @@
                        method = class->method_table[mgmt_class];
                        if (method) {
                                if (method_in_use(&method, mad_reg_req)) {
-                                       spin_unlock_irqrestore(
-                                               &port_priv->reg_lock, 
flags);
                                        ret = ERR_PTR(-EINVAL);
                                        goto error3;
                                }
                        }
                }
        }
-
-       /* Now, fill in the various structures */
-       memset(mad_agent_priv, 0, sizeof *mad_agent_priv);
-       mad_agent_priv->port_priv = port_priv;
-       mad_agent_priv->reg_req = reg_req;
-       mad_agent_priv->rmpp_version = rmpp_version;
-       mad_agent_priv->agent.device = device;
-       mad_agent_priv->agent.recv_handler = recv_handler;
-       mad_agent_priv->agent.send_handler = send_handler;
-       mad_agent_priv->agent.context = context;
-       mad_agent_priv->agent.qp = port_priv->qp[qp_type];
-       mad_agent_priv->agent.hi_tid = ++ib_mad_client_id;
-       mad_agent_priv->agent.port_num = port_num;
-
        ret2 = add_mad_reg_req(mad_reg_req, mad_agent_priv);
        if (ret2) {
-               spin_unlock_irqrestore(&port_priv->reg_lock, flags);
                ret = ERR_PTR(ret2); 
                goto error3; 
        }
@@ -281,8 +278,8 @@
        return &mad_agent_priv->agent;
 
 error3:
-       if (reg_req)
-               kfree(reg_req);
+       spin_unlock_irqrestore(&port_priv->reg_lock, flags);
+       kfree(reg_req);
 error2:
        kfree(mad_agent_priv);
 error1:


thanks
Shirley Ma
IBM Linux Technology Center
15300 SW Koll Parkway
Beaverton, OR 97006-6063
Phone: (503) 578-7638
FAX:      (503) 578-3228

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20041029/07ddd2bb/attachment.html>


More information about the general mailing list