Skip to contentSkip to conversation

rdma: display resource limits in curr/max format

PATCH Superseded Tao Cui 2 participants 4 messages Jun 15 – Jun 29

Subsystems (3)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Tao Cui

author
#0 lore raw

PATCH v3 1/1 rdma: display resource limits in curr/max format

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 both current and max fields per resource type (e.g. "qp": 123, "qp-max": 131072). Backward compatible: no output change when kernel lacks the new attribute.

---
 rdma/include/uapi/rdma/rdma_netlink.h |  5 +++++
 rdma/res.c                            | 21 ++++++++++++++++++++-
 rdma/utils.c                          |  1 +
 3 files changed, 26 insertions(+), 1 deletion(-)
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
 	 */
rdma/res.c +20 -1
index 062f0007..046935e2 100644
@@ -55,7 +55,26 @@ 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()) {
+				char buf[64];
+
+				snprintf(buf, sizeof(buf), "%s %" PRIu64 "/%" PRIu64 " ",
+					 name, curr, max);
+				pr_out("%s", buf);
+			}
+		} 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
#1 lore raw

rdma/include/uapi/rdma/rdma_netlink.h enum rdma_nldev_attr { · line 610

Quoted 12 lines · Tao Cui
rdma/include/uapi/rdma/rdma_netlink.h +4 -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 */

I do not see this uapi in Linus' tree. What is the status of the kernel commit? Put a reference to the kernel patches in the commit message.

author
#2 lore raw

Hi David,

Thanks for taking a look.

The kernel counterpart that introduces this uapi attribute is the following patch, currently under review on the rdma list and not yet in Linus' tree:

[PATCH rdma-next v3] RDMA/nldev: add resource summary max values for usage display
https://lore.kernel.org/all/[email protected]/

That is the one adding RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_MAX.

You're right that the iproute2 side should reference the kernel patch. I'll add a Link to it in the commit log of the next revision, e.g.:

If you'd prefer, I can also hold this iproute2 patch until the kernel side has landed, so the uapi is already in tree when it goes in. Happy to do whichever you think is best.

Thanks,
Tao

Quoted 17 lines · David Ahern

rdma/include/uapi/rdma/rdma_netlink.h enum rdma_nldev_attr { · line 610

Quoted 12 lines · Tao Cui
rdma/include/uapi/rdma/rdma_netlink.h +4 -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 */

I do not see this uapi in Linus' tree. What is the status of the kernel commit? Put a reference to the kernel patches in the commit message.

#3 lore raw
Quoted 3 lines · Tao Cui

If you'd prefer, I can also hold this iproute2 patch until the kernel side has landed, so the uapi is already in tree when it goes in. Happy to do whichever you think is best.

That is the request - resend after it lands with a reference to the patch set.