Skip to content

Commit 621a566

Browse files
committed
btl/sm: do not set always callback frag when there is none
This fixes an issue with the btl_send function in btl/sm. The pml/ob1 usage always provides a callback function which masked this bug. The btl_send function was unconditionally setting the MCA_BTL_DES_SEND_ALWAYS_CALLBACK flag for any outgoing fragment. This is a violation of the interface which allows the caller to leave the callback function unset. This commit fixes the issue by protecting the code which set the flag to first check if the callback function is non-NULL. This commit also ensures that when a fragment is sent that the complete flag is unset. This flag is used to return a fragment to the sender and can confuse the receive logic if it is set at the wrong time. This change allows the owner of the frag to send multiple times without needing to allocate a new frag using btl_alloc. Signed-off-by: Nathan Hjelm <hjelmn@google.com>
1 parent 56ed3a6 commit 621a566

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

opal/mca/btl/sm/btl_sm_send.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2010-2014 Los Alamos National Security, LLC. All rights
1616
* reserved.
17+
* Copyright (c) 2021 Google, LLC. All rights reserved.
1718
* $COPYRIGHT$
1819
*
1920
* Additional copyrights may follow
@@ -42,18 +43,25 @@ int mca_btl_sm_send (struct mca_btl_base_module_t *btl,
4243
mca_btl_sm_frag_t *frag = (mca_btl_sm_frag_t *) descriptor;
4344
const size_t total_size = frag->segments[0].seg_len;
4445

45-
/* in order to work around a long standing ob1 bug (see #3845) we have to always
46-
* make the callback. once this is fixed in ob1 we can restore the code below. */
47-
frag->base.des_flags |= MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
46+
if (frag->base.des_cbfunc) {
47+
/* in order to work around a long standing ob1 bug (see #3845) we have to always
48+
* make the callback. once this is fixed in ob1 we can restore the code below. */
49+
frag->base.des_flags |= MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
50+
}
4851

4952
/* header (+ optional inline data) */
5053
frag->hdr->len = total_size;
5154
/* type of message, pt-2-pt, one-sided, etc */
5255
frag->hdr->tag = tag;
5356

57+
/* clear the complete flag if it has been set */
58+
frag->hdr->flags &= ~MCA_BTL_SM_FLAG_COMPLETE;
59+
5460
/* post the relative address of the descriptor into the peer's fifo */
5561
if (opal_list_get_size (&endpoint->pending_frags) || !sm_fifo_write_ep (frag->hdr, endpoint)) {
56-
frag->base.des_flags |= MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
62+
if (frag->base.des_cbfunc) {
63+
frag->base.des_flags |= MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
64+
}
5765
OPAL_THREAD_LOCK(&endpoint->pending_frags_lock);
5866
opal_list_append (&endpoint->pending_frags, (opal_list_item_t *) frag);
5967
if (!endpoint->waiting) {
@@ -69,8 +77,9 @@ int mca_btl_sm_send (struct mca_btl_base_module_t *btl,
6977
return OPAL_SUCCESS;
7078

7179
#if 0
72-
if ((frag->hdr->flags & MCA_BTL_SM_FLAG_SINGLE_COPY) ||
73-
!(frag->base.des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP)) {
80+
if (((frag->hdr->flags & MCA_BTL_SM_FLAG_SINGLE_COPY) ||
81+
!(frag->base.des_flags & MCA_BTL_DES_FLAGS_BTL_OWNERSHIP)) &&
82+
frag->base.des_cbfunc) {
7483
frag->base.des_flags |= MCA_BTL_DES_SEND_ALWAYS_CALLBACK;
7584

7685
return OPAL_SUCCESS;

0 commit comments

Comments
 (0)