Skip to content

Commit dabad08

Browse files
authored
Merge pull request #6621 from bosilca/topic/persistent_req_leak
Fix the leak of fragments for persistent sends (issue #6565)
2 parents 2821f5a + a16cf0e commit dabad08

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

ompi/mca/pml/ob1/pml_ob1_rdmafrag.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2013 The University of Tennessee and The University
6+
* Copyright (c) 2004-2019 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -46,7 +46,8 @@ struct mca_pml_ob1_rdma_frag_t {
4646
mca_bml_base_btl_t *rdma_bml;
4747
mca_pml_ob1_hdr_t rdma_hdr;
4848
mca_pml_ob1_rdma_state_t rdma_state;
49-
size_t rdma_length;
49+
size_t rdma_length; /* how much the fragment will transfer */
50+
opal_atomic_size_t rdma_bytes_remaining; /* how much is left to be transferred */
5051
void *rdma_req;
5152
uint32_t retries;
5253
mca_pml_ob1_rdma_frag_callback_t cbfunc;
@@ -71,7 +72,6 @@ OBJ_CLASS_DECLARATION(mca_pml_ob1_rdma_frag_t);
7172

7273
#define MCA_PML_OB1_RDMA_FRAG_RETURN(frag) \
7374
do { \
74-
/* return fragment */ \
7575
if (frag->local_handle) { \
7676
mca_bml_base_deregister_mem (frag->rdma_bml, frag->local_handle); \
7777
frag->local_handle = NULL; \

ompi/mca/pml/ob1/pml_ob1_recvfrag.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,10 +577,6 @@ void mca_pml_ob1_recv_frag_callback_ack(mca_btl_base_module_t* btl,
577577
* then throttle sends */
578578
if(hdr->hdr_common.hdr_flags & MCA_PML_OB1_HDR_FLAGS_NORDMA) {
579579
if (NULL != sendreq->rdma_frag) {
580-
if (NULL != sendreq->rdma_frag->local_handle) {
581-
mca_bml_base_deregister_mem (sendreq->req_rdma[0].bml_btl, sendreq->rdma_frag->local_handle);
582-
sendreq->rdma_frag->local_handle = NULL;
583-
}
584580
MCA_PML_OB1_RDMA_FRAG_RETURN(sendreq->rdma_frag);
585581
sendreq->rdma_frag = NULL;
586582
}

ompi/mca/pml/ob1/pml_ob1_recvreq.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2018 The University of Tennessee and The University
6+
* Copyright (c) 2004-2019 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
@@ -319,7 +319,12 @@ static int mca_pml_ob1_recv_request_ack(
319319
return OMPI_SUCCESS;
320320
}
321321

322-
/* let know to shedule function there is no need to put ACK flag */
322+
/* let know to shedule function there is no need to put ACK flag. If not all message went over
323+
* RDMA then we cancel the GET protocol in order to switch back to send/recv. In this case send
324+
* back the remote send request, the peer kept a poointer to the frag locally. In the future we
325+
* might want to cancel the fragment itself, in which case we will have to send back the remote
326+
* fragment instead of the remote request.
327+
*/
323328
recvreq->req_ack_sent = true;
324329
return mca_pml_ob1_recv_request_ack_send(proc, hdr->hdr_src_req.lval,
325330
recvreq, recvreq->req_send_offset, 0,
@@ -658,7 +663,6 @@ void mca_pml_ob1_recv_request_progress_rget( mca_pml_ob1_recv_request_t* recvreq
658663
int rc;
659664

660665
prev_sent = offset = 0;
661-
bytes_remaining = hdr->hdr_rndv.hdr_msg_length;
662666
recvreq->req_recv.req_bytes_packed = hdr->hdr_rndv.hdr_msg_length;
663667
recvreq->req_send_offset = 0;
664668
recvreq->req_rdma_offset = 0;

ompi/mca/pml/ob1/pml_ob1_sendreq.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2018 The University of Tennessee and The University
6+
* Copyright (c) 2004-2019 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
@@ -41,7 +41,6 @@
4141
#include "ompi/mca/bml/base/base.h"
4242
#include "ompi/memchecker.h"
4343

44-
4544
OBJ_CLASS_INSTANCE(mca_pml_ob1_send_range_t, opal_free_list_item_t,
4645
NULL, NULL);
4746

@@ -148,10 +147,7 @@ static void mca_pml_ob1_send_request_destruct(mca_pml_ob1_send_request_t* req)
148147
{
149148
OBJ_DESTRUCT(&req->req_send_ranges);
150149
OBJ_DESTRUCT(&req->req_send_range_lock);
151-
if (req->rdma_frag) {
152-
MCA_PML_OB1_RDMA_FRAG_RETURN(req->rdma_frag);
153-
req->rdma_frag = NULL;
154-
}
150+
assert( NULL == req->rdma_frag );
155151
}
156152

157153
OBJ_CLASS_INSTANCE( mca_pml_ob1_send_request_t,
@@ -262,12 +258,20 @@ mca_pml_ob1_rget_completion (mca_pml_ob1_rdma_frag_t *frag, int64_t rdma_length)
262258
{
263259
mca_pml_ob1_send_request_t *sendreq = (mca_pml_ob1_send_request_t *) frag->rdma_req;
264260
mca_bml_base_btl_t *bml_btl = frag->rdma_bml;
261+
size_t frag_remaining;
265262

266263
/* count bytes of user data actually delivered and check for request completion */
267264
if (OPAL_LIKELY(0 < rdma_length)) {
268-
OPAL_THREAD_ADD_FETCH_SIZE_T(&sendreq->req_bytes_delivered, (size_t) rdma_length);
265+
frag_remaining = OPAL_THREAD_SUB_FETCH_SIZE_T(&frag->rdma_bytes_remaining, (size_t)rdma_length);
269266
SPC_USER_OR_MPI(sendreq->req_send.req_base.req_ompi.req_status.MPI_TAG, (ompi_spc_value_t)rdma_length,
270267
OMPI_SPC_BYTES_SENT_USER, OMPI_SPC_BYTES_SENT_MPI);
268+
269+
if( 0 == frag_remaining ) { /* this frag is now completed. Update the request and be done */
270+
OPAL_THREAD_ADD_FETCH_SIZE_T(&sendreq->req_bytes_delivered, frag->rdma_length);
271+
if( sendreq->rdma_frag == frag )
272+
sendreq->rdma_frag = NULL;
273+
MCA_PML_OB1_RDMA_FRAG_RETURN(frag);
274+
}
271275
}
272276

273277
send_request_pml_complete_check(sendreq);
@@ -701,6 +705,7 @@ int mca_pml_ob1_send_request_start_rdma( mca_pml_ob1_send_request_t* sendreq,
701705
frag->rdma_req = sendreq;
702706
frag->rdma_bml = bml_btl;
703707
frag->rdma_length = size;
708+
frag->rdma_bytes_remaining = size;
704709
frag->cbfunc = mca_pml_ob1_rget_completion;
705710
/* do not store the local handle in the fragment. it will be released by mca_pml_ob1_free_rdma_resources */
706711

ompi/mca/pml/ob1/pml_ob1_sendreq.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,7 @@ static inline void mca_pml_ob1_send_request_fini (mca_pml_ob1_send_request_t *se
216216
{
217217
/* Let the base handle the reference counts */
218218
MCA_PML_BASE_SEND_REQUEST_FINI((&(sendreq)->req_send));
219-
if (sendreq->rdma_frag) {
220-
MCA_PML_OB1_RDMA_FRAG_RETURN (sendreq->rdma_frag);
221-
sendreq->rdma_frag = NULL;
222-
}
219+
assert( NULL == sendreq->rdma_frag );
223220
}
224221

225222
/*

0 commit comments

Comments
 (0)