RDMA tool driver-specific resource tracking
Subsystems (3)
v3 cover RDMA tool driver-specific resource tracking
This series enhances the iproute2 rdma tool to include displaying driver-specific resource attributes. It is the user-space part of the kernel driver resource tracking series that has been accepted for merging into linux-4.18 [1]
If there are no additional review comments, it can now be merged, I think.
Changes since v2:
- resync rdma_netlink.h to fix uapi break
Changes since v1:
- commit log editorial fixes
- cite kernel commits that updated rdma_netlink.h in the iproute2 commit syncing this header
- reorder stack definitions ala "reverse christmas tree"
- correctly handle unknown driver attributes when printing
Changes since v0/rfc:
- changed "provider" to "driver" based on kernel side changes
- updated man pages
- removed "RFC" tag
Thanks,
Steve.
[1] https://www.spinics.net/lists/linux-rdma/msg64199.html
Steve Wise (3):
rdma: update rdma_netlink.h to get new driver attributes
rdma: print driver resource attributes
rdma: update man pages
man/man8/rdma-resource.8 | 29 ++++- man/man8/rdma.8 | 2 +- rdma/include/uapi/rdma/rdma_netlink.h | 30 +++++- rdma/rdma.c | 9 +- rdma/rdma.h | 11 ++ rdma/res.c | 30 ++---- rdma/utils.c | 196 ++++++++++++++++++++++++++++++++++ 7 files changed, 280 insertions(+), 27 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v3 1/3 rdma: update rdma_netlink.h to get new driver attributes
Pull in the rdma_netlink.h changes from kernel
commits:
25a0ad85156a ("RDMA/nldev: Add explicit pad attribute") da5c85078215 ("RDMA/nldev: add driver-specific resource tracking)" 0d52d803767e ("RDMA/uapi: Fix uapi breakage")
--- rdma/include/uapi/rdma/rdma_netlink.h | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
rdma/include/uapi/rdma/rdma_netlink.h +29 -1
@@ -249,10 +249,22 @@ enum rdma_nldev_command {RDMA_NLDEV_NUM_OPS }; +enum { +RDMA_NLDEV_ATTR_ENTRY_STRLEN =16 , +}; + +enum rdma_nldev_print_type { +RDMA_NLDEV_PRINT_TYPE_UNSPEC , +RDMA_NLDEV_PRINT_TYPE_HEX , +}; +enum rdma_nldev_attr {/* don't change the order or add anything between, this is ABI! */ RDMA_NLDEV_ATTR_UNSPEC , +/* Pad attribute for 64b alignment */ +RDMA_NLDEV_ATTR_PAD =RDMA_NLDEV_ATTR_UNSPEC , +/* Identifier for ib_device */ RDMA_NLDEV_ATTR_DEV_INDEX ,/* u32 */
@@ -387,7 +399,6 @@ enum rdma_nldev_attr {RDMA_NLDEV_ATTR_RES_PD_ENTRY ,/* nested table */ RDMA_NLDEV_ATTR_RES_LOCAL_DMA_LKEY ,/* u32 */ RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY, /* u32 */ -/* * Provides logical name and index of netdevice which is * connected to physical port. This information is relevant
@@ -400,7 +411,24 @@ enum rdma_nldev_attr {*/ RDMA_NLDEV_ATTR_NDEV_INDEX ,/* u32 */ RDMA_NLDEV_ATTR_NDEV_NAME ,/* string */ +/* +* driver-specific attributes. +*/ +RDMA_NLDEV_ATTR_DRIVER ,/* nested table */ +RDMA_NLDEV_ATTR_DRIVER_ENTRY ,/* nested table */ +RDMA_NLDEV_ATTR_DRIVER_STRING ,/* string */ +/* +* u8 values from enum rdma_nldev_print_type +*/ +RDMA_NLDEV_ATTR_DRIVER_PRINT_TYPE ,/* u8 */ +RDMA_NLDEV_ATTR_DRIVER_S32 ,/* s32 */ +RDMA_NLDEV_ATTR_DRIVER_U32 ,/* u32 */ +RDMA_NLDEV_ATTR_DRIVER_S64 ,/* s64 */ +RDMA_NLDEV_ATTR_DRIVER_U64 ,/* u64 */ +/* +* Always the end +*/ RDMA_NLDEV_ATTR_MAX };#endif /* _RDMA_NETLINK_H */
Signature · 1 line
1.8.3.1
PATCH v3 2/3 rdma: print driver resource attributes
In reply to Steve WiseThis enhancement allows printing rdma device-specific state, if provided by the kernel. This is done in a generic manner, so rdma tool doesn't need to know about the details of every type of rdma device.
Driver attributes for a rdma resource are in the form of <key, [print_type], value> tuples, where the key is a string and the value can be any supported driver attribute. The print_type attribute, if present, provides a print format to use vs the standard print format for the type. For example, the default print type for a PROVIDER_S32 value is "%d ", but "0x%x " if the print_type of PRINT_TYPE_HEX is included inthe tuple.
Driver resources are only printed when the -dd flag is present. If -p is present, then the output is formatted to not exceed 80 columns, otherwise it is printed as a single row to be grep/awk friendly.
Example output:
# rdma resource show qp lqpn 1028 -dd -p
link cxgb4_0/- lqpn 1028 rqpn 0 type RC state RTS rq-psn 0 sq-psn 0 path-mig-state MIGRATED pid 0 comm [nvme_rdma]
sqid 1028 flushed 0 memsize 123968 cidx 85 pidx 85 wq_pidx 106 flush_cidx 85 in_use 0
size 386 flags 0x0 rqid 1029 memsize 16768 cidx 43 pidx 41 wq_pidx 171 msn 44 rqt_hwaddr 0x2a8a5d00
rqt_size 256 in_use 128 size 130--- rdma/rdma.c | 9 ++- rdma/rdma.h | 11 ++++ rdma/res.c | 30 +++------ rdma/utils.c | 196 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 224 insertions(+), 22 deletions(-)
rdma/rdma.c +7 -2
@@ -129,13 +129,14 @@ int main(int argc, char **argv) { "batch", required_argument, NULL, 'b' }, { NULL, 0, NULL, 0 } }; +bool show_driver_details = false;const char *batch_file =NULL ;bool pretty_output = false;bool show_details = false;bool json_output = false;bool force = false; -char *filename;struct rd rd = {}; +char *filename;int opt;int err;
@@ -152,7 +153,10 @@ int main(int argc, char **argv) pretty_output = true;break ;case 'd' : - show_details = true; +if (show_details) + show_driver_details = true; +else + show_details = true;break ;case 'j' : json_output = true;
@@ -180,6 +184,7 @@ int main(int argc, char **argv) argv += optind; rd.show_details = show_details; + rd.show_driver_details = show_driver_details; rd.json_output = json_output; rd.pretty_output = pretty_output;
rdma/rdma.h +11 -0
@@ -55,6 +55,7 @@ struct rd {char **argv;char *filename;bool show_details; +bool show_driver_details;struct list_head dev_map_list;uint32_t dev_idx;uint32_t port_idx;
@@ -115,4 +116,14 @@ int rd_recv_msg(struct rd *rd, mnl_cb_t callback, void *data, uint32_t seq);void rd_prepare_msg (struct rd *rd,uint32_t cmd,uint32_t *seq,uint16_t flags);int rd_dev_init_cb (const struct nlmsghdr *nlh,void *data);int rd_attr_cb (const struct nlattr *attr,void *data); +int rd_attr_check (const struct nlattr *attr,int *typep); + +/* +* Print helpers +*/ +void print_driver_table (struct rd *rd,struct nlattr *tb); +void newline (struct rd *rd); +void newline_indent (struct rd *rd); +#define MAX_LINE_LENGTH 80 +#endif /* _RDMA_TOOL_H_ */
rdma/res.c +10 -20
@@ -439,10 +439,8 @@ static int res_qp_parse_cb(const struct nlmsghdr *nlh, void *data)if (nla_line[RDMA_NLDEV_ATTR_RES_PID ])free (comm); -if (rd->json_output) -jsonw_end_array (rd->jw); -else -pr_out ("\n" ); +print_driver_table (rd, nla_line[RDMA_NLDEV_ATTR_DRIVER ]); +newline (rd); }return MNL_CB_OK ; }
@@ -678,10 +676,8 @@ static int res_cm_id_parse_cb(const struct nlmsghdr *nlh, void *data)if (nla_line[RDMA_NLDEV_ATTR_RES_PID ])free (comm); -if (rd->json_output) -jsonw_end_array (rd->jw); -else -pr_out ("\n" ); +print_driver_table (rd, nla_line[RDMA_NLDEV_ATTR_DRIVER ]); +newline (rd); }return MNL_CB_OK ; }
@@ -804,10 +800,8 @@ static int res_cq_parse_cb(const struct nlmsghdr *nlh, void *data)if (nla_line[RDMA_NLDEV_ATTR_RES_PID ])free (comm); -if (rd->json_output) -jsonw_end_array (rd->jw); -else -pr_out ("\n" ); +print_driver_table (rd, nla_line[RDMA_NLDEV_ATTR_DRIVER ]); +newline (rd); }return MNL_CB_OK ; }
@@ -919,10 +913,8 @@ static int res_mr_parse_cb(const struct nlmsghdr *nlh, void *data)if (nla_line[RDMA_NLDEV_ATTR_RES_PID ])free (comm); -if (rd->json_output) -jsonw_end_array (rd->jw); -else -pr_out ("\n" ); +print_driver_table (rd, nla_line[RDMA_NLDEV_ATTR_DRIVER ]); +newline (rd); }return MNL_CB_OK ; }
@@ -1004,10 +996,8 @@ static int res_pd_parse_cb(const struct nlmsghdr *nlh, void *data)if (nla_line[RDMA_NLDEV_ATTR_RES_PID ])free (comm); -if (rd->json_output) -jsonw_end_array (rd->jw); -else -pr_out ("\n" ); +print_driver_table (rd, nla_line[RDMA_NLDEV_ATTR_DRIVER ]); +newline (rd); }return MNL_CB_OK ; }
rdma/utils.c +196 -0
213 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v3 3/3 rdma: update man pages
In reply to Steve WiseUpdate the man pages for the resource attributes as well as the driver-specific attributes.
--- man/man8/rdma-resource.8 | 29 ++++++++++++++++++++++++++--- man/man8/rdma.8 | 2 +- 2 files changed, 27 insertions(+), 4 deletions(-)
man/man8/rdma-resource.8 +26 -3
@@ -7,13 +7,16 @@ rdma-resource \- rdma resource configuration .in +8 .ti -8 .B rdma -.RI "[ " OPTIONS " ]" -.B resource -.RI " { " COMMAND " | " +.RI "[ " OPTIONS " ] " RESOURCE " { " COMMAND " | " .BR help " }" .sp .ti -8 +.IR RESOURCE " := { " +.BR cm_id " | " cq " | " mr " | " pd " | " qp " }" +.sp + +.ti -8 .IR OPTIONS " := { " \fB\-j\fR[\fIson\fR] | \fB\-d\fR[\fIetails\fR] }
@@ -70,11 +73,31 @@ rdma res show qp link mlx5_4/- -d Detailed view. .RE .PP +rdma res show qp link mlx5_4/- -dd +.RS 4 +Detailed view including driver-specific details. +.RE +.PP rdma res show qp link mlx5_4/1 lqpn 0-6 .RS 4 Limit to specific Local QPNs. .RE .PP +rdma resource show cm_id dst-port 7174 +.RS 4 +Show CM_IDs with destination ip port of 7174. +.RE +.PP +rdma resource show cm_id src-addr 172.16.0.100 +.RS 4 +Show CM_IDs bound to local ip address 172.16.0.100 +.RE +.PP +rdma resource show cq pid 30489 +.RS 4 +Show CQs belonging to pid 30489 +.RE +.PP .SH SEE ALSO .BR rdma (8),
man/man8/rdma.8 +1 -1
@@ -49,7 +49,7 @@ If there were any errors during execution of the commands, the application retur .TP .BR "\-d" , " --details" -Output detailed information. +Output detailed information. Adding a second \-d includes driver-specific details. .TP .BR "\-p" , " --pretty"
Signature · 1 line
1.8.3.1
David Ahern
AppliedQuoted 7 lines · Steve Wise
This series enhances the iproute2 rdma tool to include displaying driver-specific resource attributes. It is the user-space part of the kernel driver resource tracking series that has been accepted for merging into linux-4.18 [1]
If there are no additional review comments, it can now be merged, I think.
applied to iproute2-next.
BTW: Something is off with the header dependencies. After applying patch 1 nothing was rebuilt.