All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Tao Cui <cuitao@kylinos.cn>
Cc: jgg@ziepe.ca, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH rdma-next v2] RDMA/nldev: add resource summary max values for usage display
Date: Wed, 10 Jun 2026 11:02:23 +0300	[thread overview]
Message-ID: <20260610080223.GE327369@unreal> (raw)
In-Reply-To: <20260515073307.428768-1-cuitao@kylinos.cn>

On Fri, May 15, 2026 at 03:33:07PM +0800, Tao Cui wrote:
> Add RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_MAX netlink attribute to expose
> device resource limits (max_qp, max_cq, max_mr, max_pd, max_srq) in
> the resource summary alongside the existing current count. This allows
> userspace tools like iproute2's rdma to display resource usage in
> curr/max format.
> 
> Expected output from "rdma resource show":
>   Before: 0: mlx5_0: qp 123  cq 45  mr 200  pd 10
>   After:  0: mlx5_0: qp 123/131072  cq 45/65536  mr 200/1000000  pd 10/32768
> 
> In JSON output, both "curr" and "max" fields will be provided so that
> scripts can compute percentages if needed.
> 
> The new attribute is optional and backward compatible - old userspace
> tools will simply ignore it.
> 
> Signed-off-by: Tao Cui <cuitao@kylinos.cn>
> ---
>  drivers/infiniband/core/nldev.c  | 29 ++++++++++++++++++++++++++---
>  include/uapi/rdma/rdma_netlink.h |  5 +++++
>  2 files changed, 31 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
> index 96c745d5bac4..879aaa7960fe 100644
> --- a/drivers/infiniband/core/nldev.c
> +++ b/drivers/infiniband/core/nldev.c
> @@ -187,6 +187,7 @@ static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
>  	[RDMA_NLDEV_ATTR_FRMR_POOLS_AGING_PERIOD] = { .type = NLA_U32 },
>  	[RDMA_NLDEV_ATTR_FRMR_POOL_PINNED_HANDLES] = { .type = NLA_U32 },
>  	[RDMA_NLDEV_ATTR_FRMR_POOL_KEY_KERNEL_VENDOR_KEY] = { .type = NLA_U64 },
> +	[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_MAX]	= { .type = NLA_U64 },
>  };

<...>

>  	if (fill_nldev_handle(msg, device))
>  		return -EMSGSIZE;
> @@ -462,7 +466,26 @@ static int fill_res_info(struct sk_buff *msg, struct ib_device *device,
>  		if (!names[i])
>  			continue;
>  		curr = rdma_restrack_count(device, i, show_details);
> -		ret = fill_res_info_entry(msg, names[i], curr);
> +		switch (i) {
> +		case RDMA_RESTRACK_QP:
> +			max = device->attrs.max_qp;
> +			break;
> +		case RDMA_RESTRACK_CQ:
> +			max = device->attrs.max_cq;
> +			break;
> +		case RDMA_RESTRACK_MR:
> +			max = device->attrs.max_mr;
> +			break;
> +		case RDMA_RESTRACK_PD:
> +			max = device->attrs.max_pd;
> +			break;
> +		case RDMA_RESTRACK_SRQ:
> +			max = device->attrs.max_srq;
> +			break;
> +		default:
> +			max = 0;

The more accurate approach is to avoid setting the  
RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_MAX field for cases that have no  
limitations, and let iproute2 decide how to handle it.

Thanks

      reply	other threads:[~2026-06-10  8:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15  7:33 [PATCH rdma-next v2] RDMA/nldev: add resource summary max values for usage display Tao Cui
2026-06-10  8:02 ` Leon Romanovsky [this message]

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=20260610080223.GE327369@unreal \
    --to=leon@kernel.org \
    --cc=cuitao@kylinos.cn \
    --cc=jgg@ziepe.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.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 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.