Skip to content

Commit 630bebd

Browse files
authored
Merge pull request #9844 from hjelmn/btl_sm_should_not_crash_when_using_rdma_on_self_ever
btl/sm: fix crash on put/get to self
2 parents 9609183 + 1b9b61a commit 630bebd

File tree

6 files changed

+24
-50
lines changed

6 files changed

+24
-50
lines changed

opal/mca/btl/sm/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ libmca_btl_sm_la_sources = \
2929
btl_sm_module.c \
3030
btl_sm.h \
3131
btl_sm_component.c \
32-
btl_sm_endpoint.h \
3332
btl_sm_fifo.h \
3433
btl_sm_frag.c \
3534
btl_sm_frag.h \

opal/mca/btl/sm/btl_sm.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ mca_btl_base_descriptor_t *mca_btl_sm_alloc(struct mca_btl_base_module_t *btl,
157157
*/
158158
int mca_btl_sm_free(struct mca_btl_base_module_t *btl, mca_btl_base_descriptor_t *des);
159159

160+
static inline bool mca_btl_is_self_endpoint(mca_btl_base_endpoint_t *endpoint) {
161+
return endpoint->peer_smp_rank == MCA_BTL_SM_LOCAL_RANK;
162+
}
163+
160164
END_C_DECLS
161165

162166
#endif

opal/mca/btl/sm/btl_sm_endpoint.h

Lines changed: 0 additions & 34 deletions
This file was deleted.

opal/mca/btl/sm/btl_sm_get.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* reserved.
55
* Copyright (c) 2018 Research Organization for Information Science
66
* and Technology (RIST). All rights reserved.
7-
* Copyright (c) 2019-2021 Google, Inc. All rights reserved.
7+
* Copyright (c) 2019-2022 Google, Inc. All rights reserved.
88
* Copyright (c) 2020 The University of Tennessee and The University
99
* of Tennessee Research Foundation. All rights
1010
* reserved.
@@ -18,7 +18,6 @@
1818
#include "opal_config.h"
1919

2020
#include "opal/mca/btl/sm/btl_sm.h"
21-
#include "opal/mca/btl/sm/btl_sm_endpoint.h"
2221
#include "opal/mca/btl/sm/btl_sm_frag.h"
2322
#include "opal/mca/smsc/smsc.h"
2423

@@ -37,10 +36,14 @@ int mca_btl_sm_get(mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endpoint
3736
int order, mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext,
3837
void *cbdata)
3938
{
40-
int ret = MCA_SMSC_CALL(copy_from, endpoint->smsc_endpoint, local_address,
41-
(void *) (intptr_t) remote_address, size, remote_handle);
42-
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) {
43-
return ret;
39+
if (!mca_btl_is_self_endpoint(endpoint)) {
40+
int ret = MCA_SMSC_CALL(copy_from, endpoint->smsc_endpoint, local_address,
41+
(void *) (intptr_t) remote_address, size, remote_handle);
42+
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) {
43+
return ret;
44+
}
45+
} else {
46+
memcpy(local_address, (void *)(uintptr_t) remote_address, size);
4447
}
4548

4649
/* always call the callback function */

opal/mca/btl/sm/btl_sm_module.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* and Technology (RIST). All rights reserved.
2020
* Copyright (c) 2018-2019 Triad National Security, LLC. All rights
2121
* reserved.
22-
* Copyright (c) 2020-2021 Google, LLC. All rights reserved.
22+
* Copyright (c) 2020-2022 Google, LLC. All rights reserved.
2323
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
2424
* $COPYRIGHT$
2525
*
@@ -32,7 +32,6 @@
3232
#include "opal/util/show_help.h"
3333

3434
#include "opal/mca/btl/sm/btl_sm.h"
35-
#include "opal/mca/btl/sm/btl_sm_endpoint.h"
3635
#include "opal/mca/btl/sm/btl_sm_fbox.h"
3736
#include "opal/mca/btl/sm/btl_sm_fifo.h"
3837
#include "opal/mca/btl/sm/btl_sm_frag.h"
@@ -168,7 +167,7 @@ static int init_sm_endpoint(struct mca_btl_base_endpoint_t **ep_out, struct opal
168167

169168
ep->peer_smp_rank = peer_local_rank;
170169

171-
if (peer_local_rank != MCA_BTL_SM_LOCAL_RANK) {
170+
if (!mca_btl_is_self_endpoint(ep)) {
172171
OPAL_MODEX_RECV_IMMEDIATE(rc, &component->super.btl_version, &proc->proc_name,
173172
(void **) &modex, &msg_size);
174173
if (OPAL_SUCCESS != rc) {

opal/mca/btl/sm/btl_sm_put.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* reserved.
55
* Copyright (c) 2014-2018 Research Organization for Information Science
66
* and Technology (RIST). All rights reserved.
7-
* Copyright (c) 2019-2021 Google, Inc. All rights reserved.
7+
* Copyright (c) 2019-2022 Google, Inc. All rights reserved.
88
* Copyright (c) 2020 The University of Tennessee and The University
99
* of Tennessee Research Foundation. All rights
1010
* reserved.
@@ -18,7 +18,6 @@
1818
#include "opal_config.h"
1919

2020
#include "opal/mca/btl/sm/btl_sm.h"
21-
#include "opal/mca/btl/sm/btl_sm_endpoint.h"
2221
#include "opal/mca/btl/sm/btl_sm_frag.h"
2322
#include "opal/mca/smsc/smsc.h"
2423

@@ -37,10 +36,14 @@ int mca_btl_sm_put(mca_btl_base_module_t *btl, mca_btl_base_endpoint_t *endpoint
3736
int order, mca_btl_base_rdma_completion_fn_t cbfunc, void *cbcontext,
3837
void *cbdata)
3938
{
40-
int ret = MCA_SMSC_CALL(copy_to, endpoint->smsc_endpoint, local_address,
41-
(void *) (intptr_t) remote_address, size, remote_handle);
42-
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) {
43-
return ret;
39+
if (!mca_btl_is_self_endpoint(endpoint)) {
40+
int ret = MCA_SMSC_CALL(copy_to, endpoint->smsc_endpoint, local_address,
41+
(void *) (intptr_t) remote_address, size, remote_handle);
42+
if (OPAL_UNLIKELY(OPAL_SUCCESS != ret)) {
43+
return ret;
44+
}
45+
} else {
46+
memcpy((void *)(uintptr_t) remote_address, local_address, size);
4447
}
4548

4649
/* always call the callback function */

0 commit comments

Comments
 (0)