diff mbox

[libibverbs] Allow use of huge pages in multiple calls to ibv_fork_init

Message ID 1454499762-29819-1-git-send-email-leon@leon.nu (mailing list archive)
State Accepted
Headers show

Commit Message

Leon Romanovsky Feb. 3, 2016, 11:42 a.m. UTC
From: Leon Romanovsky <leonro@mellanox.com>

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>
---
 src/memory.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Doug Ledford March 3, 2016, 2:44 a.m. UTC | #1
On 2/3/2016 6:42 AM, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@mellanox.com>
> 
> 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.

Thanks, applied.

> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> ---
>  src/memory.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/src/memory.c b/src/memory.c
> index e9d1eecd9eab..89509c6e356f 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));
>
diff mbox

Patch

diff --git a/src/memory.c b/src/memory.c
index e9d1eecd9eab..89509c6e356f 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));