|
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" |
@@ -678,15 +680,21 @@ static inline int mca_oob_ud_port_recv_start (mca_oob_ud_port_t *port) |
678 | 680 | static inline int mca_oob_ud_alloc_reg_mem (struct ibv_pd *pd, mca_oob_ud_reg_mem_t *reg_mem, |
679 | 681 | const int buffer_len) |
680 | 682 | { |
| 683 | + size_t buffer_len_aligned, page_size; |
681 | 684 | reg_mem->len = buffer_len; |
682 | 685 | reg_mem->ptr = NULL; |
683 | 686 | reg_mem->mr = NULL; |
684 | | - |
| 687 | + /* The allocated buffer should be a multiple of page size. |
| 688 | + If ibv_fork_init() has been invoked the pages are marked MADV_DONTFORK. |
| 689 | + If we only partially use a page, any data allocated on the remainder of |
| 690 | + the page will be inaccessible to the child process */ |
| 691 | + page_size = opal_getpagesize(); |
| 692 | + buffer_len_aligned = OPAL_ALIGN(buffer_len, page_size, size_t); |
685 | 693 | opal_output_verbose(5, orte_oob_base_framework.framework_output, |
686 | 694 | "%s oob:ud:alloc_reg_mem allocing and registering %d bytes of memory with pd %p", |
687 | 695 | ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), buffer_len, (void *) pd); |
688 | 696 |
|
689 | | - posix_memalign ((void **)®_mem->ptr, sysconf(_SC_PAGESIZE), buffer_len); |
| 697 | + posix_memalign ((void **)®_mem->ptr, page_size, buffer_len_aligned); |
690 | 698 | if (NULL == reg_mem->ptr) { |
691 | 699 | ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); |
692 | 700 | return ORTE_ERR_OUT_OF_RESOURCE; |
|
0 commit comments