|
19 | 19 | #include "orte_config.h"
|
20 | 20 | #include "orte/types.h"
|
21 | 21 | #include "opal/types.h"
|
| 22 | +#include "opal/align.h" |
| 23 | +#include "opal/util/sys_limits.h" |
22 | 24 |
|
23 | 25 | #include "orte/mca/errmgr/errmgr.h"
|
24 | 26 | #include "orte/runtime/orte_globals.h"
|
@@ -665,15 +667,21 @@ static inline int mca_oob_ud_port_recv_start (mca_oob_ud_port_t *port)
|
665 | 667 | static inline int mca_oob_ud_alloc_reg_mem (struct ibv_pd *pd, mca_oob_ud_reg_mem_t *reg_mem,
|
666 | 668 | const int buffer_len)
|
667 | 669 | {
|
| 670 | + size_t buffer_len_aligned, page_size; |
668 | 671 | reg_mem->len = buffer_len;
|
669 | 672 | reg_mem->ptr = NULL;
|
670 | 673 | reg_mem->mr = NULL;
|
671 |
| - |
| 674 | + /* The allocated buffer should be a multiple of page size. |
| 675 | + If ibv_fork_init() has been invoked the pages are marked MADV_DONTFORK. |
| 676 | + If we only partially use a page, any data allocated on the remainder of |
| 677 | + the page will be inaccessible to the child process */ |
| 678 | + page_size = opal_getpagesize(); |
| 679 | + buffer_len_aligned = OPAL_ALIGN(buffer_len, page_size, size_t); |
672 | 680 | opal_output_verbose(5, orte_oob_base_framework.framework_output,
|
673 | 681 | "%s oob:ud:alloc_reg_mem allocing and registering %d bytes of memory with pd %p",
|
674 | 682 | ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), buffer_len, (void *) pd);
|
675 | 683 |
|
676 |
| - posix_memalign ((void **)®_mem->ptr, sysconf(_SC_PAGESIZE), buffer_len); |
| 684 | + posix_memalign ((void **)®_mem->ptr, page_size, buffer_len_aligned); |
677 | 685 | if (NULL == reg_mem->ptr) {
|
678 | 686 | ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
679 | 687 | return ORTE_ERR_OUT_OF_RESOURCE;
|
|
0 commit comments