From: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: Brian Norris <briannorris@chromium.org>,
Edward Cree <ecree.xilinx@gmail.com>,
Francesco Dolcini <francesco@dolcini.it>,
Manish Chopra <manishc@marvell.com>,
Mike Rapoport <rppt@kernel.org>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Sudarsana Kalluru <skalluru@marvell.com>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
b43-dev@lists.infradead.org, intel-wired-lan@lists.osuosl.org,
libertas-dev@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, linux-net-drivers@amd.com,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH net-next 2/8] bnx2x: use kzalloc() to allocate mac filtering list
Date: Tue, 30 Jun 2026 13:59:21 +0300 [thread overview]
Message-ID: <20260630-b4-drivers-net-v1-2-672162a91f37@kernel.org> (raw)
In-Reply-To: <20260630-b4-drivers-net-v1-0-672162a91f37@kernel.org>
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>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
index 07a908a2c72f..d560524d317d 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
@@ -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);
--
2.53.0
next prev parent reply other threads:[~2026-06-30 10:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 10:59 [PATCH net-next 0/8] drivers/net: replace __get_free_pages() with kmalloc() Mike Rapoport (Microsoft)
2026-06-30 10:59 ` [PATCH net-next 1/8] b43, b43legacy: debugfs: use kmalloc() to allocate formatting buffers Mike Rapoport (Microsoft)
2026-06-30 10:59 ` Mike Rapoport (Microsoft) [this message]
2026-06-30 10:59 ` [PATCH net-next 3/8] ice: use kzalloc() to allocate staging buffer for reading from GNSS Mike Rapoport (Microsoft)
2026-06-30 10:59 ` [PATCH net-next 4/8] libertas: debugfs: use kzalloc() to allocate formatting buffers Mike Rapoport (Microsoft)
2026-06-30 10:59 ` [PATCH net-next 5/8] mwifiex: " Mike Rapoport (Microsoft)
2026-06-30 10:59 ` [PATCH net-next 6/8] sfc/siena: use kmalloc() to allocate logging buffer Mike Rapoport (Microsoft)
2026-06-30 10:59 ` [PATCH net-next 7/8] sfc: " Mike Rapoport (Microsoft)
2026-06-30 10:59 ` [PATCH net-next 8/8] wlcore: allocate aggregation and firmware log buffers with kzalloc() Mike Rapoport (Microsoft)
2026-06-30 14:23 ` [PATCH net-next 0/8] drivers/net: replace __get_free_pages() with kmalloc() Jakub Kicinski
2026-06-30 14:40 ` Mike Rapoport
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260630-b4-drivers-net-v1-2-672162a91f37@kernel.org \
--to=rppt@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=b43-dev@lists.infradead.org \
--cc=briannorris@chromium.org \
--cc=davem@davemloft.net \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@google.com \
--cc=francesco@dolcini.it \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kuba@kernel.org \
--cc=libertas-dev@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-net-drivers@amd.com \
--cc=linux-wireless@vger.kernel.org \
--cc=manishc@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=skalluru@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox