From: Tao Cui <cui.tao@linux.dev>
To: dsahern@kernel.org, leonro@nvidia.com
Cc: linux-rdma@vger.kernel.org, netdev@vger.kernel.org,
Tao Cui <cuitao@kylinos.cn>
Subject: [PATCH iproute2-next v7 2/2] rdma: display resource limits in curr/max format
Date: Thu, 16 Jul 2026 19:52:37 +0800 [thread overview]
Message-ID: <20260716115237.1859633-3-cui.tao@linux.dev> (raw)
In-Reply-To: <20260716115237.1859633-1-cui.tao@linux.dev>
From: Tao Cui <cuitao@kylinos.cn>
Parse the new RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_MAX netlink attribute
to show resource limits alongside current counts in curr/max format:
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
JSON output provides separate <name> and <name>-max fields per resource
type, so scripts can compute usage against the device limit; resources
without an upper bound (e.g. cm_id, ctx) are reported without a -max
field:
$ rdma resource show -j
[{
"ifindex": 0,
"ifname": "mlx5_0",
"qp": 123, "qp-max": 131072,
"cq": 45, "cq-max": 65536,
"mr": 200, "mr-max": 1000000,
"pd": 10, "pd-max": 32768,
"cm_id": 0, "ctx": 0
}]
Backward compatible: no output change when the kernel lacks the new
attribute.
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
Link: https://lore.kernel.org/all/20260615003646.168704-1-cui.tao@linux.dev/
---
rdma/res.c | 16 +++++++++++++++-
rdma/utils.c | 1 +
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/rdma/res.c b/rdma/res.c
index 062f0007..7efced8d 100644
--- a/rdma/res.c
+++ b/rdma/res.c
@@ -55,7 +55,21 @@ static int res_print_summary(struct nlattr **tb)
name = mnl_attr_get_str(nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_NAME]);
curr = mnl_attr_get_u64(nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR]);
- res_print_u64(name, curr, nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR]);
+ if (nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_MAX]) {
+ uint64_t max;
+ char max_name[64];
+
+ max = mnl_attr_get_u64(
+ nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_MAX]);
+ snprintf(max_name, sizeof(max_name), "%s-max", name);
+ print_u64(PRINT_JSON, name, NULL, curr);
+ print_u64(PRINT_JSON, max_name, NULL, max);
+ if (!is_json_context())
+ pr_out("%s %" PRIu64 "/%" PRIu64 " ", name, curr, max);
+ } else {
+ res_print_u64(name, curr,
+ nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR]);
+ }
}
return 0;
}
diff --git a/rdma/utils.c b/rdma/utils.c
index 87003b2c..90ea1c55 100644
--- a/rdma/utils.c
+++ b/rdma/utils.c
@@ -480,6 +480,7 @@ static const enum mnl_attr_data_type nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
[RDMA_NLDEV_ATTR_EVENT_TYPE] = MNL_TYPE_U8,
[RDMA_NLDEV_SYS_ATTR_MONITOR_MODE] = MNL_TYPE_U8,
[RDMA_NLDEV_ATTR_STAT_OPCOUNTER_ENABLED] = MNL_TYPE_U8,
+ [RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_MAX] = MNL_TYPE_U64,
};
static int rd_attr_check(const struct nlattr *attr, int *typep)
--
2.43.0
prev parent reply other threads:[~2026-07-16 11:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 11:52 [PATCH iproute2-next v7 0/2] rdma: display resource limits in curr/max format Tao Cui
2026-07-16 11:52 ` [PATCH iproute2-next v7 1/2] rdma: update uapi headers Tao Cui
2026-07-16 11:52 ` Tao Cui [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=20260716115237.1859633-3-cui.tao@linux.dev \
--to=cui.tao@linux.dev \
--cc=cuitao@kylinos.cn \
--cc=dsahern@kernel.org \
--cc=leonro@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox