Skip to content

Commit 92f2e0e

Browse files
committed
smsc/xpmem: retry with page upper bound if aligned range cannot be mapped
The aligned range computed in mca_smsc_xpmem_map_peer_region may reach past the end of the stack, which may cause the mapping to fail. Retrying with an actual page as upper bound has a better chance to succeed. Signed-off-by: Joseph Schuchart <schuchart@icl.utk.edu>
1 parent 06516ba commit 92f2e0e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

opal/mca/smsc/xpmem/smsc_xpmem_module.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "opal/mca/smsc/base/base.h"
2424
#include "opal/mca/smsc/xpmem/smsc_xpmem_internal.h"
2525
#include "opal/util/minmax.h"
26+
#include "opal/util/sys_limits.h"
2627

2728
OBJ_CLASS_INSTANCE(mca_smsc_xpmem_endpoint_t, opal_object_t, NULL, NULL);
2829

@@ -157,8 +158,14 @@ void *mca_smsc_xpmem_map_peer_region(mca_smsc_endpoint_t *endpoint, uint64_t fla
157158

158159
reg->rcache_context = xpmem_attach(xpmem_addr, bound - base, NULL);
159160
if (OPAL_UNLIKELY((void *) -1 == reg->rcache_context)) {
160-
OBJ_RELEASE(reg);
161-
return NULL;
161+
/* retry with the page as upper bound */
162+
bound = OPAL_ALIGN((uintptr_t) remote_ptr + size, opal_getpagesize(), uintptr_t);
163+
reg->bound = (unsigned char *) bound;
164+
reg->rcache_context = xpmem_attach(xpmem_addr, bound - base, NULL);
165+
if (OPAL_UNLIKELY((void *) -1 == reg->rcache_context)) {
166+
OBJ_RELEASE(reg);
167+
return NULL;
168+
}
162169
}
163170

164171
opal_memchecker_base_mem_defined(reg->rcache_context, bound - base);
@@ -307,5 +314,5 @@ mca_smsc_xpmem_module_t mca_smsc_xpmem_module = {
307314
.copy_from = mca_smsc_xpmem_copy_from,
308315
.map_peer_region = mca_smsc_xpmem_map_peer_region,
309316
.unmap_peer_region = mca_smsc_xpmem_unmap_peer_region,
310-
},
317+
},
311318
};

0 commit comments

Comments
 (0)