Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH] RDMA/irdma: Use kvzalloc for lvl2 leafmem allocation
@ 2026-09-16 17:32 Jeremy Bongio
  2026-09-16 17:42 ` sashiko-bot
  2026-09-22 14:16 ` Leon Romanovsky
  0 siblings, 2 replies; 4+ messages in thread
From: Jeremy Bongio @ 2026-09-16 17:32 UTC (permalink / raw)
  To: tatyana.e.nikolova, jgg, leon; +Cc: linux-rdma, jmoroni, Jeremy Bongio

During VM live migration or when registering large memory regions
(e.g., guest memory >= 256 GB backed by 4 KiB pages), get_lvl2_pble()
calculates total leaves exceeding ~131,072. The memory required for
lvl2->leafmem.va exceeds 4 MiB (sizeof(*leaf) * total > 5.24 MiB).

Because kzalloc() requires physically contiguous pages, requests larger
than MAX_PAGE_ORDER (4 MiB on x86_64) fail and trigger a warning:

  WARNING: CPU: 123 PID: 119906 at mm/page_alloc.c:5997 __alloc_frozen_pages_noprof+0x50c/0x1050
  Call Trace:
   <TASK>
   alloc_frozen_pages_noprof+0xc0/0x240
   ___kmalloc_large_node+0x3d/0xd0
   __kmalloc_large_node_noprof+0x1b/0x90
   __kmalloc_noprof+0x254/0x660
   get_lvl1_lvl2_pble+0xbc/0x270 [irdma]
   irdma_get_pble+0x44/0xc0 [irdma]
   irdma_setup_pbles+0x46/0x1d0 [irdma]
   irdma_reg_user_mr_type_mem+0x41/0x230 [irdma]
   irdma_reg_user_mr+0x194/0x1c0 [irdma]
   ib_uverbs_reg_mr+0x1b0/0x2c0 [ib_uverbs]

The leafmem array is purely host software tracking structures (struct
irdma_pble_info) and does not require physically contiguous memory.

Switch the allocation from kzalloc() to kvzalloc() and free it with
kvfree() so that requests exceeding MAX_PAGE_ORDER fall back to
virtually contiguous memory via vmalloc.

Fixes: e8c4dbc2fcac ("RDMA/irdma: Add PBLE resource manager")
Assisted-by: LLM
Signed-off-by: Jeremy Bongio <jbongio@google.com>
---
 drivers/infiniband/hw/irdma/pble.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/irdma/pble.c b/drivers/infiniband/hw/irdma/pble.c
index 28dfad7f940c..5380cfbfec21 100644
--- a/drivers/infiniband/hw/irdma/pble.c
+++ b/drivers/infiniband/hw/irdma/pble.c
@@ -330,7 +330,7 @@ static void free_lvl2(struct irdma_hmc_pble_rsrc *pble_rsrc,
 	if (root->addr)
 		irdma_prm_return_pbles(&pble_rsrc->pinfo, &root->chunkinfo);
 
-	kfree(lvl2->leafmem.va);
+	kvfree(lvl2->leafmem.va);
 	lvl2->leaf = NULL;
 }
 
@@ -358,7 +358,7 @@ static int get_lvl2_pble(struct irdma_hmc_pble_rsrc *pble_rsrc,
 	lvl2->leaf_cnt = total;
 
 	lvl2->leafmem.size = (sizeof(*leaf) * total);
-	lvl2->leafmem.va = kzalloc(lvl2->leafmem.size, GFP_KERNEL);
+	lvl2->leafmem.va = kvzalloc(lvl2->leafmem.size, GFP_KERNEL);
 	if (!lvl2->leafmem.va)
 		return -ENOMEM;
 
@@ -367,7 +367,7 @@ static int get_lvl2_pble(struct irdma_hmc_pble_rsrc *pble_rsrc,
 	ret_code = irdma_prm_get_pbles(&pble_rsrc->pinfo, &root->chunkinfo,
 				       total << 3, &root->addr, &fpm_addr);
 	if (ret_code) {
-		kfree(lvl2->leafmem.va);
+		kvfree(lvl2->leafmem.va);
 		lvl2->leaf = NULL;
 		return -ENOMEM;
 	}
-- 
2.55.0.1082.g2b9226bbc0-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] RDMA/irdma: Use kvzalloc for lvl2 leafmem allocation
  2026-09-16 17:32 [PATCH] RDMA/irdma: Use kvzalloc for lvl2 leafmem allocation Jeremy Bongio
@ 2026-09-16 17:42 ` sashiko-bot
  2026-09-16 18:32   ` Jacob Moroni
  2026-09-22 14:16 ` Leon Romanovsky
  1 sibling, 1 reply; 4+ messages in thread
From: sashiko-bot @ 2026-09-16 17:42 UTC (permalink / raw)
  To: Jeremy Bongio; +Cc: linux-rdma

> During VM live migration or when registering large memory regions
> (e.g., guest memory >= 256 GB backed by 4 KiB pages), get_lvl2_pble()
> calculates total leaves exceeding ~131,072. The memory required for
> lvl2->leafmem.va exceeds 4 MiB (sizeof(*leaf) * total > 5.24 MiB).
> 
> Because kzalloc() requires physically contiguous pages, requests larger
> than MAX_PAGE_ORDER (4 MiB on x86_64) fail and trigger a warning:
> 
>   WARNING: CPU: 123 PID: 119906 at mm/page_alloc.c:5997 __alloc_frozen_pages_noprof+0x50c/0x1050
>   Call Trace:
>    <TASK>
>    alloc_frozen_pages_noprof+0xc0/0x240
>    ___kmalloc_large_node+0x3d/0xd0
>    __kmalloc_large_node_noprof+0x1b/0x90
>    __kmalloc_noprof+0x254/0x660
> [ ... ]
> virtually contiguous memory via vmalloc.
> 
> Fixes: e8c4dbc2fcac ("RDMA/irdma: Add PBLE resource manager")
> Assisted-by: LLM
> Signed-off-by: Jeremy Bongio <jbongio@google.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260916173203.2555458-1-jbongio@google.com?part=1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] RDMA/irdma: Use kvzalloc for lvl2 leafmem allocation
  2026-09-16 17:42 ` sashiko-bot
@ 2026-09-16 18:32   ` Jacob Moroni
  0 siblings, 0 replies; 4+ messages in thread
From: Jacob Moroni @ 2026-09-16 18:32 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: Jeremy Bongio, linux-rdma

Tested-by: Jacob Moroni <jmoroni@google.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] RDMA/irdma: Use kvzalloc for lvl2 leafmem allocation
  2026-09-16 17:32 [PATCH] RDMA/irdma: Use kvzalloc for lvl2 leafmem allocation Jeremy Bongio
  2026-09-16 17:42 ` sashiko-bot
@ 2026-09-22 14:16 ` Leon Romanovsky
  1 sibling, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2026-09-22 14:16 UTC (permalink / raw)
  To: tatyana.e.nikolova, jgg, Jeremy Bongio; +Cc: linux-rdma, jmoroni


On Wed, 16 Sep 2026 17:32:03 +0000, Jeremy Bongio wrote:
> During VM live migration or when registering large memory regions
> (e.g., guest memory >= 256 GB backed by 4 KiB pages), get_lvl2_pble()
> calculates total leaves exceeding ~131,072. The memory required for
> lvl2->leafmem.va exceeds 4 MiB (sizeof(*leaf) * total > 5.24 MiB).
> 
> Because kzalloc() requires physically contiguous pages, requests larger
> than MAX_PAGE_ORDER (4 MiB on x86_64) fail and trigger a warning:
> 
> [...]

Applied, thanks!

[1/1] RDMA/irdma: Use kvzalloc for lvl2 leafmem allocation
      https://git.kernel.org/rdma/rdma/c/9c40f13a63a4b8

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-22 14:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-16 17:32 [PATCH] RDMA/irdma: Use kvzalloc for lvl2 leafmem allocation Jeremy Bongio
2026-09-16 17:42 ` sashiko-bot
2026-09-16 18:32   ` Jacob Moroni
2026-09-22 14:16 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox