Skip to content

Commit c4b7b1b

Browse files
committed
btl/base_am_rdma: fix handling of btl_send returning 1
Active message RDMA uses btl_send to send the initial request and RDMA response. btl_send will return 0 when the descriptor has been successfully queued for send, and will return 1 when the desciptor has been successfully sent. Currently, active message RDMA treats the return value 1 as an error, thus will either return the value to caller, or retry the send. This patch address the issue by correctly handling the return value 1. Signed-off-by: Wei Zhang <[email protected]>
1 parent b277aba commit c4b7b1b

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

opal/mca/btl/base/btl_base_am_rdma.c

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ static inline int mca_btl_base_am_rdma_advance(mca_btl_base_module_t *btl,
372372
mca_btl_base_rdma_context_t *context,
373373
bool send_descriptor)
374374
{
375+
int ret;
375376
const size_t remaining = context->total_size - context->sent;
376377

377378
if (0 == remaining) {
@@ -409,7 +410,19 @@ static inline int mca_btl_base_am_rdma_advance(mca_btl_base_module_t *btl,
409410
}
410411

411412
if (send_descriptor) {
412-
return btl->btl_send(btl, endpoint, descriptor, mca_btl_base_rdma_tag(hdr->type));
413+
/* btl_send return OPAL_SUCCESS when that the descriptor has been queued for send, and
414+
* descriptor's callback will be called upon completion.
415+
*
416+
* btl_send return 1 when the descriptor has been sent. In this case, the descriptor's
417+
* callback is called only if MCA_BTL_DES_SEND_ALWAYS_CALLBACK is set on the descriptor's flags.
418+
*
419+
* When creating the initiator request, we specified MCA_BTL_DES_SEND_ALWAYS_CALLBACK,
420+
* therefore btl_send's returning 1 is the same as it returning OPAL_SUCCESS.
421+
*/
422+
ret = btl->btl_send(btl, endpoint, descriptor, mca_btl_base_rdma_tag(hdr->type));
423+
if (ret == 1)
424+
ret = OPAL_SUCCESS;
425+
return ret;
413426
}
414427

415428
/* queue for later to avoid btl_send in callback */
@@ -614,7 +627,19 @@ static int mca_btl_base_am_rdma_respond(mca_btl_base_module_t *btl,
614627

615628
send_descriptor->des_cbfunc = NULL;
616629

630+
/* btl_send return OPAL_SUCCESS when that the descriptor has been queued for send, and
631+
* descriptor's callback will be called upon completion.
632+
*
633+
* btl_send return 1 when the descriptor has been sent. In this case, descriptor's
634+
* callback is called only if MCA_BTL_DES_SEND_ALWAYS_CALLBACK is set on the descriptor.
635+
*
636+
* There is no callback for the response descriptor, therefore for us btl_send
637+
* return 1 is the the same as it returning OPAL_SUCCESS.
638+
*/
617639
int ret = btl->btl_send(btl, endpoint, send_descriptor, mca_btl_base_rdma_resp_tag());
640+
if (ret == 1)
641+
ret = OPAL_SUCCESS;
642+
618643
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) {
619644
*descriptor = send_descriptor;
620645
}
@@ -779,6 +804,18 @@ static int mca_btl_base_am_rdma_progress(void)
779804

780805
OPAL_THREAD_SCOPED_LOCK(&default_module.mutex, ACTION1);
781806

807+
/* Note in ACTION2, we treated btl_send's return value of opal_success
808+
* and 1 the same. This is because:
809+
*
810+
* btl_send return OPAL_SUCCESS when that the descriptor has been queued for send, and
811+
* descriptor's callback will be called upon completion.
812+
*
813+
* btl_send return 1 when the descriptor has been sent and descriptor's callback has been
814+
* called if MCA_BTL_DES_SEND_ALWAYS_CALLBACK is set on the descriptor's flags.
815+
*
816+
* When creating the initiator descriptor, we specified MCA_BTL_DES_SEND_ALWAYS_CALLBACK,
817+
* therefore for us, btl_send's returning 1 is the same as it returning OPAL_SUCCESS.
818+
*/
782819
#define ACTION2 \
783820
mca_btl_base_am_rdma_queued_descriptor_t *descriptor, *next; \
784821
OPAL_LIST_FOREACH_SAFE (descriptor, next, \
@@ -791,7 +828,7 @@ static int mca_btl_base_am_rdma_progress(void)
791828
descriptor->endpoint, \
792829
descriptor->descriptor, \
793830
mca_btl_base_rdma_tag(context->type)); \
794-
if (OPAL_SUCCESS == ret) { \
831+
if (OPAL_SUCCESS == ret || 1 == ret) { \
795832
opal_list_remove_item(&default_module.queued_initiator_descriptors, \
796833
&descriptor->super); \
797834
} \

0 commit comments

Comments
 (0)