[vz7] nfsd: use kvzalloc() to allocate memory for drc_hashtbl

Submitted by Oleg Babin on May 10, 2018, 3:09 p.m.

Details

Message ID 1525964960-223577-1-git-send-email-obabin@virtuozzo.com
State New
Series "nfsd: use kvzalloc() to allocate memory for drc_hashtbl"
Headers show

Commit Message

Oleg Babin May 10, 2018, 3:09 p.m.
The size of drc_hashtbl depends on totalram_pages and totalhigh_pages
mm variables and limited to 96k which means 5th memory order.

Use kvzalloc() for drc_hashtbl allocation to fallback to vmalloc()
in case of high order page is not available at the moment.

https://jira.sw.ru/browse/PSBM-84234
Signed-off-by: Oleg Babin <obabin@virtuozzo.com>
---
 fs/nfsd/nfscache.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
index a4fa08e..7f64b20 100644
--- a/fs/nfsd/nfscache.c
+++ b/fs/nfsd/nfscache.c
@@ -177,7 +177,7 @@  int nfsd_reply_cache_init(void)
 	if (!drc_slab)
 		goto out_nomem;
 
-	drc_hashtbl = kcalloc(hashsize, sizeof(*drc_hashtbl), GFP_KERNEL);
+	drc_hashtbl = kvzalloc(hashsize * sizeof(*drc_hashtbl), GFP_KERNEL);
 	if (!drc_hashtbl)
 		goto out_nomem;
 	for (i = 0; i < hashsize; i++) {
@@ -209,7 +209,7 @@  void nfsd_reply_cache_shutdown(void)
 		}
 	}
 
-	kfree (drc_hashtbl);
+	kvfree(drc_hashtbl);
 	drc_hashtbl = NULL;
 	drc_hashsize = 0;
 

Comments

Oleg Babin May 10, 2018, 5:06 p.m.
Please ignore this patch as it will be superseded with v2 patchset.

On 05/10/2018 06:09 PM, Oleg Babin wrote:
> The size of drc_hashtbl depends on totalram_pages and totalhigh_pages
> mm variables and limited to 96k which means 5th memory order.
> 
> Use kvzalloc() for drc_hashtbl allocation to fallback to vmalloc()
> in case of high order page is not available at the moment.
> 
> https://jira.sw.ru/browse/PSBM-84234
> Signed-off-by: Oleg Babin <obabin@virtuozzo.com>
> ---
>  fs/nfsd/nfscache.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
> index a4fa08e..7f64b20 100644
> --- a/fs/nfsd/nfscache.c
> +++ b/fs/nfsd/nfscache.c
> @@ -177,7 +177,7 @@ int nfsd_reply_cache_init(void)
>  	if (!drc_slab)
>  		goto out_nomem;
>  
> -	drc_hashtbl = kcalloc(hashsize, sizeof(*drc_hashtbl), GFP_KERNEL);
> +	drc_hashtbl = kvzalloc(hashsize * sizeof(*drc_hashtbl), GFP_KERNEL);
>  	if (!drc_hashtbl)
>  		goto out_nomem;
>  	for (i = 0; i < hashsize; i++) {
> @@ -209,7 +209,7 @@ void nfsd_reply_cache_shutdown(void)
>  		}
>  	}
>  
> -	kfree (drc_hashtbl);
> +	kvfree(drc_hashtbl);
>  	drc_hashtbl = NULL;
>  	drc_hashsize = 0;
>  
>