* [PATCH] silence nfscache allocation warnings with kvzalloc
@ 2020-09-14 17:07 Rik van Riel
2020-09-14 20:36 ` J. Bruce Fields
0 siblings, 1 reply; 2+ messages in thread
From: Rik van Riel @ 2020-09-14 17:07 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: Chuck Lever, linux-nfs, linux-kernel, kernel-team
silence nfscache allocation warnings with kvzalloc
Currently nfsd_reply_cache_init attempts hash table allocation through
kmalloc, and manually falls back to vzalloc if that fails. This makes
the code a little larger than needed, and creates a significant amount
of serial console spam if you have enough systems.
Switching to kvzalloc gets rid of the allocation warnings, and makes
the code a little cleaner too as a side effect.
Freeing of nn->drc_hashtbl is already done using kvfree currently.
Signed-off-by: Rik van Riel <riel@surriel.com>
---
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
index 96352ab7bd81..5125b5ef25b6 100644
--- a/fs/nfsd/nfscache.c
+++ b/fs/nfsd/nfscache.c
@@ -164,14 +164,10 @@ int nfsd_reply_cache_init(struct nfsd_net *nn)
if (!nn->drc_slab)
goto out_shrinker;
- nn->drc_hashtbl = kcalloc(hashsize,
- sizeof(*nn->drc_hashtbl), GFP_KERNEL);
- if (!nn->drc_hashtbl) {
- nn->drc_hashtbl = vzalloc(array_size(hashsize,
- sizeof(*nn->drc_hashtbl)));
- if (!nn->drc_hashtbl)
- goto out_slab;
- }
+ nn->drc_hashtbl = kvzalloc(array_size(hashsize,
+ sizeof(*nn->drc_hashtbl)), GFP_KERNEL);
+ if (!nn->drc_hashtbl)
+ goto out_slab;
for (i = 0; i < hashsize; i++) {
INIT_LIST_HEAD(&nn->drc_hashtbl[i].lru_head);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] silence nfscache allocation warnings with kvzalloc
2020-09-14 17:07 [PATCH] silence nfscache allocation warnings with kvzalloc Rik van Riel
@ 2020-09-14 20:36 ` J. Bruce Fields
0 siblings, 0 replies; 2+ messages in thread
From: J. Bruce Fields @ 2020-09-14 20:36 UTC (permalink / raw)
To: Rik van Riel; +Cc: Chuck Lever, linux-nfs, linux-kernel, kernel-team
Applying, thanks.--b.
On Mon, Sep 14, 2020 at 01:07:19PM -0400, Rik van Riel wrote:
> silence nfscache allocation warnings with kvzalloc
>
> Currently nfsd_reply_cache_init attempts hash table allocation through
> kmalloc, and manually falls back to vzalloc if that fails. This makes
> the code a little larger than needed, and creates a significant amount
> of serial console spam if you have enough systems.
>
> Switching to kvzalloc gets rid of the allocation warnings, and makes
> the code a little cleaner too as a side effect.
>
> Freeing of nn->drc_hashtbl is already done using kvfree currently.
>
> Signed-off-by: Rik van Riel <riel@surriel.com>
> ---
> diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
> index 96352ab7bd81..5125b5ef25b6 100644
> --- a/fs/nfsd/nfscache.c
> +++ b/fs/nfsd/nfscache.c
> @@ -164,14 +164,10 @@ int nfsd_reply_cache_init(struct nfsd_net *nn)
> if (!nn->drc_slab)
> goto out_shrinker;
>
> - nn->drc_hashtbl = kcalloc(hashsize,
> - sizeof(*nn->drc_hashtbl), GFP_KERNEL);
> - if (!nn->drc_hashtbl) {
> - nn->drc_hashtbl = vzalloc(array_size(hashsize,
> - sizeof(*nn->drc_hashtbl)));
> - if (!nn->drc_hashtbl)
> - goto out_slab;
> - }
> + nn->drc_hashtbl = kvzalloc(array_size(hashsize,
> + sizeof(*nn->drc_hashtbl)), GFP_KERNEL);
> + if (!nn->drc_hashtbl)
> + goto out_slab;
>
> for (i = 0; i < hashsize; i++) {
> INIT_LIST_HEAD(&nn->drc_hashtbl[i].lru_head);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-14 20:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14 17:07 [PATCH] silence nfscache allocation warnings with kvzalloc Rik van Riel
2020-09-14 20:36 ` J. Bruce Fields
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.