[PATCH for-rc] RDMA/rxe: Allocate the MR page array with kvzalloc()
From: Qiliang Yuan
Date: Mon Nov 23 2026 - 04:26:55 EST
A user MR keeps a struct rxe_mr_page, 16 bytes on 64-bit, for every
PAGE_SIZE page it covers, in one array allocated with kzalloc() when the
MR is registered. Before the array, the pages were kept in an xarray.
With 4 KiB pages, the array of an MR larger than 1 GiB exceeds
KMALLOC_MAX_SIZE, so registering it fails with -ENOMEM, and the first
attempt warns:
WARNING: mm/slub.c:5459 at ___kmalloc_large_node+0xe9/0x130
Call Trace:
__kmalloc_large_node_noprof
__kmalloc_noprof
__alloc_mr_page_info
rxe_mr_init_user
rxe_reg_user_mr
Allocate the array with kvzalloc_objs() and free it with kvfree(), so
that MRs of any size can be registered again.
Registering an MR over THP-backed memory, median of 3:
size before (ms) after (ms) change
1 GiB 5.3 5.2 -2%
2 GiB -ENOMEM 10.8 n/a
4 GiB -ENOMEM 21.1 n/a
16 GiB -ENOMEM 85.9 n/a
Fixes: 12985e5915a0b ("RDMA/rxe: Fix iova-to-va conversion for MR page sizes != PAGE_SIZE")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Qiliang Yuan <qiliang.yuan@xxxxxxxxx>
---
drivers/infiniband/sw/rxe/rxe_mr.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c
index 13cb28d3916f6..fbf4d89947383 100644
--- a/drivers/infiniband/sw/rxe/rxe_mr.c
+++ b/drivers/infiniband/sw/rxe/rxe_mr.c
@@ -157,7 +157,7 @@ static int rxe_mr_fill_pages_from_sgt(struct rxe_mr *mr, struct sg_table *sgt)
static int __alloc_mr_page_info(struct rxe_mr *mr, int num_pages)
{
- mr->page_info = kzalloc_objs(struct rxe_mr_page, num_pages);
+ mr->page_info = kvzalloc_objs(struct rxe_mr_page, num_pages);
if (!mr->page_info)
return -ENOMEM;
@@ -186,7 +186,7 @@ static void free_mr_page_info(struct rxe_mr *mr)
if (!mr->page_info)
return;
- kfree(mr->page_info);
+ kvfree(mr->page_info);
mr->page_info = NULL;
}
---
base-commit: e7732ec135b501e87ab060d992b3b5f2ec4396c9
change-id: 20261123-bug-rdma-rxe-large-mr-f752a49d8365
Best regards,
--
Qiliang Yuan <qiliang.yuan@xxxxxxxxx>