Skip to content

Commit cb3890a

Browse files
authored
Merge pull request #12817 from hjelmn/fix_possibly_ancient_ob1_bug_in_the_get_fallback_path_that_crashes_ob1_or_leaks_memory
Fix various bugs in get/put fallbacks in pml/ob1
2 parents 5f00259 + b7f8cae commit cb3890a

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

ompi/mca/pml/ob1/pml_ob1_recvreq.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ static int mca_pml_ob1_recv_request_get_frag_failed (mca_pml_ob1_rdma_frag_t *fr
382382
}
383383
}
384384

385-
if (++frag->retries < mca_pml_ob1.rdma_retries_limit &&
385+
if (frag->retries < mca_pml_ob1.rdma_retries_limit &&
386386
OMPI_ERR_OUT_OF_RESOURCE == rc) {
387387
OPAL_THREAD_LOCK(&mca_pml_ob1.lock);
388388
opal_list_append(&mca_pml_ob1.rdma_pending, (opal_list_item_t*)frag);
@@ -413,6 +413,7 @@ static void mca_pml_ob1_rget_completion (mca_btl_base_module_t* btl, struct mca_
413413
/* check completion status */
414414
if (OPAL_UNLIKELY(OMPI_SUCCESS != status)) {
415415
status = mca_pml_ob1_recv_request_get_frag_failed (frag, status);
416+
/* fragment was returned or queue by the above call */
416417
if (OPAL_UNLIKELY(OMPI_SUCCESS != status)) {
417418
size_t skipped_bytes = recvreq->req_send_offset - recvreq->req_rdma_offset;
418419
opal_output_verbose(mca_pml_ob1_output, 1, "pml:ob1: %s: operation failed with code %d", __func__, status);
@@ -435,12 +436,12 @@ static void mca_pml_ob1_rget_completion (mca_btl_base_module_t* btl, struct mca_
435436
mca_pml_ob1_send_fin (recvreq->req_recv.req_base.req_proc,
436437
bml_btl, frag->rdma_hdr.hdr_rget.hdr_frag,
437438
frag->rdma_length, 0, 0);
439+
440+
MCA_PML_OB1_RDMA_FRAG_RETURN(frag);
438441
}
439442

440443
recv_request_pml_complete_check(recvreq);
441444

442-
MCA_PML_OB1_RDMA_FRAG_RETURN(frag);
443-
444445
MCA_PML_OB1_PROGRESS_PENDING(bml_btl);
445446
}
446447

ompi/mca/pml/ob1/pml_ob1_sendreq.c

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* Copyright (c) 2018-2019 Triad National Security, LLC. All rights
2323
* reserved.
2424
* Copyright (c) 2022 IBM Corporation. All rights reserved.
25+
* Copyright (c) 2024 Google, LLC. All rights reserved.
2526
* $COPYRIGHT$
2627
*
2728
* Additional copyrights may follow
@@ -1110,6 +1111,12 @@ mca_pml_ob1_send_request_schedule_once(mca_pml_ob1_send_request_t* sendreq)
11101111

11111112
range = get_send_range(sendreq);
11121113

1114+
if (NULL != sendreq->rdma_frag) {
1115+
/* this request was first attempted with RDMA but is now using send/recv */
1116+
MCA_PML_OB1_RDMA_FRAG_RETURN(sendreq->rdma_frag);
1117+
sendreq->rdma_frag = NULL;
1118+
}
1119+
11131120
while(range && (false == sendreq->req_throttle_sends ||
11141121
sendreq->req_pipeline_depth < mca_pml_ob1.send_pipeline_depth)) {
11151122
mca_pml_ob1_frag_hdr_t* hdr;
@@ -1268,30 +1275,31 @@ static void mca_pml_ob1_send_request_put_frag_failed (mca_pml_ob1_rdma_frag_t *f
12681275
mca_pml_ob1_send_request_t* sendreq = (mca_pml_ob1_send_request_t *) frag->rdma_req;
12691276
mca_bml_base_btl_t *bml_btl = frag->rdma_bml;
12701277

1271-
if (++frag->retries < mca_pml_ob1.rdma_retries_limit && OMPI_ERR_OUT_OF_RESOURCE == rc) {
1278+
if (frag->retries < mca_pml_ob1.rdma_retries_limit && OMPI_ERR_OUT_OF_RESOURCE == rc) {
12721279
/* queue the frag for later if there was a resource error */
12731280
OPAL_THREAD_LOCK(&mca_pml_ob1.lock);
12741281
opal_list_append(&mca_pml_ob1.rdma_pending, (opal_list_item_t*)frag);
12751282
OPAL_THREAD_UNLOCK(&mca_pml_ob1.lock);
1276-
} else {
1283+
return;
1284+
}
1285+
12771286
#if OPAL_ENABLE_FT
1278-
if(!ompi_proc_is_active(sendreq->req_send.req_base.req_proc)) {
1279-
return;
1280-
}
1281-
#endif /* OPAL_ENABLE_FT */
1282-
/* tell receiver to deregister memory */
1283-
mca_pml_ob1_send_fin (sendreq->req_send.req_base.req_proc, bml_btl,
1284-
frag->rdma_hdr.hdr_rdma.hdr_frag, 0, MCA_BTL_NO_ORDER,
1285-
OPAL_ERR_TEMP_OUT_OF_RESOURCE);
1286-
1287-
/* send fragment by copy in/out */
1288-
mca_pml_ob1_send_request_copy_in_out(sendreq, frag->rdma_hdr.hdr_rdma.hdr_rdma_offset,
1289-
frag->rdma_length);
1290-
/* if a pointer to a receive request is not set it means that
1291-
* ACK was not yet received. Don't schedule sends before ACK */
1292-
if (NULL != sendreq->req_recv.pval)
1293-
mca_pml_ob1_send_request_schedule (sendreq);
1287+
if(!ompi_proc_is_active(sendreq->req_send.req_base.req_proc)) {
1288+
return;
12941289
}
1290+
#endif /* OPAL_ENABLE_FT */
1291+
/* tell receiver to deregister memory */
1292+
mca_pml_ob1_send_fin (sendreq->req_send.req_base.req_proc, bml_btl,
1293+
frag->rdma_hdr.hdr_rdma.hdr_frag, 0, MCA_BTL_NO_ORDER,
1294+
OPAL_ERR_TEMP_OUT_OF_RESOURCE);
1295+
1296+
/* send fragment by copy in/out */
1297+
mca_pml_ob1_send_request_copy_in_out(sendreq, frag->rdma_hdr.hdr_rdma.hdr_rdma_offset,
1298+
frag->rdma_length);
1299+
/* if a pointer to a receive request is not set it means that
1300+
* ACK was not yet received. Don't schedule sends before ACK */
1301+
if (NULL != sendreq->req_recv.pval)
1302+
mca_pml_ob1_send_request_schedule (sendreq);
12951303
}
12961304

12971305
/**

0 commit comments

Comments
 (0)