mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
sfc: use kmalloc() to allocate logging buffer
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> Link: https://patch.msgid.link/20260701-b4-drivers-ethernet-v1-4-58776615db6e@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
50bfc5eac4
commit
e8cfc70720
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user