|
23 | 23 | #include "opal/mca/smsc/base/base.h"
|
24 | 24 | #include "opal/mca/smsc/xpmem/smsc_xpmem_internal.h"
|
25 | 25 | #include "opal/util/minmax.h"
|
| 26 | +#include "opal/util/sys_limits.h" |
26 | 27 |
|
27 | 28 | OBJ_CLASS_INSTANCE(mca_smsc_xpmem_endpoint_t, opal_object_t, NULL, NULL);
|
28 | 29 |
|
@@ -116,7 +117,7 @@ void *mca_smsc_xpmem_map_peer_region(mca_smsc_endpoint_t *endpoint, uint64_t fla
|
116 | 117 | int rc;
|
117 | 118 |
|
118 | 119 | base = OPAL_DOWN_ALIGN((uintptr_t) remote_ptr, attach_align, uintptr_t);
|
119 |
| - bound = OPAL_ALIGN((uintptr_t) remote_ptr + size - 1, attach_align, uintptr_t) + 1; |
| 120 | + bound = OPAL_ALIGN((uintptr_t) remote_ptr + size, attach_align, uintptr_t); |
120 | 121 | if (OPAL_UNLIKELY(bound > xpmem_endpoint->address_max)) {
|
121 | 122 | bound = xpmem_endpoint->address_max;
|
122 | 123 | }
|
@@ -157,8 +158,14 @@ void *mca_smsc_xpmem_map_peer_region(mca_smsc_endpoint_t *endpoint, uint64_t fla
|
157 | 158 |
|
158 | 159 | reg->rcache_context = xpmem_attach(xpmem_addr, bound - base, NULL);
|
159 | 160 | 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 | + } |
162 | 169 | }
|
163 | 170 |
|
164 | 171 | opal_memchecker_base_mem_defined(reg->rcache_context, bound - base);
|
@@ -307,5 +314,5 @@ mca_smsc_xpmem_module_t mca_smsc_xpmem_module = {
|
307 | 314 | .copy_from = mca_smsc_xpmem_copy_from,
|
308 | 315 | .map_peer_region = mca_smsc_xpmem_map_peer_region,
|
309 | 316 | .unmap_peer_region = mca_smsc_xpmem_unmap_peer_region,
|
310 |
| - }, |
| 317 | + }, |
311 | 318 | };
|
0 commit comments