Skip to contentSkip to conversation

rdma: display resource limits in curr/max format

PATCH Applied Tao Cui 2 participants 4 messages Jul 16

Subsystems (3)
lore
Share & tools
lore

Tao Cui

author
#0 lore raw

v7 cover rdma: display resource limits in curr/max format

From: Tao Cui <[email protected]>

This series adds support for displaying RDMA device resource limits in curr/max format in the rdma tool, building on the kernel uapi attribute RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_MAX which has landed in linux-next (kernel commit 5911f6d6e7cc [1]).

Patch 1 syncs the rdma_netlink.h uapi header from the kernel. Patch 2 updates the rdma tool to parse the new attribute and display resource usage in curr/max format:

  $ rdma resource show
  0: mlx5_0: qp 123/131072  cq 45/65536  mr 200/1000000  pd 10/32768

[1]:

Tao Cui (2):
rdma: update uapi headers
rdma: display resource limits in curr/max format

 rdma/include/uapi/rdma/rdma_netlink.h |  5 +++++
 rdma/res.c                            | 16 +++++++++++++++-
 rdma/utils.c                          |  1 +
 3 files changed, 21 insertions(+), 1 deletion(-)

---
Changes in v7:
- Drop the unnecessary intermediate buffer in res_print_summary() and pass the format string to pr_out() directly (claude review).
- Add a JSON output example to the tool commit message. Changes in v6:
- Fix the incorrect kernel commit SHA referenced in the uapi headers sync message (5911f6d6e7cc, not 5911f6d6e7ce).
Changes in v5:
- Split the rdma_netlink.h update into its own commit following the uapi headers sync format ("rdma: update uapi headers").
Changes in v4:
- Add a Link: reference to the kernel patch; re-send now that the kernel side has landed in linux-next.

Signature · 1 line
2.43.0
author
#1 lore raw

PATCH v7 1/2 rdma: update uapi headers

From: Tao Cui <[email protected]>

Update rdma_netlink.h file upto kernel commit 5911f6d6e7cc ("RDMA/nldev: Add resource summary max values for usage display")

---
 rdma/include/uapi/rdma/rdma_netlink.h | 5 +++++
 1 file changed, 5 insertions(+)
rdma/include/uapi/rdma/rdma_netlink.h +5 -0
index 4356ec4a..e5b8b065 100644
@@ -604,6 +604,11 @@ enum rdma_nldev_attr {
 	RDMA_NLDEV_ATTR_FRMR_POOL_PINNED_HANDLES,	/* u32 */
 	RDMA_NLDEV_ATTR_FRMR_POOL_KEY_KERNEL_VENDOR_KEY,	/* u64 */
 
+	/*
+	 * Resource summary entry maximum value.
+	 */
+	RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_MAX,		/* u64 */
+
 	/*
 	 * Always the end
 	 */
Signature · 1 line
2.43.0
author
#2 lore raw

PATCH v7 2/2 rdma: display resource limits in curr/max format

In reply to Tao Cui

From: Tao Cui <[email protected]>

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.

---
 rdma/res.c   | 16 +++++++++++++++-
 rdma/utils.c |  1 +
 2 files changed, 16 insertions(+), 1 deletion(-)
rdma/res.c +15 -1
index 062f0007..7efced8d 100644
@@ -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;
 }
rdma/utils.c +1 -0
index 87003b2c..90ea1c55 100644
@@ -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)
Signature · 1 line
2.43.0
#3 lore raw
In reply to Tao Cui
This series was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:

Hello:

This series was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:

Quoted 8 lines · On Thu, 16 Jul 2026 19:52:35 +0800 you wrote:

From: Tao Cui <[email protected]>

This series adds support for displaying RDMA device resource limits in curr/max format in the rdma tool, building on the kernel uapi attribute RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_MAX which has landed in linux-next (kernel commit 5911f6d6e7cc [1]).

[...]

Here is the summary with links:
- [iproute2-next,v7,1/2] rdma: update uapi headers

    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=39eb3a40d967
  - [iproute2-next,v7,2/2] rdma: display resource limits in curr/max format
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=35a237091c24

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html