Skip to content

Commit c18af0d

Browse files
committed
Merge pull request #1378 from nysal/issue_1363
Make UD OOB memory registrations a multiple of page size
2 parents 2745610 + cc9b131 commit c18af0d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

orte/mca/oob/ud/oob_ud_component.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include "orte_config.h"
2020
#include "orte/types.h"
2121
#include "opal/types.h"
22+
#include "opal/align.h"
23+
#include "opal/util/sys_limits.h"
2224

2325
#include "orte/mca/errmgr/errmgr.h"
2426
#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)
678680
static inline int mca_oob_ud_alloc_reg_mem (struct ibv_pd *pd, mca_oob_ud_reg_mem_t *reg_mem,
679681
const int buffer_len)
680682
{
683+
size_t buffer_len_aligned, page_size;
681684
reg_mem->len = buffer_len;
682685
reg_mem->ptr = NULL;
683686
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);
685693
opal_output_verbose(5, orte_oob_base_framework.framework_output,
686694
"%s oob:ud:alloc_reg_mem allocing and registering %d bytes of memory with pd %p",
687695
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), buffer_len, (void *) pd);
688696

689-
posix_memalign ((void **)&reg_mem->ptr, sysconf(_SC_PAGESIZE), buffer_len);
697+
posix_memalign ((void **)&reg_mem->ptr, page_size, buffer_len_aligned);
690698
if (NULL == reg_mem->ptr) {
691699
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
692700
return ORTE_ERR_OUT_OF_RESOURCE;

0 commit comments

Comments
 (0)