diff mbox series

[net-next] neighbour: use kvzalloc()/kvfree()

Message ID 20241022150059.1345406-1-edumazet@google.com (mailing list archive)
State Accepted
Commit ab101c553bc1f76a839163d1dc0d1e715ad6bb4e
Delegated to: Netdev Maintainers
Headers show
Series [net-next] neighbour: use kvzalloc()/kvfree() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 6 this patch: 6
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 38 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-10-23--12-00 (tests: 777)

Commit Message

Eric Dumazet Oct. 22, 2024, 3 p.m. UTC
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>
---
 net/core/neighbour.c | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

Comments

Joe Damato Oct. 22, 2024, 4:14 p.m. UTC | #1
On Tue, Oct 22, 2024 at 03:00:59PM +0000, Eric Dumazet wrote:
> 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>
Kuniyuki Iwashima Oct. 22, 2024, 9:11 p.m. UTC | #2
From: Eric Dumazet <edumazet@google.com>
Date: Tue, 22 Oct 2024 15:00:59 +0000
> 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: Kuniyuki Iwashima <kuniyu@amazon.com>
patchwork-bot+netdevbpf@kernel.org Oct. 29, 2024, 2:40 a.m. UTC | #3
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 22 Oct 2024 15:00:59 +0000 you wrote:
> 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>
> ---
>  net/core/neighbour.c | 19 ++-----------------
>  1 file changed, 2 insertions(+), 17 deletions(-)

Here is the summary with links:
  - [net-next] neighbour: use kvzalloc()/kvfree()
    https://git.kernel.org/netdev/net-next/c/ab101c553bc1

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 395ae1626eef2f22f5b81051671371ed67eb5943..4b871cecd2cee9ccc88e5d29d090c49978cbae9f 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -14,7 +14,6 @@ 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
 #include <linux/slab.h>
-#include <linux/kmemleak.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -538,14 +537,7 @@  static struct neigh_hash_table *neigh_hash_alloc(unsigned int shift)
 	ret = kmalloc(sizeof(*ret), GFP_ATOMIC);
 	if (!ret)
 		return NULL;
-	if (size <= PAGE_SIZE) {
-		buckets = kzalloc(size, GFP_ATOMIC);
-	} else {
-		buckets = (struct neighbour __rcu **)
-			  __get_free_pages(GFP_ATOMIC | __GFP_ZERO,
-					   get_order(size));
-		kmemleak_alloc(buckets, size, 1, GFP_ATOMIC);
-	}
+	buckets = kvzalloc(size, GFP_ATOMIC);
 	if (!buckets) {
 		kfree(ret);
 		return NULL;
@@ -562,15 +554,8 @@  static void neigh_hash_free_rcu(struct rcu_head *head)
 	struct neigh_hash_table *nht = container_of(head,
 						    struct neigh_hash_table,
 						    rcu);
-	size_t size = (1 << nht->hash_shift) * sizeof(struct neighbour *);
-	struct neighbour __rcu **buckets = nht->hash_buckets;
 
-	if (size <= PAGE_SIZE) {
-		kfree(buckets);
-	} else {
-		kmemleak_free(buckets);
-		free_pages((unsigned long)buckets, get_order(size));
-	}
+	kvfree(nht->hash_buckets);
 	kfree(nht);
 }