forked from mirrors/linux
		
	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>
This commit is contained in:
		
							parent
							
								
									63afe0c217
								
							
						
					
					
						commit
						ab101c553b
					
				
					 1 changed files with 2 additions and 17 deletions
				
			
		| 
						 | 
					@ -14,7 +14,6 @@
 | 
				
			||||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 | 
					#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <linux/slab.h>
 | 
					#include <linux/slab.h>
 | 
				
			||||||
#include <linux/kmemleak.h>
 | 
					 | 
				
			||||||
#include <linux/types.h>
 | 
					#include <linux/types.h>
 | 
				
			||||||
#include <linux/kernel.h>
 | 
					#include <linux/kernel.h>
 | 
				
			||||||
#include <linux/module.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);
 | 
						ret = kmalloc(sizeof(*ret), GFP_ATOMIC);
 | 
				
			||||||
	if (!ret)
 | 
						if (!ret)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	if (size <= PAGE_SIZE) {
 | 
						buckets = kvzalloc(size, GFP_ATOMIC);
 | 
				
			||||||
		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);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (!buckets) {
 | 
						if (!buckets) {
 | 
				
			||||||
		kfree(ret);
 | 
							kfree(ret);
 | 
				
			||||||
		return NULL;
 | 
							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 *nht = container_of(head,
 | 
				
			||||||
						    struct neigh_hash_table,
 | 
											    struct neigh_hash_table,
 | 
				
			||||||
						    rcu);
 | 
											    rcu);
 | 
				
			||||||
	size_t size = (1 << nht->hash_shift) * sizeof(struct neighbour *);
 | 
					 | 
				
			||||||
	struct neighbour __rcu **buckets = nht->hash_buckets;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (size <= PAGE_SIZE) {
 | 
						kvfree(nht->hash_buckets);
 | 
				
			||||||
		kfree(buckets);
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		kmemleak_free(buckets);
 | 
					 | 
				
			||||||
		free_pages((unsigned long)buckets, get_order(size));
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	kfree(nht);
 | 
						kfree(nht);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue