mirror of
https://github.com/torvalds/linux.git
synced 2026-09-27 10:36:23 +02:00
bnx2x: use kzalloc() to allocate mac filtering list
bnx2x_mcast_enqueue_cmd() allocates memory for mac filtering list using __get_free_pages(). This memory can be allocated with kzalloc() as there's nothing special about it to go directly to the page allocator. kmalloc() provides a better API that does not require ugly casts and kfree() does not need to know the size of the freed object. Performance difference between kmalloc() and __get_free_pages() is not measurable as both allocators take an object/page from a per-CPU list for fast path allocations. For the slow path the performance is anyway determined by the amount of reclaim involved rather than by what allocator is used. Replace use of __get_free_page() with kzalloc() and free_page() with kfree(). Link: https://lore.kernel.org/all/635405e4-9423-4a25-a6e7-e03c8ea0bcbe@redhat.com Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Link: https://patch.msgid.link/20260701-b4-drivers-ethernet-v1-1-58776615db6e@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
4fa0619d03
commit
28a236c54c
|
|
@ -26,6 +26,7 @@
|
|||
#include <linux/netdevice.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/crc32c.h>
|
||||
#include <linux/slab.h>
|
||||
#include "bnx2x.h"
|
||||
#include "bnx2x_cmn.h"
|
||||
#include "bnx2x_sp.h"
|
||||
|
|
@ -2664,7 +2665,7 @@ static void bnx2x_free_groups(struct list_head *mcast_group_list)
|
|||
struct bnx2x_mcast_elem_group,
|
||||
mcast_group_link);
|
||||
list_del(¤t_mcast_group->mcast_group_link);
|
||||
free_page((unsigned long)current_mcast_group);
|
||||
kfree(current_mcast_group);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2713,8 +2714,7 @@ static int bnx2x_mcast_enqueue_cmd(struct bnx2x *bp,
|
|||
total_elems = BNX2X_MCAST_BINS_NUM;
|
||||
}
|
||||
while (total_elems > 0) {
|
||||
elem_group = (struct bnx2x_mcast_elem_group *)
|
||||
__get_free_page(GFP_ATOMIC | __GFP_ZERO);
|
||||
elem_group = kzalloc(PAGE_SIZE, GFP_ATOMIC);
|
||||
if (!elem_group) {
|
||||
bnx2x_free_groups(&new_cmd->group_head);
|
||||
kfree(new_cmd);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user