From: Leon Romanovsky <leon@kernel.org>
To: Wenpeng Liang <liangwenpeng@huawei.com>
Cc: dledford@redhat.com, jgg@nvidia.com, linux-rdma@vger.kernel.org,
linuxarm@huawei.com, Xi Wang <wangxi11@huawei.com>
Subject: Re: [PATCH v3 for-next 12/12] RDMA/hns: Dump detailed driver-specific UCTX
Date: Tue, 27 Jul 2021 14:57:06 +0300 [thread overview]
Message-ID: <YP/0ksOdlErAT9lh@unreal> (raw)
In-Reply-To: <1627356452-30564-13-git-send-email-liangwenpeng@huawei.com>
On Tue, Jul 27, 2021 at 11:27:32AM +0800, Wenpeng Liang wrote:
> From: Xi Wang <wangxi11@huawei.com>
>
> Dump DCA mem pool status in UCTX restrack.
>
> Sample output:
> $ rdma res show ctx dev hns_0 -dd
> dev hns_0 ctxn 7 pid 1410 comm python3 drv_dca-loading 37.50 drv_dca-total 65536 drv_dca-free 40960
> dev hns_0 ctxn 8 pid 1410 comm python3 drv_dca-loading 0.00 drv_dca-total 0 drv_dca-free 0
>
> Signed-off-by: Xi Wang <wangxi11@huawei.com>
> Signed-off-by: Wenpeng Liang <liangwenpeng@huawei.com>
> ---
> drivers/infiniband/hw/hns/hns_roce_device.h | 2 +
> drivers/infiniband/hw/hns/hns_roce_main.c | 1 +
> drivers/infiniband/hw/hns/hns_roce_restrack.c | 85 +++++++++++++++++++++++++++
> 3 files changed, 88 insertions(+)
<...>
> +static int hns_roce_fill_dca_uctx(struct hns_roce_dca_ctx *ctx,
> + struct sk_buff *msg)
> +{
> + char tmp_str[LOADING_PERCENT_CHARS];
> + unsigned long flags;
> + u64 total, free;
> + u64 percent;
> + u32 rem = 0;
> +
> + spin_lock_irqsave(&ctx->pool_lock, flags);
> + total = ctx->total_size;
> + free = ctx->free_size;
> + spin_unlock_irqrestore(&ctx->pool_lock, flags);
> +
> + percent = calc_dca_loading_percent(total, free, &rem);
> + scnprintf(tmp_str, sizeof(tmp_str), "%llu.%0*u\n", percent,
> + LOADING_PERCENT_SHIFT, rem);
> +
> + if (rdma_nl_put_driver_string(msg, "dca-loading", tmp_str))
> + goto err;
Please no, users can calculate percentage by themselves. We don't need
to complicate kernel for it.
Thanks
> +
> + if (rdma_nl_put_driver_u64(msg, "dca-total", total))
> + goto err;
> +
> + if (rdma_nl_put_driver_u64(msg, "dca-free", free))
> + goto err;
> +
> + return 0;
> +
> +err:
> + return -EMSGSIZE;
> +}
> +
> +int hns_roce_fill_res_ctx_entry(struct sk_buff *msg, struct ib_ucontext *ctx)
> +{
> + struct hns_roce_dev *hr_dev = to_hr_dev(ctx->device);
> + struct hns_roce_ucontext *uctx = to_hr_ucontext(ctx);
> + struct nlattr *table_attr;
> +
> + table_attr = nla_nest_start(msg, RDMA_NLDEV_ATTR_DRIVER);
> + if (!table_attr)
> + goto err;
> +
> + if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_DCA_MODE) {
> + if (hns_roce_fill_dca_uctx(&uctx->dca_ctx, msg))
> + goto err_cancel_table;
> + }
> +
> + nla_nest_end(msg, table_attr);
> +
> + return 0;
> +
> +err_cancel_table:
> + nla_nest_cancel(msg, table_attr);
> +err:
> + return -EMSGSIZE;
> +
> + return 0;
> +}
> --
> 2.8.1
>
next prev parent reply other threads:[~2021-07-27 11:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-27 3:27 [PATCH v3 for-next 00/12] RDMA/hns: Add support for Dynamic Context Attachment Wenpeng Liang
2021-07-27 3:27 ` [PATCH v3 for-next 01/12] RDMA/hns: Introduce DCA for RC QP Wenpeng Liang
2021-07-27 12:07 ` Leon Romanovsky
2021-07-28 6:10 ` Wenpeng Liang
2021-07-27 3:27 ` [PATCH v3 for-next 02/12] RDMA/hns: Add method for shrinking DCA memory pool Wenpeng Liang
2021-07-27 3:27 ` [PATCH v3 for-next 03/12] RDMA/hns: Configure DCA mode for the userspace QP Wenpeng Liang
2021-07-27 3:27 ` [PATCH v3 for-next 04/12] RDMA/hns: Refactor QP modify flow Wenpeng Liang
2021-07-27 3:27 ` [PATCH v3 for-next 05/12] RDMA/hns: Add method for attaching WQE buffer Wenpeng Liang
2021-07-27 3:27 ` [PATCH v3 for-next 06/12] RDMA/hns: Setup the configuration of WQE addressing to QPC Wenpeng Liang
2021-07-27 3:27 ` [PATCH v3 for-next 07/12] RDMA/hns: Add method to detach WQE buffer Wenpeng Liang
2021-07-27 3:27 ` [PATCH v3 for-next 08/12] RDMA/hns: Add method to query WQE buffer's address Wenpeng Liang
2021-07-27 3:27 ` [PATCH v3 for-next 09/12] RDMA/hns: Add a shared memory to sync DCA status Wenpeng Liang
2021-07-27 3:27 ` [PATCH v3 for-next 10/12] RDMA/hns: Sync DCA status by the shared memory Wenpeng Liang
2021-07-27 3:27 ` [PATCH v3 for-next 11/12] RDMA/nldev: Add detailed CTX information support Wenpeng Liang
2021-07-27 3:27 ` [PATCH v3 for-next 12/12] RDMA/hns: Dump detailed driver-specific UCTX Wenpeng Liang
2021-07-27 11:57 ` Leon Romanovsky [this message]
2021-07-28 6:13 ` Wenpeng Liang
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=YP/0ksOdlErAT9lh@unreal \
--to=leon@kernel.org \
--cc=dledford@redhat.com \
--cc=jgg@nvidia.com \
--cc=liangwenpeng@huawei.com \
--cc=linux-rdma@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=wangxi11@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox