Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Eric Dumazet and committed by
Jakub Kicinski
ab101c55 63afe0c2

+2 -17
+2 -17
net/core/neighbour.c
··· 14 14 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 15 15 16 16 #include <linux/slab.h> 17 - #include <linux/kmemleak.h> 18 17 #include <linux/types.h> 19 18 #include <linux/kernel.h> 20 19 #include <linux/module.h> ··· 537 538 ret = kmalloc(sizeof(*ret), GFP_ATOMIC); 538 539 if (!ret) 539 540 return NULL; 540 - if (size <= PAGE_SIZE) { 541 - buckets = kzalloc(size, GFP_ATOMIC); 542 - } else { 543 - buckets = (struct neighbour __rcu **) 544 - __get_free_pages(GFP_ATOMIC | __GFP_ZERO, 545 - get_order(size)); 546 - kmemleak_alloc(buckets, size, 1, GFP_ATOMIC); 547 - } 541 + buckets = kvzalloc(size, GFP_ATOMIC); 548 542 if (!buckets) { 549 543 kfree(ret); 550 544 return NULL; ··· 554 562 struct neigh_hash_table *nht = container_of(head, 555 563 struct neigh_hash_table, 556 564 rcu); 557 - size_t size = (1 << nht->hash_shift) * sizeof(struct neighbour *); 558 - struct neighbour __rcu **buckets = nht->hash_buckets; 559 565 560 - if (size <= PAGE_SIZE) { 561 - kfree(buckets); 562 - } else { 563 - kmemleak_free(buckets); 564 - free_pages((unsigned long)buckets, get_order(size)); 565 - } 566 + kvfree(nht->hash_buckets); 566 567 kfree(nht); 567 568 } 568 569