From: Edward Cree <ecree.xilinx@gmail.com>
To: "Mike Rapoport (Microsoft)" <rppt@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Manish Chopra <manishc@marvell.com>,
Paolo Abeni <pabeni@redhat.com>
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Sudarsana Kalluru <skalluru@marvell.com>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, linux-net-drivers@amd.com,
netdev@vger.kernel.org
Subject: Re: [PATCH 4/4] sfc: use kmalloc() to allocate logging buffer
Date: Wed, 1 Jul 2026 17:59:56 +0100 [thread overview]
Message-ID: <df6a8720-fa5e-490b-bfb5-817ba53ff59b@gmail.com> (raw)
In-Reply-To: <20260701-b4-drivers-ethernet-v1-4-58776615db6e@kernel.org>
On 01/07/2026 14:57, Mike Rapoport (Microsoft) wrote:
> efx_mcdi_init() allocates a logging buffer for MCDI firmware
> communication diagnostics.
>
> This buffer can be allocated with kmalloc() 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 kmalloc() 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>
Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
> ---
> drivers/net/ethernet/sfc/mcdi.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c
> index e65db9b70724..b806d3d90c42 100644
> --- a/drivers/net/ethernet/sfc/mcdi.c
> +++ b/drivers/net/ethernet/sfc/mcdi.c
> @@ -7,6 +7,7 @@
> #include <linux/delay.h>
> #include <linux/moduleparam.h>
> #include <linux/atomic.h>
> +#include <linux/slab.h>
> #include "net_driver.h"
> #include "nic.h"
> #include "io.h"
> @@ -71,7 +72,7 @@ int efx_mcdi_init(struct efx_nic *efx)
> mcdi->efx = efx;
> #ifdef CONFIG_SFC_MCDI_LOGGING
> /* consuming code assumes buffer is page-sized */
> - mcdi->logging_buffer = (char *)__get_free_page(GFP_KERNEL);
> + mcdi->logging_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
> if (!mcdi->logging_buffer)
> goto fail1;
> mcdi->logging_enabled = mcdi_logging_default;
> @@ -112,7 +113,7 @@ int efx_mcdi_init(struct efx_nic *efx)
> return 0;
> fail2:
> #ifdef CONFIG_SFC_MCDI_LOGGING
> - free_page((unsigned long)mcdi->logging_buffer);
> + kfree(mcdi->logging_buffer);
> fail1:
> #endif
> kfree(efx->mcdi);
> @@ -138,7 +139,7 @@ void efx_mcdi_fini(struct efx_nic *efx)
> return;
>
> #ifdef CONFIG_SFC_MCDI_LOGGING
> - free_page((unsigned long)efx->mcdi->iface.logging_buffer);
> + kfree(efx->mcdi->iface.logging_buffer);
> #endif
>
> kfree(efx->mcdi);
>
WARNING: multiple messages have this Message-ID (diff)
From: Edward Cree <ecree.xilinx@gmail.com>
To: "Mike Rapoport (Microsoft)" <rppt@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Manish Chopra <manishc@marvell.com>,
Paolo Abeni <pabeni@redhat.com>
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Sudarsana Kalluru <skalluru@marvell.com>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, linux-net-drivers@amd.com,
netdev@vger.kernel.org
Subject: Re: [Intel-wired-lan] [PATCH 4/4] sfc: use kmalloc() to allocate logging buffer
Date: Wed, 1 Jul 2026 17:59:56 +0100 [thread overview]
Message-ID: <df6a8720-fa5e-490b-bfb5-817ba53ff59b@gmail.com> (raw)
In-Reply-To: <20260701-b4-drivers-ethernet-v1-4-58776615db6e@kernel.org>
On 01/07/2026 14:57, Mike Rapoport (Microsoft) wrote:
> efx_mcdi_init() allocates a logging buffer for MCDI firmware
> communication diagnostics.
>
> This buffer can be allocated with kmalloc() 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 kmalloc() 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>
Reviewed-by: Edward Cree <ecree.xilinx@gmail.com>
> ---
> drivers/net/ethernet/sfc/mcdi.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c
> index e65db9b70724..b806d3d90c42 100644
> --- a/drivers/net/ethernet/sfc/mcdi.c
> +++ b/drivers/net/ethernet/sfc/mcdi.c
> @@ -7,6 +7,7 @@
> #include <linux/delay.h>
> #include <linux/moduleparam.h>
> #include <linux/atomic.h>
> +#include <linux/slab.h>
> #include "net_driver.h"
> #include "nic.h"
> #include "io.h"
> @@ -71,7 +72,7 @@ int efx_mcdi_init(struct efx_nic *efx)
> mcdi->efx = efx;
> #ifdef CONFIG_SFC_MCDI_LOGGING
> /* consuming code assumes buffer is page-sized */
> - mcdi->logging_buffer = (char *)__get_free_page(GFP_KERNEL);
> + mcdi->logging_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
> if (!mcdi->logging_buffer)
> goto fail1;
> mcdi->logging_enabled = mcdi_logging_default;
> @@ -112,7 +113,7 @@ int efx_mcdi_init(struct efx_nic *efx)
> return 0;
> fail2:
> #ifdef CONFIG_SFC_MCDI_LOGGING
> - free_page((unsigned long)mcdi->logging_buffer);
> + kfree(mcdi->logging_buffer);
> fail1:
> #endif
> kfree(efx->mcdi);
> @@ -138,7 +139,7 @@ void efx_mcdi_fini(struct efx_nic *efx)
> return;
>
> #ifdef CONFIG_SFC_MCDI_LOGGING
> - free_page((unsigned long)efx->mcdi->iface.logging_buffer);
> + kfree(efx->mcdi->iface.logging_buffer);
> #endif
>
> kfree(efx->mcdi);
>
next prev parent reply other threads:[~2026-07-01 16:59 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 13:57 [PATCH 0/4] drivers/net/ethernet: replace __get_free_pages() with kmalloc() Mike Rapoport (Microsoft)
2026-07-01 13:57 ` [Intel-wired-lan] " Mike Rapoport (Microsoft)
2026-07-01 13:57 ` [PATCH 1/4] bnx2x: use kzalloc() to allocate mac filtering list Mike Rapoport (Microsoft)
2026-07-01 13:57 ` [Intel-wired-lan] " Mike Rapoport (Microsoft)
2026-07-02 13:52 ` Przemek Kitszel
2026-07-02 13:52 ` Przemek Kitszel
2026-07-02 14:35 ` Mike Rapoport
2026-07-02 14:35 ` [Intel-wired-lan] " Mike Rapoport
2026-07-01 13:57 ` [PATCH 2/4] ice: use kzalloc() to allocate staging buffer for reading from GNSS Mike Rapoport (Microsoft)
2026-07-01 13:57 ` [Intel-wired-lan] " Mike Rapoport (Microsoft)
2026-07-02 13:49 ` Przemek Kitszel
2026-07-02 13:49 ` Przemek Kitszel
2026-07-02 14:40 ` Mike Rapoport
2026-07-02 14:40 ` [Intel-wired-lan] " Mike Rapoport
2026-07-03 9:34 ` Przemek Kitszel
2026-07-01 13:57 ` [PATCH 3/4] sfc/siena: use kmalloc() to allocate logging buffer Mike Rapoport (Microsoft)
2026-07-01 13:57 ` [Intel-wired-lan] " Mike Rapoport (Microsoft)
2026-07-01 17:01 ` Edward Cree
2026-07-01 17:01 ` [Intel-wired-lan] " Edward Cree
2026-07-01 13:57 ` [Intel-wired-lan] [PATCH 4/4] sfc: " Mike Rapoport (Microsoft)
2026-07-01 13:57 ` Mike Rapoport (Microsoft)
2026-07-01 16:59 ` Edward Cree [this message]
2026-07-01 16:59 ` [Intel-wired-lan] " Edward Cree
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=df6a8720-fa5e-490b-bfb5-817ba53ff59b@gmail.com \
--to=ecree.xilinx@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-net-drivers@amd.com \
--cc=manishc@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=rppt@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.