[ofw] [IPOIB_NDIS6_CM] enhance wc linking loop performance by removing array index calculations

Smith, Stan stan.smith at intel.com
Mon Aug 9 12:53:01 PDT 2010


Hefty, Sean wrote:
>>> --- A/ulp/ipoib_NDIS6_CM/kernel/ipoib_endpoint.cpp      Wed Aug 04
>>> 10:30:43 2010 +++ B/ulp/ipoib_NDIS6_CM/kernel/ipoib_endpoint.cpp
>>> Wed Aug 04 10:28:59 2010 @@ -888,9 +888,10 @@
>>>                 p_port->p_adapter->p_ifc->modify_qp( p_endpt-
>>>> conn.h_send_qp, &mod_attr );
>>>                 p_port->p_adapter->p_ifc->modify_qp( p_endpt-
>>>> conn.h_recv_qp, &mod_attr );
>>>
>>> -               for( i = 0; i < MAX_RECV_WC; i++ )
>>> -                       wc[i].p_next = &wc[i + 1];
>>> -               wc[MAX_RECV_WC - 1].p_next = NULL;
>>> +       for( p_free_wc=wc; p_free_wc < &wc[MAX_RECV_WC];
>>> p_free_wc++ ) +               p_free_wc->p_next = p_free_wc + 1;
>>> +
>>> +       (--p_free_wc)->p_next = NULL;
>
> Personally, I don't like the use of (--p_free_wc) here.  This results
> in updating (extra memory write) p_free_wc outside of the loop, plus
> a second write to wc[MAX_RECV_WC - 1].p_next, because the first write
> was incorrect.  I realize that the original code had this update as
> well, but can't we just end the loop one iteration earlier?
>
> - Sean

Yes '(--p_free_wc)->p_next = NULL;' should have been '(p_free_wc - 1)->p_next = NULL;' to skip the extra memory write.

Although (if this is what you had in mind)

        for( p_free_wc=wc; p_free_wc < &wc[MAX_RECV_WC - 1]; p_free_wc++ )
              p_free_wc->p_next = p_free_wc + 1;

       p_free_wc->p_next = NULL;

is more efficient; (could not see the forest for the trees issue) thanks.





More information about the ofw mailing list