Skip to content

Commit 7441e76

Browse files
Michal Hockohnaz
authored andcommitted
lib/rhashtable.c: use kvzalloc() in bucket_table_alloc() when possible
bucket_table_alloc() can be currently called with GFP_KERNEL or GFP_ATOMIC. For the former we basically have an open coded kvzalloc() while the later only uses kzalloc(). Let's simplify the code a bit by the dropping the open coded path and replace it with kvzalloc(). Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Michal Hocko <[email protected]> Cc: Thomas Graf <[email protected]> Cc: Herbert Xu <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent a597286 commit 7441e76

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/rhashtable.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,10 @@ static struct bucket_table *bucket_table_alloc(struct rhashtable *ht,
211211
int i;
212212

213213
size = sizeof(*tbl) + nbuckets * sizeof(tbl->buckets[0]);
214-
if (size <= (PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER) ||
215-
gfp != GFP_KERNEL)
214+
if (gfp != GFP_KERNEL)
216215
tbl = kzalloc(size, gfp | __GFP_NOWARN | __GFP_NORETRY);
217-
if (tbl == NULL && gfp == GFP_KERNEL)
218-
tbl = vzalloc(size);
216+
else
217+
tbl = kvzalloc(size, gfp);
219218

220219
size = nbuckets;
221220

0 commit comments

Comments
 (0)