mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 11:41:29 -04:00
sfc/siena: use kmalloc() to allocate logging buffer
efx_siena_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> Link: https://patch.msgid.link/20260701-b4-drivers-ethernet-v1-3-58776615db6e@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
committed by
Paolo Abeni
parent
764f2a0c6d
commit
50bfc5eac4
@@ -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"
|
||||
@@ -73,7 +74,7 @@ int efx_siena_mcdi_init(struct efx_nic *efx)
|
||||
mcdi->efx = efx;
|
||||
#ifdef CONFIG_SFC_SIENA_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 = efx_siena_mcdi_logging_default;
|
||||
@@ -116,7 +117,7 @@ int efx_siena_mcdi_init(struct efx_nic *efx)
|
||||
return 0;
|
||||
fail2:
|
||||
#ifdef CONFIG_SFC_SIENA_MCDI_LOGGING
|
||||
free_page((unsigned long)mcdi->logging_buffer);
|
||||
kfree(mcdi->logging_buffer);
|
||||
fail1:
|
||||
#endif
|
||||
kfree(efx->mcdi);
|
||||
@@ -142,7 +143,7 @@ void efx_siena_mcdi_fini(struct efx_nic *efx)
|
||||
return;
|
||||
|
||||
#ifdef CONFIG_SFC_SIENA_MCDI_LOGGING
|
||||
free_page((unsigned long)efx->mcdi->iface.logging_buffer);
|
||||
kfree(efx->mcdi->iface.logging_buffer);
|
||||
#endif
|
||||
|
||||
kfree(efx->mcdi);
|
||||
|
||||
Reference in New Issue
Block a user