aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeon Romanovsky <leonro@mellanox.com>2016-02-03 13:42:42 +0200
committerYishai Hadas <yishaih@mellanox.com>2016-05-17 16:40:12 +0300
commitb5eac7cbfb0a9060f24aef8a17579140ab8b18dc (patch)
tree874673565cc0c80d95c89692c255708e50946b7b
parent027dd68002ae081b71b2a36a4e1b0becab37f798 (diff)
downloadlibibverbs-b5eac7cbfb0a9060f24aef8a17579140ab8b18dc.tar.gz
Allow use of huge pages in multiple calls to ibv_fork_init
Setting the environment variable RDMAV_HUGEPAGES_SAFE tells the library to check the underlying page size used by the kernel for memory regions. This is required if an application uses huge pages either directly or indirectly via a library such as libhugetlbfs. The check of this variable was performed at the first call to ibv_fork_init. This caused to unpredicted behavior in complex applications with multiple underlying libraries. The proposed change will allow support of huge pages without relying on ibv_fork_init calls order. Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--src/memory.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/memory.c b/src/memory.c
index e9d1eec..89509c6 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -140,6 +140,9 @@ int ibv_fork_init(void)
int ret;
unsigned long size;
+ if (getenv("RDMAV_HUGEPAGES_SAFE"))
+ huge_page_enabled = 1;
+
if (mm_root)
return 0;
@@ -153,11 +156,6 @@ int ibv_fork_init(void)
if (posix_memalign(&tmp, page_size, page_size))
return ENOMEM;
- if (getenv("RDMAV_HUGEPAGES_SAFE"))
- huge_page_enabled = 1;
- else
- huge_page_enabled = 0;
-
if (huge_page_enabled) {
size = get_page_size(tmp);
tmp_aligned = (void *) ((uintptr_t) tmp & ~(size - 1));