>
>It seems like you have some inconsistency in how you handle the SGEs in
>dapls_ib_post_recv and dapls_ib_post_send between uDAPL v1 and 
>uDAPL v2.
>
>For example in v1, you now leak the SGEs if the SGEs aren't allocated
>on the stack whereas in v2, you free them.
>

Good catch. Looks like the fix was lost in the scm merge.

reapplied your patch to v1 scm provider:

--
Fix memory leak in provider specific post send/recv if there's
more than DEFAULT_DS_ENTRIES iovecs.

Signed-off-by: Patrick Marchand Latifi <[EMAIL PROTECTED]>

diff --git a/dapl/openib_scm/dapl_ib_dto.h
b/dapl/openib_scm/dapl_ib_dto.h
index b15f347..7dd3075 100644
--- a/dapl/openib_scm/dapl_ib_dto.h
+++ b/dapl/openib_scm/dapl_ib_dto.h
@@ -67,10 +67,11 @@ dapls_ib_post_recv (
        IN  DAT_LMR_TRIPLET     *local_iov )
 {
        ib_data_segment_t ds_array[DEFAULT_DS_ENTRIES];
-       ib_data_segment_t *ds_array_p;
+       ib_data_segment_t *ds_array_p, *ds_array_start_p = NULL;
        struct ibv_recv_wr wr;
        struct ibv_recv_wr *bad_wr;
        DAT_COUNT i, total_len;
+       int ret;
        
        dapl_dbg_log(DAPL_DBG_TYPE_EP,
                     " post_rcv: ep %p cookie %p segs %d l_iov %p\n",
@@ -79,7 +80,7 @@ dapls_ib_post_recv (
        if (segments <= DEFAULT_DS_ENTRIES) 
                ds_array_p = ds_array;
        else
-               ds_array_p = 
+               ds_array_start_p = ds_array_p = 
                        dapl_os_alloc(segments *
sizeof(ib_data_segment_t));
 
        if (NULL == ds_array_p)
@@ -113,8 +114,13 @@ dapls_ib_post_recv (
        if (cookie != NULL) 
                cookie->val.dto.size = total_len;
 
-       if (ibv_post_recv(ep_ptr->qp_handle, &wr, &bad_wr))
-               return( dapl_convert_errno(errno,"ibv_recv") );
+       ret = ibv_post_recv(ep_ptr->qp_handle, &wr, &bad_wr);
+
+       if (ds_array_start_p != NULL)
+               dapl_os_free(ds_array_start_p, segments *
sizeof(ib_data_segment_t));
+
+       if (ret)
+               return(dapl_convert_errno(errno,"ibv_recv"));
        
        return DAT_SUCCESS;
 }
@@ -141,12 +147,13 @@ dapls_ib_post_send (
                     remote_iov, completion_flags);
 
        ib_data_segment_t ds_array[DEFAULT_DS_ENTRIES];
-       ib_data_segment_t *ds_array_p;
+       ib_data_segment_t *ds_array_p, *ds_array_start_p = NULL;
        struct ibv_send_wr wr;
        struct ibv_send_wr *bad_wr;
        ib_hca_transport_t *ibt_ptr = 
                &ep_ptr->header.owner_ia->hca_ptr->ib_trans;
        DAT_COUNT i, total_len;
+       int ret;
        
        dapl_dbg_log(DAPL_DBG_TYPE_EP,
                     " post_snd: ep %p cookie %p segs %d l_iov %p\n",
@@ -155,7 +162,7 @@ dapls_ib_post_send (
        if(segments <= DEFAULT_DS_ENTRIES) 
                ds_array_p = ds_array;
        else
-               ds_array_p = 
+               ds_array_start_p = ds_array_p = 
                        dapl_os_alloc(segments *
sizeof(ib_data_segment_t));
 
        if (NULL == ds_array_p)
@@ -217,9 +224,14 @@ dapls_ib_post_send (
                     " post_snd: op 0x%x flags 0x%x sglist %p, %d\n", 
                     wr.opcode, wr.send_flags, wr.sg_list, wr.num_sge);
 
-       if (ibv_post_send(ep_ptr->qp_handle, &wr, &bad_wr))
-               return( dapl_convert_errno(errno,"ibv_recv") );
+       ret = ibv_post_send(ep_ptr->qp_handle, &wr, &bad_wr);
        
+       if (ds_array_start_p != NULL)
+               dapl_os_free(ds_array_start_p, segments *
sizeof(ib_data_segment_t));
+
+       if (ret)
+               return(dapl_convert_errno(errno,"ibv_send"));
+
        dapl_dbg_log(DAPL_DBG_TYPE_EP," post_snd: returned\n");
        return DAT_SUCCESS;
 }



_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to