Skip to content

Commit ab101c5

Browse files
Eric Dumazetkuba-moo
Eric Dumazet
authored andcommitted
neighbour: use kvzalloc()/kvfree()
mm layer is providing convenient functions, we do not have to work around old limitations. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Gilad Naaman <gnaaman@drivenets.com> Reviewed-by: Joe Damato <jdamato@fastly.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://patch.msgid.link/20241022150059.1345406-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 63afe0c commit ab101c5

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

net/core/neighbour.c

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1515

1616
#include <linux/slab.h>
17-
#include <linux/kmemleak.h>
1817
#include <linux/types.h>
1918
#include <linux/kernel.h>
2019
#include <linux/module.h>
@@ -538,14 +537,7 @@ static struct neigh_hash_table *neigh_hash_alloc(unsigned int shift)
538537
ret = kmalloc(sizeof(*ret), GFP_ATOMIC);
539538
if (!ret)
540539
return NULL;
541-
if (size <= PAGE_SIZE) {
542-
buckets = kzalloc(size, GFP_ATOMIC);
543-
} else {
544-
buckets = (struct neighbour __rcu **)
545-
__get_free_pages(GFP_ATOMIC | __GFP_ZERO,
546-
get_order(size));
547-
kmemleak_alloc(buckets, size, 1, GFP_ATOMIC);
548-
}
540+
buckets = kvzalloc(size, GFP_ATOMIC);
549541
if (!buckets) {
550542
kfree(ret);
551543
return NULL;
@@ -562,15 +554,8 @@ static void neigh_hash_free_rcu(struct rcu_head *head)
562554
struct neigh_hash_table *nht = container_of(head,
563555
struct neigh_hash_table,
564556
rcu);
565-
size_t size = (1 << nht->hash_shift) * sizeof(struct neighbour *);
566-
struct neighbour __rcu **buckets = nht->hash_buckets;
567557

568-
if (size <= PAGE_SIZE) {
569-
kfree(buckets);
570-
} else {
571-
kmemleak_free(buckets);
572-
free_pages((unsigned long)buckets, get_order(size));
573-
}
558+
kvfree(nht->hash_buckets);
574559
kfree(nht);
575560
}
576561

0 commit comments

Comments
 (0)