All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: Qiliang Yuan <qiliang.yuan@linux.dev>,
	Zhu Yanjun <zyjzyj2000@gmail.com>, Jason Gunthorpe <jgg@ziepe.ca>,
	Leon Romanovsky <leon@kernel.org>,
	Li Zhijian <lizhijian@fujitsu.com>
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	Zhu Yanjun <yanjun.zhu@linux.dev>,
	stable@vger.kernel.org
Subject: Re: [PATCH for-rc] RDMA/rxe: Allocate the MR page array with kvzalloc()
Date: Tue, 24 Nov 2026 11:11:36 -0800	[thread overview]
Message-ID: <eabf4f7d-c3e7-4914-ae2f-e2688c992e86@linux.dev> (raw)
In-Reply-To: <20261123-bug-rdma-rxe-large-mr-v1-1-8d0748ac4a3f@linux.dev>


在 2026/11/23 1:26, Qiliang Yuan 写道:
> 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

Thanks a lot. kzalloc_objs only allocates contiguous physical memory,

whereas kvzalloc_objs can allocate non-contiguous memory—making

kvzalloc_objs much less likely to fail when allocating large amounts of 
memory.

Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>

Yanjun Zhu

>
> Fixes: 12985e5915a0b ("RDMA/rxe: Fix iova-to-va conversion for MR page sizes != PAGE_SIZE")
> Cc: stable@vger.kernel.org
> Signed-off-by: Qiliang Yuan <qiliang.yuan@linux.dev>
> ---
>   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,

-- 
Best Regards,
Yanjun.Zhu


  parent reply	other threads:[~2026-11-24 19:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  9:26 [PATCH for-rc] RDMA/rxe: Allocate the MR page array with kvzalloc() Qiliang Yuan
2026-11-23  9:33 ` sashiko-bot
2026-11-24 19:11 ` Zhu Yanjun [this message]
2026-11-25 10:42 ` Zhijian Li (Fujitsu)
2026-11-26 13:57 ` Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eabf4f7d-c3e7-4914-ae2f-e2688c992e86@linux.dev \
    --to=yanjun.zhu@linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=lizhijian@fujitsu.com \
    --cc=qiliang.yuan@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=zyjzyj2000@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.