mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 21:48:54 +02:00
RDMA/mlx5: replace __get_free_page() with kmalloc()
mlx5_ib_mr_wqe_pfault_handler() allocates a scratch buffer for parsing work queue entries during page fault handling. 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> Link: https://patch.msgid.link/20260713-b4-rdma-v2-2-65d2a1a5180c@kernel.org Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
parent
66073100a7
commit
e3d8c413e2
|
|
@ -37,6 +37,7 @@
|
|||
#include <linux/hmm.h>
|
||||
#include <linux/hmm-dma.h>
|
||||
#include <linux/pci-p2pdma.h>
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include "mlx5_ib.h"
|
||||
#include "cmd.h"
|
||||
|
|
@ -1414,7 +1415,8 @@ static void mlx5_ib_mr_wqe_pfault_handler(struct mlx5_ib_dev *dev,
|
|||
goto resolve_page_fault;
|
||||
}
|
||||
|
||||
wqe_start = (void *)__get_free_page(GFP_KERNEL);
|
||||
/* TODO: switch to "fast and as large as possible" allocation helper */
|
||||
wqe_start = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
||||
if (!wqe_start) {
|
||||
mlx5_ib_err(dev, "Error allocating memory for IO page fault handling.\n");
|
||||
goto resolve_page_fault;
|
||||
|
|
@ -1475,7 +1477,7 @@ static void mlx5_ib_mr_wqe_pfault_handler(struct mlx5_ib_dev *dev,
|
|||
pfault->wqe.wq_num, resume_with_error,
|
||||
pfault->type);
|
||||
mlx5_core_res_put(res);
|
||||
free_page((unsigned long)wqe_start);
|
||||
kfree(wqe_start);
|
||||
}
|
||||
|
||||
static void mlx5_ib_mr_rdma_pfault_handler(struct mlx5_ib_dev *dev,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user