From: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Li Dongyang <dongyang.li-FCV4sgi5zeUQrrorzV6ljw@public.gmane.org>
Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] IB/mlx5: fall back to vmalloc for mlx5_ib_wq
Date: Wed, 16 Aug 2017 15:12:05 +0300 [thread overview]
Message-ID: <20170816121205.GN24282@mtr-leonro.local> (raw)
In-Reply-To: <20170816110632.9779-1-dongyang.li-FCV4sgi5zeUQrrorzV6ljw@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 1690 bytes --]
On Wed, Aug 16, 2017 at 09:06:32PM +1000, Li Dongyang wrote:
> We observed multiple times on our Lustre OSS servers that when
> the system memory is fragmented, kmalloc() in create_kernel_qp()
> could fail order 4/5 allocations while we still have many free pages.
>
> Fall back to vmalloc to allow the operation to contine, also switch
> to kmalloc_array() from kmalloc().
>
> Signed-off-by: Li Dongyang <dongyang.li-FCV4sgi5zeUQrrorzV6ljw@public.gmane.org>
> ---
> drivers/infiniband/hw/mlx5/qp.c | 54 +++++++++++++++++++++++++++++-----------
> drivers/infiniband/hw/mlx5/srq.c | 8 ++++--
> 2 files changed, 45 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c
> index 0889ff367c86..e662fa5af5bb 100644
> --- a/drivers/infiniband/hw/mlx5/qp.c
> +++ b/drivers/infiniband/hw/mlx5/qp.c
> @@ -959,11 +959,35 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev,
> goto err_free;
> }
>
> - qp->sq.wrid = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wrid), GFP_KERNEL);
> - qp->sq.wr_data = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wr_data), GFP_KERNEL);
> - qp->rq.wrid = kmalloc(qp->rq.wqe_cnt * sizeof(*qp->rq.wrid), GFP_KERNEL);
> - qp->sq.w_list = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.w_list), GFP_KERNEL);
> - qp->sq.wqe_head = kmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wqe_head), GFP_KERNEL);
> + qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt, sizeof(*qp->sq.wrid),
> + GFP_KERNEL | __GFP_NOWARN);
> + if (!qp->sq.wrid)
> + qp->sq.wrid = __vmalloc(qp->sq.wqe_cnt * sizeof(*qp->sq.wrid),
> + GFP_KERNEL, PAGE_KERNEL);
Please don't open code, the kvmalloc and kvmalloc_array functions.
Thanks for doing it.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-08-16 12:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-16 11:06 [PATCH] IB/mlx5: fall back to vmalloc for mlx5_ib_wq Li Dongyang
[not found] ` <20170816110632.9779-1-dongyang.li-FCV4sgi5zeUQrrorzV6ljw@public.gmane.org>
2017-08-16 12:12 ` Leon Romanovsky [this message]
[not found] ` <20170816121205.GN24282-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-08-16 12:50 ` Dongyang Li
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=20170816121205.GN24282@mtr-leonro.local \
--to=leon-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=dongyang.li-FCV4sgi5zeUQrrorzV6ljw@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox